我正在尝试使用Ethers.js从KyberSwap获取ETH的价格,但是我收到了以下错误信息:
我连接到一个Infura Web Socket来获取数据。这是我的脚本:
怎么修复这个错误?
Error: unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.5.3)
我连接到一个Infura Web Socket来获取数据。这是我的脚本:
const { ethers } = require("hardhat");
const kyberABI = require('./kyberABI.json')
const provider = new ethers.providers.WebSocketProvider(
"wss://mainnet.infura.io/ws/v3/<project_id>")
const kyberNetworkProxyAddress = "0x818E6FECD516Ecc3849DAf6845e3EC868087B755"
const daiAddress = "0x6b175474e89094c44da98b954eedeac495271d0f"
const kyber = new ethers.Contract(
kyberNetworkProxyAddress,
kyberABI.kyberNetworkProxy,
provider.getSigner(),
);
async function main() {
// Update eth price from Kyber to reflect current market value
let curEthPriceUSD
const updateEthPrice = async () => {
const results = await kyber.getExpectedRate(
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
daiAddress,
1
)
curEthPriceUSD = results.expectedRate
}
await updateEthPrice()
console.log('Current Ethereum price in USD is: ',
ethers.utils.formatEther(curEthPriceUSD))
}
main()
怎么修复这个错误?