微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在这种情况下如何设置 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 举报,一经查实,本站将立刻删除。