5 关于时间锁的使用问题!

时间锁合约地址: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/TimelockController.sol

部署一个时间锁合约,minDelay为10 之后尝试使用web3js修改minDelay 第一步先调用schedule

// minDelay data
// this.timelock == timelock合约实例
const data = this.timelock.methods.updateDelay(20).encodeABI();
// schedule data
const scheduleData = this.timelock.methods.schedule(this.timelockAddress, 0, data, Web3.utils.asciiToHex("123123123123"), Web3.utils.asciiToHex("201528"), 10).encodeABI();
// 调用合约
const result = await this.conMethod(scheduleData, this.timelockAddress, this.timelockAddress);
console.log(result);

调用成功,并返回收据 10S后查看状态

const d = await this.timelock.methods.hashOperation(this.timelockAddress, 0, data, Web3.utils.asciiToHex("123123123123"), Web3.utils.asciiToHex("201528")).call();
console.log(d);
this.timelock.methods.isOperation(d).call().then(res => { console.log(res) })
this.timelock.methods.isOperationPending(d).call().then(res => { console.log(res) })
this.timelock.methods.isOperationReady(d).call().then(res => { console.log(res) })

此时查看hashOperation有返回16进制的值 isOperation 、isOperationPending 、 isOperationReady方法全部返回true

最后执行execute函数

const data = this.timelock.methods.updateDelay(20).encodeABI();
const cc = this.timelock.methods.execute(this.timelockAddress, 0, data, Web3.utils.asciiToHex("123123123123"), Web3.utils.asciiToHex("201528")).encodeABI();
const aa = await this.conMethod(cc, this.timelockAddress, this.timelockAddress);
console.log(aa);

报错为:TimelockController: missing dependency

请先 登录 后评论

最佳答案 2021-05-24 15:19

报错写了 :TimelockController: missing dependency

依赖的任务还没有执行。

请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,2619 浏览
  • ANYFC 提出于 2021-05-23 23:53

相似问题