由于HttpProviderError错误,无法批准合同到ERC-20令牌



OracleSwap是一个DEX,是Uniswap的一个分支。

最终目标是我试图增加流动性https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-01 addliquidity

为了做到这一点,首先我们需要批准OracleSwapRouter合约来使用erc20令牌。

当我试图在鸣禽(EVM兼容)网络中approveOracleSwapRouter时,我得到以下错误,以便我可以在农场上提供流动性。我不确定这是RPC速率限制问题还是代码有问题。

ProviderError: HttpProviderError
at HttpProvider.request (<path>/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
at LocalAccountsProvider.request (<path>/node_modules/hardhat/src/internal/core/providers/accounts.ts:181:36)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async EthersProviderWrapper.send (<path>/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

任何帮助都是感激的。提前谢谢你

相关链接

oracle erc20 token——比;https://songbird-explorer.flare.network/address/0xD7565b16b65376e2Ddb6c71E7971c7185A7Ff3Ff

contract to approve (OracleSwapRouter)——比;https://songbird-explorer.flare.network/address/0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4

下面是相关的代码片段
const OracleSwapRouterContract = await ethers.getContractAt(OracleSwapRouterAbi.default,
"0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4");
const oracleContract = await ethers.getContractAt(oracleAbi.default,  "0xd7565b16b65376e2ddb6c71e7971c7185a7ff3ff");
await oracleContract.approve(
"0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4",
oracleBalance
);

下面的代码给了我帐户的余额,所以我知道oracleccontract不是问题。

const oracleBalance = await oracleContract.balanceOf(SONGBIRD_ACC);

my hardhat network config

songbird: {
url: "https://songbird-api.flare.network/ext/C/rpc",
chainId: 19,
accounts:
SONGBIRD_PRIVATE_KEY !== undefined ? [SONGBIRD_PRIVATE_KEY] : [],
gasPrice: 900000000,
},

您可以在node_modules/hardhat/internal/core/providers/http.js中添加一些行进行调试。每次isErrorResponse检查后,添加:console.log(response)console.log(jsonRpcResponse)

很可能是你的合同或部署脚本(或两者)中的错误。

最新更新