【发布时间】:2022-12-18 14:22:19
【问题描述】:
我正在尝试在 Hardhat 中测试我的智能合约,但为此我首先需要向我的合约发送一些 ERC20 代币(对于此测试,我使用的是 USDC)。
在我的测试中,我模拟了一只 USDC 鲸鱼,但我如何实际将 USDC 转移到我的合约中?
it("USDC test", async function () {
const testContract =
await ethers.getContractFactory("TestContract")
.then(contract => contract.deploy());
await testContract.deployed();
// Impersonate USDC whale
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [USDC_WHALE_ADDRESS],
});
const usdcWhale = await ethers.provider.getSigner(USDC_WHALE_ADDRESS);
// Need to transfer USDC from usdcWhale to testContract
});
【问题讨论】:
标签: ethereum blockchain ethers.js hardhat erc20