1
const {ChainId, Fetcher, WETH, Route, Trade, TokenAmount, TradeType, Percent} = require ('@uniswap/sdk');
const ethers = require('ethers');

const chainId = ChainId.MAINNET;

我如何将其指定为本地分叉的 ganache 链?

试过这个:

const Web3 = require('web3');
const web3 = new Web3(`http://localhost:8545`);

const tokenAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F';

const init = async ()=> {
  const chainId = await web3.eth.getChainId();

...

显示以下错误:

/Users/GreyShadow/node_modules/@ethersproject/logger/lib/index.js:179 var error = new Error(message); ^

错误:不支持 getDefaultProvider 网络(操作=“getDefaultProvider”,网络={“chainId”:1337,“名称”:“未知”},代码=NETWORK_ERROR,版本=提供者/5.0.17)

非常感谢帮助

4

0 回答 0