[英]cannot approve contract to ERC-20 token due to ProviderError: HttpProviderError error
OracleSwap 是一個 DEX,它是 Uniswap 的一個分支。
最終目標是我正在嘗試增加流動性https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-01#addliquidity
為此,首先我們需要批准 OracleSwapRouter 合約使用 erc20 代幣。
當我試圖approve
OracleSwapRouter
(EVM 兼容)網絡中的 OracleSwapRouter 以便我可以在農場提供流動性時,我遇到了以下錯誤。 我不確定這是 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)
任何幫助表示贊賞。 先感謝您
相關鏈接
甲骨文 erc20 令牌--> https://songbird-explorer.flare.network/address/0xD7565b16b65376e2Ddb6c71E7971c7185A7Ff3Ff
合同批准 (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
);
下面的代碼給了我賬戶余額,所以我知道 oracleContract 不是問題所在。
const oracleBalance = await oracleContract.balanceOf(SONGBIRD_ACC);
我的安全帽網絡配置
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)。
這很可能是您的合同或部署腳本(或兩者)中的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.