我得到了一个示例,它将Aave令牌存放到Aave中。我正在使用Aave v2 github提供的代码契约示例
// Fork Kovan
await hre.network.provider.request({
method: 'hardhat_reset',
params: [{ forking: { jsonRpcUrl: KOVAN_JSON_RPC } }],
});
// Act like AAVE_HOLDER
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [AAVE_HOLDER],
});
const signer = await hre.ethers.getSigner(AAVE_HOLDER);
console.log('signer:', signer.address);
// AAVE token on Kovan network
const aavetoken = IERC20__factory.connect(AAVE_TOKEN_ADDRESS, signer);
console.log('token balance:', (await aavetoken.balanceOf(signer.address)).toString());
const MyV2CreditDelegation = new MyV2CreditDelegation__factory(signer);
const delegation = await MyV2CreditDelegation.deploy({ gasLimit: 1e7 });
console.log('delegation:', delegation.address);
// Set the allowance higher than the deposit amount
// so we know we can make multiple transactions
let allowance = 100000
let despositAmount = 10;
await aavetoken.approve(delegation.address, allowance);
console.log('allowance:', (await aavetoken.allowance(signer.address, delegation.address, { gasLimit: 1e6 })).toString());
const depositTrans = await delegation.depositCollateral(aavetoken.address, despositAmount, true, { gasLimit: 1e6 });
console.log('depositTrans:', depositTrans.hash);
const depositReceipt = await depositTrans.wait();但是,当我试图取款时,存款工作正常:
try {
var withdrawTrans = await delegation
.withdrawCollateral(aavetoken.address, { gasLimit: 1e6 })
console.log('withdrawTrans:', withdrawTrans.hash);
const withdrawReceipt = await withdrawTrans.wait();
}
catch (err) {
console.log('Error:' + err);
}我收到一个错误:
事务恢复:函数返回了意外数量的数据
我对“硬帽子”非常陌生,现在我知道如何进一步调试它了。我怎么才能退出Aave?
发布于 2021-10-03 08:43:15
我也犯了同样的错误
事务恢复:函数返回了意外数量的数据
当我调用一个返回bytes32的外部契约上的函数,并将返回值分配给一个类型为字节的变量时,就会发生这种情况。
Contract1
function Func1() external returns (bytes memory returnValue) {
returnValue = Contract2(contract2.address).Func2();
}在另一个Contract2上
bytes32 Var = 0x5d73888975b842f81b854bb06846b539e34142cbcd3cc5e5e7ec53bafb8ed151;
function Func2() external returns (bytes32 returnValue) {
return Var(;
}https://ethereum.stackexchange.com/questions/107046
复制相似问题