(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('
');
(window.slotbydup = window.slotbydup || []).push({
id: "u3646201",
container: s
});
})();
(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('
');
(window.slotbydup = window.slotbydup || []).push({
id: "u3646162",
container: s
});
})();
3.13 全局可用变量
1023 人参与 2018年09月17日 16:15 分类 : 区块链精品文章 评论
有些特殊变量和函数永远存在于全局中。
3.13.1 区块和交易属性
区块和交易属性有如下几项:
·block.blockhash(uint blockNumber)returns(bytes32)。给定区块的哈希值,只支持最近256个区块。
·block.coinbase(address)。当前区块矿工的地址。
·block.difficulty(uint)。当前区块的难度值。
·block.gaslimit(uint)。当前区块的gas上限。它定义了整个区块中的所有交易一起最多可以消耗
多少gas。其目的是使区块的传播和处理时间保持在较低水平,这样才能有足够去中心化的网络。矿工有权利将当前区块的gas上限设置为上一个区块的gas
上限~0.0975%(1/1,024)以内的数值,所以gas上限的结果应当是矿工偏好的中间值。
·block.number(uint)。当前区块的序号。
·block.timestamp(uint)。当前区块的时间戳。
·msg.data(bytes)。完整的调用数据里存储的函数及其实参。
·msg.gas(uint)。当前剩余的gas。
·msg.sender(address)。当前调用发起人的地址。
·msg.sig(bytes4)。调用数据的前四个字节(函数标识符)。
·msg.value(uint)。这个消息所附带的货币量,单位为wei。
·now(uint)。当前区块的时间戳,等同于block.timestamp。
·tx.gasprice(uint)。交易的gas价格。
·tx.origin(address)。交易的发起人(完整的调用链)。
3.13.2 地址类型相关
地址类型相关变量如下:
·<address>.balance(uint256)。地址余额,单位为wei。
·<address>.send(uint256 amount)returns(bool)。发送指定数量的wei到地址,失败时返回false。
3.13.3 合约相关
合约相关变量如下:
·this。当前合约,可显式转换成地址类型。
·selfdestruct(address recipient)。销毁当前合约,把其中的资金发送到指定地址。
来源:我是码农,转载请保留出处和链接!
本文链接:http://www.54manong.com/?id=571
(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('
');
(window.slotbydup = window.slotbydup || []).push({
id: "u3646208",
container: s
});
})();
(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('
');
(window.slotbydup = window.slotbydup || []).push({
id: "u3646147",
container: s
});
})();
window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdPic":"","bdStyle":"0","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
区块链是什么 微信号:qq444848023 QQ号:444848023
加入【我是码农】QQ群:864689844(加群验证:我是码农)
<< 上一篇
下一篇 >>
(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('
');
(window.slotbydup = window.slotbydup || []).push({
id: "u3646186",
container: s
});
})();
(function() {
var s = "_" + Math.random().toString(36).slice(2);
document.write('
');
(window.slotbydup = window.slotbydup || []).push({
id: "u3646175",
container: s
});
})();
jQuery(document).ready(function($){
/* prepend menu icon */
$('#daohangs-around').prepend('
');
/* toggle nav */
$("#caidan-tubiao").on("click", function(){
$("#daohangs").slideToggle();
$(this).toggleClass("active");
});
});
评论专区