简体   繁体   English

由于 ProviderError: HttpProviderError 错误,无法批准 ERC-20 代币合约

[英]cannot approve contract to ERC-20 token due to ProviderError: HttpProviderError error

OracleSwap is a DEX that is a fork of Uniswap. OracleSwap 是一个 DEX,它是 Uniswap 的一个分支。

The end goal is I am trying to add liquidity https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-01#addliquidity最终目标是我正在尝试增加流动性https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-01#addliquidity

In order to do this, first we need to approve the OracleSwapRouter contract to spend the erc20 token.为此,首先我们需要批准 OracleSwapRouter 合约使用 erc20 代币。

I get below error when I am trying to approve to OracleSwapRouter in songbird (EVM compatible) network so that I can provide liquidity on the farm.当我试图approve OracleSwapRouter (EVM 兼容)网络中的 OracleSwapRouter 以便我可以在农场提供流动性时,我遇到了以下错误。 I am not sure if this is an RPC rate-limiting issue or if something is wrong with the code.我不确定这是 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)

Any help is appreciated.任何帮助表示赞赏。 Thank you in advance先感谢您

Relevant links相关链接

oracle erc20 token --> https://songbird-explorer.flare.network/address/0xD7565b16b65376e2Ddb6c71E7971c7185A7Ff3Ff甲骨文 erc20 令牌--> https://songbird-explorer.flare.network/address/0xD7565b16b65376e2Ddb6c71E7971c7185A7Ff3Ff

contract to approve (OracleSwapRouter) --> https://songbird-explorer.flare.network/address/0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4合同批准 (OracleSwapRouter) --> https://songbird-explorer.flare.network/address/0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4

Below are the relevant code snippets下面是相关的代码片段

  const OracleSwapRouterContract = await ethers.getContractAt(OracleSwapRouterAbi.default,
"0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4");

const oracleContract = await ethers.getContractAt(oracleAbi.default,  "0xd7565b16b65376e2ddb6c71e7971c7185a7ff3ff");

 await oracleContract.approve(
      "0x73E93D9657E6f32203f900fe1BD81179a5bf6Ce4",
      oracleBalance
    );

The below code gives me the balance for the account so I know oracleContract is not the problem.下面的代码给了我账户余额,所以我知道 oracleContract 不是问题所在。

  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,
    },

You can add some lines to node_modules/hardhat/internal/core/providers/http.js to debug.您可以将一些行添加到 node_modules/hardhat/internal/core/providers/http.js 进行调试。 After every isErrorResponse check, add: console.log(response) or console.log(jsonRpcResponse).在每个 isErrorResponse 检查之后,添加:console.log(response) 或 console.log(jsonRpcResponse)。

Most likely it's an error inside your contracts or deploy script (or both).这很可能是您的合同或部署脚本(或两者)中的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM