Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
docs: add instructions for viem
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Jul 6, 2023
1 parent 2969bc7 commit 12c1382
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/packages/ganache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 12c1382

Please sign in to comment.