在这种情况下如何设置 etherscan API?

问题描述

如果我运行此代码,我仍然收到错误消息,指出我没有使用 API 密钥,因此代码运行缓慢。如何激活我的密钥?

 import { createRequire } from 'module';
    const require = createRequire(import.Meta.url);
    // can Now use `require` in an ESM
    
    const ethers = require('ethers');
    const uniswap = require('@uniswap/sdk');
    
    const myProvider = ethers.getDefaultProvider("homestead",{
        etherscan: "MY-API-Key",});
    import { ChainId,Token,WETH,Fetcher,Trade,Route,TokenAmount,TradeType } from '@uniswap/sdk'
    // while (true){ //reserved for later because of API testing
    var i;
    for (i = 0; i < 11; i++) {
    
        const tokenAddress = '0x2ba592F78dB6436527729929AAf6c908497cB200' // CREAM Mainnet
        const CREAM = new Token(ChainId.MAINNET,'0x2ba592F78dB6436527729929AAf6c908497cB200',18)
    
        // note that you may want/need to handle this async code differently,// for example if top-level await is not an option
        const pair = await Fetcher.fetchPairData(CREAM,WETH[CREAM.chainId])
    
        const route = new Route([pair],WETH[CREAM.chainId])
    
        const Trade = new Trade(route,new TokenAmount(WETH[CREAM.chainId],'1000000000000000000'),TradeType.EXACT_INPUT)
    
        console.log(Trade.executionPrice.toSignificant(6))
        // console.log(Trade.nextMidPrice.toSignificant(6)) //I settle for executionPrice for Now
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)