基于区块链的毕业设计timelockvault-contracts – timelockvault合同

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计timelockvault-contracts – timelockvault合同 是一篇很好的国外资料

timelockvault-contracts timelockvault-contracts - timelockvault合同

Lock up your ETH for a set duration to force you into saving, while allowing you to bypass the timelock if a group of your trusted friends (keyholders) vote to permit you to bypass in the case of an emergency or unexpected event.

The docs below will teach you how to configure and deploy your own instance of the TimeLockMultiSigVault contract.

Configuration Guide:

  • Rename .env.example to .env
  • Set KEYHOLDER_LIMIT to the number of keyholders you wish to have (ex: 2)
  • Set TIMELOCK_SECONDS to the number of seconds you would like your to deposit to be unwithdrawable (ex: 2628000)
  • Set GWEI_GAS_PRICE to the price of gas in GWEI to deploy your contract with (use the fast price from ethgasstation.info)
  • Set INFURA_KEY to an Infura project ID (more info here)
  • Set ETHERSCAN_API_KEY to an Etherscan API key (get one here)
  • Set PRIVATE_KEY to your private key (more info here)

Deployment Guide:

  • Run npm run deploy-mainnet to deploy to the mainnet & verify the contract on Etherscan automatically (Change mainnet to kovan or ropsten to deploy to those testnets respectively).

Your contract will now start deploying! Get the contract address by copying it from the command output from truffle:

timelockvault-contracts - timelockvault合同

  • Once the transaction has confirmed, it’s time to add your keyholders.

  • Go to etherscan.io/address/YOUR_DELPOYED_CONTRACT_ADDRESS

timelockvault-contracts - timelockvault合同

  • Call the contract’s addKeyholder method with the address of each person you wish to add as keyholder until you’ve reached the KEYHOLDER_LIMIT you set.

You should now be able to send ether to your contract and it will be locked up for the TIMELOCK_SECONDS amount you set!

  • If you want to check to see how much you can withdraw at a certian time call getWithdrawableAmount which will return the max amount you can withdraw at the current time (factoring in the timelock).

  • Once the timelock has expired on any of your deposits you can call withdraw to withdraw all unlocked funds!

  • You can also tell your keyholders to call allowMaxAmountTimelockBypass or allowAmountTimelockBypass(uint256 amount) to allow you to bypass the limit.

    • Once all of your keyholders have called one of those methods, call withdrawMaxWithTimelockBypass or withdrawAmountWithTimelockBypass(uint256 amount) respectively to get withdraw your ETH!

To go beyond the basics and learn all the cool things you or your keyholders can do with this contract, take a look at the contracts yourself under the contracts folder or look at some usage examples in the tests folder!


timelockvault合同timelockvault-contracts - timelockvault合同

在设定的时间内锁定ETH以强制您保存,同时允许您绕过timelock,如果您信任的朋友(keyholder)投票允许您在发生紧急或意外事件时绕过timelock。

下面的文档将教您如何配置和部署自己的TimeLockMultiSigVault合同实例。

配置指南:

  • 重命名。环境示例to.env
  • 将KEYHOLDER_LIMIT设置为您希望拥有的KEYHOLDER数量(例如:2)
  • 将TIMELOCK_SECONDS设置为您希望存款不可提取的秒数(例如:2628000)
  • 将GWEI天然气价格设置为GWEI中部署您的合同的天然气价格(使用快速价格从乙炔站.info)
  • 将INFURA_密钥设置为INFURA项目ID(此处提供更多信息)
  • 将ETHERSCAN_API密钥设置为ETHERSCAN API密钥(请在此处获取)
  • 将私钥设置为私钥(此处提供更多信息)

部署指南:

  • 运行npm Run deploy mainnet以部署到主网&在Etherscan上自动验证契约(将mainnet更改为kovan或ropsten以分别部署到这些测试网)。

您的合同现在将开始部署!从truffle的命令输出中复制合同地址:

timelockvault-contracts - timelockvault合同

  • 交易确认后,是时候添加您的密钥持有人了。
  • 转到etherscan.io/address/您的合同地址

timelockvault-contracts - timelockvault合同

  • 调用合同的addKeyholder方法,使用您希望添加为keyholder的每个人的地址,直到达到您设置的keyholder_限制。

您现在应该能够向合同发送乙醚,并且它将被锁定在您设置的TIMELOCK秒数内!

  • 如果您想查看您在某个时间可以支取多少,请调用GetDrawableAmount,它将返回您在当前时间可以支取的最大金额(考虑timelock)。
  • 一旦您的任何存款的timelock过期,您可以致电“取款”来提取所有未锁定的资金!
  • 您也可以告诉您的密钥持有人调用allowMaxAmountTimelockBypass或AllowMountTimeLockBypass(uint256 amount)来绕过限制。一旦所有的键盘持有者都调用了其中一个方法,分别调用drawMaxWithTimeLockBypass或drawAmountWithTimeLockBypass(uint256 amount)来获取您的ETH!

若要超越基础知识,学习您或您的密钥持有者可以使用此合同执行的所有酷事,请查看“合同”文件夹下的合同或查看“测试”文件夹中的一些使用示例!

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/19377.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计timelockvault-contracts – timelockvault合同

提供最优质的资源集合

立即查看 了解详情