[区块链&DAPP介绍 Day10] Solidity 教学 - units and globally available variables-1

今日来介绍一些单位跟全域变数相关的东西

Ether Units

在任何数字後面加上 weigweiether 就会变成货币单位,预设就是 wei

assert(1 wei == 1);
assert(1 gwei == 1e9);
assert(1 ether == 1e18);

Time Units

在任何数字後面加上 seconds,就会变成时间相关参数,预设是 seconds

1 == 1 seconds
1 minutes == 60 seconds
1 hours == 60 minutes
1 days == 24 hours
1 weeks == 7 days

其余的全域变数

//目前的gas 值
block.gaslimit (uint)
//目前的区块编号
block.number (uint)
//区块难度
block.difficulty (uint)
//区块时间
block.timestamp
//矿工的位址
block.coinbase (address)
//目前chain id
block.chainid (uint)
//剩余的gas
gasleft()
//发送讯息给function的位址
msg.sender (address)
//完整的calldata
msg.data (bytes)
//发送多少以太币
msg.value (uint)
//交易的gas price
tx.gasprice (uint)
//交易发送者的位址
tx.origin (address)

明天再来介绍一些数学函式跟错误处理的相关函式。


<<:  [履历]你要对自己的履历了若指掌

>>:  OpenStack Neutron 介绍 — OVN Plug-in 架构

visual studio 编译 cpython

这是我在win 10用visual studio 来编译cpython的原始码,可以参考[your ...

[Day31] 布署 Angular App 到 GPC VM

呼...这两天稍作休息终於复活了。 到目前为止,我们的 Angular app 还只能在本机自 hi...

第30天 致谢与心得分享

铁人30天,实际在不简单,在这30天的过程,中间一度想要放弃、不知道要写什麽。 能持续产出优质文章的...

[Day-9] R语言 - K - means ++ 实作 ( K - means ++ in R.Studio)

您的订阅是我制作影片的动力 订阅点这里~ 影片程序码 library(naniar) data(ir...

Proxmox VE 安装虚拟机:Windows 10 (二)

前几章中的操作过程中,我们已经可以顺利的将 Windows 10 在虚拟客体机当中安装起来运作,但...