What exactly is ganache.provider() ? #4109
-
Hello, I may be confusing but is ganache.provider() an adapter to connect to a Ganache backend (cli ran for instance) or is it the actual EVM simulator running inside Node.js or the browser ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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! |
Beta Was this translation helpful? Give feedback.
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.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!