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

docs: add instructions for using ganache with viem #4476

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion 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