diff --git a/packages/ganache/README.md b/packages/ganache/README.md index 0075c03c3b..b6bd561805 100644 --- a/packages/ganache/README.md +++ b/packages/ganache/README.md @@ -146,7 +146,7 @@ You can use Ganache programmatically from Node.js. Install Ganache into your npm $ npm install ganache ``` -Then you can use ganache as an [EIP-1193 provider only](#as-an-eip-1193-provider-only), an [EIP-1193 provider and JSON-RPC web server](#as-an-eip-1193-provider-and-json-rpc-web-server), as a [Web3 provider](#as-a-web3js-provider), or an [ethers provider](#as-an-ethersjs-provider). +Then you can use ganache as an [EIP-1193 provider only](#as-an-eip-1193-provider-only), an [EIP-1193 provider and JSON-RPC web server](#as-an-eip-1193-provider-and-json-rpc-web-server), as a [Web3 provider](#as-a-web3js-provider), an [ethers provider](#as-an-ethersjs-provider), or a [viem transport](#as-a-viem-transport). #### As an EIP-1193 provider only: @@ -203,6 +203,20 @@ const ganache = require("ganache"); const provider = new ethers.providers.Web3Provider(ganache.provider()); ``` +#### As a [viem](https://www.npmjs.com/package/viem) transport: + +To use a ganache provider as a viem transport: + +```javascript +import { createWalletClient, custom } from "viem"; +import { localhost } from "viem/chains"; +import ganache from "ganache"; +const client = createWalletClient({ + chain: localhost, + transport: custom(ganache.provider()) +}); +``` + ### Browser Use You can also use Ganache in the browser by adding the following script to your HTML: