findmeStorage.sol – 查找存储区.sol区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,findmeStorage.sol – 查找存储区.sol区块链毕设代写 是一篇很好的国外资料

findmeStorage.sol

  1. Deploy the contract onto ropsten testnet

  2. Use truffle console --network ropsten

  3. Use web3.eth.getStorageAt("0x79Bbc5f4d3970B529E74134084dB1326Df5De5f6", 0, x => console.log(x)) to query the storage/values.

More about it: https://enderspub.kubertu.com/understand-solidity-storage-in-depth

For deployer: (Example)

Initialize the Private function with a private array of:

[“0x7465737400000000000000000000000000000000000000000000000000000000″,”0x7465737400000000000000000000000000000000000000000000000000000000″,”0x7465737400000000000000000000000000000000000000000000000000000000”]

SaferMoney.sol

//To avoid Re-entrancy in using call.value      function withdraw() external{          uint256 amount = balanceOf[msg.sender];          balanceOf[msg.sender] = 0; // typical safeguard for re-entrancy          (bool success, ) = msg.sender.call.value(amount)("");          require(success, "Transfer failed.");   }   

If msg.sender is a smart contract, it has an opportunity on line 19 to call withdraw() again before line 20 happens. In that second call, balanceOf[msg.sender] is still the original amount, so it will be transferred again. This can be repeated as many times as necessary to drain the smart contract.

NB: you can use https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol

ref: https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/


findmeStorage.sol

  1. Deploy the contract onto ropsten testnet

  2. Use truffle console --network ropsten

  3. Use web3.eth.getStorageAt("0x79Bbc5f4d3970B529E74134084dB1326Df5De5f6", 0, x => console.log(x)) to query the storage/values.

More about it: https://enderspub.kubertu.com/understand-solidity-storage-in-depth

For deployer: (Example)

Initialize the Private function with a private array of:

[“0x7465737400000000000000000000000000000000000000000000000000000000″,”0x7465737400000000000000000000000000000000000000000000000000000000″,”0x7465737400000000000000000000000000000000000000000000000000000000”]

SaferMoney.sol

//To avoid Re-entrancy in using call.value      function withdraw() external{          uint256 amount = balanceOf[msg.sender];          balanceOf[msg.sender] = 0; // typical safeguard for re-entrancy          (bool success, ) = msg.sender.call.value(amount)("");          require(success, "Transfer failed.");   }   

If msg.sender is a smart contract, it has an opportunity on line 19 to call withdraw() again before line 20 happens. In that second call, balanceOf[msg.sender] is still the original amount, so it will be transferred again. This can be repeated as many times as necessary to drain the smart contract.

NB: you can use https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol

ref: https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/

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

www.interchains.cc

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

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

提供最优质的资源集合

立即查看 了解详情