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

What exactly is ganache.provider() ? #4109

Answered by jeffsmale90
challet asked this question in Q&A
Discussion options

You must be logged in to vote

ganache.provider() will create an instance of Ganache (within the javascript context; nodejs or browser), and return an EIP-1193 provider to that Ganache instance. You can configure the Ganache instance by providing startup options object.

const ganache = require("ganache");

const options = {};
const provider = ganache.provider(options);
const accounts = await provider.request({ method: "eth_accounts", params: [] });

If you wanted to have a provider to an instance of Ganache running in the CLI, you could use web3js, ethers or other library, and pass in the websockets or http url for your CLI instance of Ganache.

Hope that helps!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@challet
Comment options

Answer selected by davidmurdoch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants