以太坊系列之十四: solidity特殊函数

简介:  solidity中的特殊函数括号里面有类型和名字的是参数,只有类型是返回值.block.blockhash(uint blockNumber) returns (bytes32): hash of the given block - onlyworks for 256 most recent blocksblock.

 solidity中的特殊函数

括号里面有类型和名字的是参数,只有类型是返回值.

  • block.blockhash(uint blockNumber) returns (bytes32): hash of the given block - only
    works for 256 most recent blocks
  • block.coinbase (address): current block miner’s address
  • block.difficulty (uint): current block difficulty
  • block.gaslimit (uint): current block gaslimit
  • block.number (uint): current block number
  • block.timestamp (uint): current block timestamp
  • msg.data (bytes): complete calldata
  • msg.gas (uint): remaining gas
  • msg.sender (address): sender of the message (current call)
  • msg.value (uint): number of wei sent with the message
  • now (uint): current block timestamp (alias for block.timestamp)
  • tx.gasprice (uint): gas price of the transaction
    6.4. Solidity in Depth 99Solidity Documentation, 0.4.10
  • tx.origin (address): sender of the transaction (full call chain)
  • revert(): abort execution and revert state changes
  • keccak256(...) returns (bytes32): compute the Ethereum-SHA-3 (Keccak-256) hash of the
    (tightly packed) arguments
  • sha3(...) returns (bytes32): an alias to keccak256()
  • sha256(...) returns (bytes32): compute the SHA-256 hash of the (tightly packed) arguments
  • ripemd160(...) returns (bytes20): compute the RIPEMD-160 hash of the (tightly packed) arguments
  • ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address):
    recover address associated with the public key from elliptic curve signature, return zero on error
  • addmod(uint x, uint y, uint k) returns (uint): compute (x + y) % k where the addition is performed with arbitrary precision and does not wrap around at 2**256
  • mulmod(uint x, uint y, uint k) returns (uint): compute (x * y) % k where the multiplication is performed with arbitrary precision and does not wrap around at 2**256
  • this (current contract’s type): the current contract, explicitly convertible to address
  • super: the contract one level higher in the inheritance hierarchy
  • selfdestruct(address recipient): destroy the current contract, sending its funds to the given address
  • .balance (uint256): balance of the Address in Wei
  • .send(uint256 amount) returns (bool): send given amount of Wei to Address, returns false on failure
  • .transfer(uint256 amount): send given amount of Wei to Address, throws on failure
目录
相关文章
|
Go 数据安全/隐私保护
Solidity笔记-合约间的互相调用
Solidity笔记-合约间的互相调用
223 0
|
存储 JavaScript 前端开发
【一步步一起学DApp开发】(三)Solidity语言讲解 | 用Solidity编写智能合约 下
【一步步一起学DApp开发】(三)Solidity语言讲解 | 用Solidity编写智能合约
240 0
|
存储 编译器 区块链
【一步步一起学DApp开发】(三)Solidity语言讲解 | 用Solidity编写智能合约 上
【一步步一起学DApp开发】(三)Solidity语言讲解 | 用Solidity编写智能合约
552 0
|
Web App开发 IDE 区块链
Solidity番外篇(一)Solidity在线or插件使用
Solidity番外篇(一)Solidity在线or插件使用
197 0
Solidity番外篇(一)Solidity在线or插件使用
|
Java 区块链
【智能合约】Solidity 进阶编程 | 注意一下合约中的细节
目录 1. 内置的全局变量 2. 错误处理 3. 访问函数 4. 创建合约 5. 合约继承 6. 修饰器modifier 最后
238 0
【智能合约】Solidity 进阶编程 | 注意一下合约中的细节
|
存储 JavaScript 前端开发
【智能合约】Solidity 基础知识 | 以太坊智能合约编程语言
目录 注意事项 编译器选择 一些说明 1. 变量 1.1 状态变量 1.2 局部变量 2. 数据类型 2.1 值类型 2.1.1 布尔类型(Booleans): 2.1.2 整型(Integers): 2.1.3 定长浮点型(Fixed Point Numbers): 2.1.4 定长字节数组(Fixed-size byte arrays) 2.1.5 有理数和整型常量(Rational and Integer Literals) 2.1.6 枚举(Enums) 2.1.7 函数类型(Function Types) 修饰符 函数定义 函数返回值 构造函数 2.1.8 地址类型(Address)
393 0
【智能合约】Solidity 基础知识 | 以太坊智能合约编程语言
|
存储 安全 程序员
Solidity 文档--第一章:智能合约入门
Solidity 文档--第一章:智能合约入门
343 0
|
数据安全/隐私保护
Solidity 文档--第三章:Solidity 编程实例
Solidity 文档--第三章:Solidity 编程实例
101 0
|
Ubuntu JavaScript 前端开发
Solidity 文档--第二章:安装 Solidity
Solidity 文档--第二章:安装 Solidity
426 0
|
存储 区块链 编译器
以太坊智能合约简介(Solidity)
本文略过了冗杂介绍,直接下沉到代码示例。本文中包含一个存储实例和生成极简单 subcurrency 的实例