这篇文章主要介绍“solidity如何获取区块hash中的数字”,在日常操作中,相信很多人在solidity如何获取区块hash中的数字问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”solidity如何获取区块hash中的数字”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
pragma solidity ^0.5.16;
contract SplitHash {
bytes32 public splitHash = 0x864f64ef07a68b2a729b2a67a10b3780ca4f37cf9b8254823f17c5d95621aeee;
bytes1 ee = 0xff;
uint8 public number = uint8(ee);
function get1(bytes32 _hash) public pure returns(uint8) {
for(uint8 i = _hash.length - 1;i >= 0;i--){
uint8 b = uint8(_hash[i]) % 16;
if(b>=0 && b<10) return b;
uint8 c = uint8(_hash[i]) / 16;
if(c>=0 && c<10) return c;
}
}
}
到此,关于“solidity如何获取区块hash中的数字”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注天达云网站,小编会继续努力为大家带来更多实用的文章!