首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >事务在试图退出aave时恢复

事务在试图退出aave时恢复
EN

Ethereum用户
提问于 2021-08-13 03:52:05
回答 1查看 1K关注 0票数 1

我得到了一个示例,它将Aave令牌存放到Aave中。我正在使用Aave v2 github提供的代码契约示例

代码语言:javascript
复制
// 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();

但是,当我试图取款时,存款工作正常:

代码语言:javascript
复制
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?

EN

回答 1

Ethereum用户

发布于 2021-10-03 08:43:15

我也犯了同样的错误

事务恢复:函数返回了意外数量的数据

当我调用一个返回bytes32的外部契约上的函数,并将返回值分配给一个类型为字节的变量时,就会发生这种情况。

Contract1

代码语言:javascript
复制
    function Func1() external returns (bytes memory returnValue) {   
        returnValue = Contract2(contract2.address).Func2();
      }

在另一个Contract2

代码语言:javascript
复制
bytes32 Var = 0x5d73888975b842f81b854bb06846b539e34142cbcd3cc5e5e7ec53bafb8ed151;

    function Func2() external returns (bytes32 returnValue) {   
        return Var(;
      }
票数 2
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/107046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档