错误:用原因字符串恢复' blacklistable:帐户被黑名单'
在我的 Hardhat 测试中,我尝试模拟 USDC 账户,以便将 USDC 转移到测试地址。问题是无论我尝试模拟哪个地址,我总是会收到以下错误:
错误:处理事务时虚拟机异常:已恢复,原因字符串“黑名单:帐户已列入黑名单”
以下是相关代码:有关
it("USDC Test", async function () {
const provider = ethers.provider;
const USDC = new ethers.Contract(addresses.tokens.usdc, abis.ERC20, provider);
// Impersonate USDC whale
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [addresses.whales.usdc],
});
const usdcWhale = await ethers.provider.getSigner(addresses.whales.usdc);
// Approve and transfer USDC to test address
await USDC.connect(usdcWhale).approve(addresses.tokens.usdc, 10000);
await USDC.connect(usdcWhale).transfer(addresses.test.address1, 10000)
});
如何修复此错误的任何想法?我确信我使用的地址实际上并未被列入黑名单,因为他们最近在 etherscan 上转移了 USDC。
In my Hardhat test I'm trying to impersonate a USDC account so I can transfer USDC to a test address. The problem is no matter what address I try to impersonate, I always get the following error:
Error: VM Exception while processing transaction: reverted with reason string 'Blacklistable: account is blacklisted'
Here's the relevant code:
it("USDC Test", async function () {
const provider = ethers.provider;
const USDC = new ethers.Contract(addresses.tokens.usdc, abis.ERC20, provider);
// Impersonate USDC whale
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [addresses.whales.usdc],
});
const usdcWhale = await ethers.provider.getSigner(addresses.whales.usdc);
// Approve and transfer USDC to test address
await USDC.connect(usdcWhale).approve(addresses.tokens.usdc, 10000);
await USDC.connect(usdcWhale).transfer(addresses.test.address1, 10000)
});
Any ideas on how to fix this error? I'm certain the addresses I'm using aren't actually blacklisted considering they recently transferred USDC on etherscan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到自己的错误。这条线导致了错误:
我最初认为我需要批准USDC合同本身来花费我的令牌,但是,如果我只是调用
Transfer()
函数,则不需要。删除此行修复了错误。
I realized my mistake. This line was causing the error:
I originally thought I needed to approve the USDC contract itself to spend my tokens, however it's not needed if I'm just calling the
transfer()
function.Removing this line fixed the error.