solidity语言7
单位和全局变量
Ether Units: wei, finney, szabo, ether
Time Units:
1 == 1 seconds
1 minutes == 60 seconds
1 hours == 60 minutes
1 days == 24 hours
1 weeks == 7 days
1 years == 365 days
function f(uint start, uint daysAfter) public {
if (now >= start + daysAfter * 1 days) {
// ...
}
}
专用变量和函数
block.blockhash(uint blockNumber) returns (bytes32): hash of the given block - only works for 256 most recent blocks excluding current
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 as seconds since unix epoch
msg.data (bytes): complete calldata
msg.gas (uint): remaining gas
msg.sender (address): sender of the message (current call)
msg.sig (bytes4): first four bytes of the calldata (i.e. function identifier)
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
tx.origin (address): sender of the transaction (full call chain)
错误处理
assert(bool condition): throws if the condition is not met - to be used for internal errors.
require(bool condition): throws if the condition is not met - to be used for errors in inputs or external components.
revert(): abort execution and revert state changes
####数字与加密函数
```bash
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 multiplica-tion is performed with arbitrary precision and does not wrap around at 2**256.
keccak256(...) returns (bytes32): compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
sha256(...) returns (bytes32): compute the SHA-256 hash of the (tightly packed) arguments
sha3(...) returns (bytes32): alias to keccak256
ripemd160(...) returns (bytes20): compute RIPEMD-160 hash of the (tightly packed) arguments
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address):
recover the address associated with the public key from elliptic curve signature or return zero on error (example usage)
地址相关
<address>.balance (uint256): balance of the Address in Wei
<address>.transfer(uint256 amount): send given amount of Wei to Address, throws on failure
<address>.send(uint256 amount) returns (bool): send given amount of Wei to Address, returns false on failure
<address>.call(...) returns (bool): issue low-level CALL, returns false on failure
<address>.callcode(...) returns (bool): issue low-level CALLCODE, returns false on failure
<address>.delegatecall(...) returns (bool): issue low-level DELEGATECALL, returns false on failure
合约相关
this (current contract’s type): the current contract, explicitly convertible to Address
selfdestruct(address recipient): destroy the current contract, sending its funds to the given Address
suicide(address recipient): alias to selfdestruct Furthermore, all functions of the current contract are callable directly including the current function.
solidity语言7的更多相关文章
- 用solidity语言开发代币智能合约
智能合约开发是以太坊编程的核心之一,而代币是区块链应用的关键环节,下面我们来用solidity语言开发一个代币合约的实例,希望对大家有帮助. 以太坊的应用被称为去中心化应用(DApp),DApp的开发 ...
- 第一行代码:以太坊(2)-使用Solidity语言开发和测试智能合约
智能合约是以太坊的核心之一,用户可以利用智能合约实现更灵活的代币以及其他DApp.不过在深入讲解如何开发智能合约之前,需要先介绍一下以太坊中用于开发智能合约的Solidity语言,以及相关的开发和测试 ...
- Solidity语言系列教程
Solidity 是一门面向合约的.为实现智能合约而创建的高级编程语言.这门语言受到了 C++,Python 和 Javascript 语言的影响,设计的目的是能在 以太坊虚拟机(EVM) 上运行. ...
- solidity语言介绍以及开发环境准备
solidity语言介绍以及开发环境准备 Solidity 是一门面向合约的.为实现智能合约而创建的高级编程语言.这门语言受到了 C++,Python 和 Javascript 语言的影响,设计的 ...
- 用C++生成solidity语言描述的buchi自动机的初级经验
我的项目rvtool(https://github.com/Zeraka/rvtool)中增加了生成solidity语言格式的监控器的模块. solidity特殊之处在于,它是运行在以太坊虚拟机环境中 ...
- Solidity语言基础 和 Etherum ERC20合约基础
1. 类型只能从第一次赋值中推断出来,因此以下代码中的循环是无限的, 小. for (var i = 0; i < 2000; i++) { ... } --- Solidity Types ...
- solidity语言
IDE:Atom 插件:autocomplete-solidity 代码自动补齐 linter-solium,linter-solidity代码检查错误 language-ethereum支持 ...
- solidity语言14
库(Libraries) 库类似合约,实现仅在专门地址部署一次,使用EVM的DELEGATECALL的功能重复使用的目的.意思是当库函数被调用后,代码执行在被调用的合约的环境.例如,使用this调用合 ...
- solidity语言13
函数过载 合约内允许定义同名函数,但是输入参数不一致 pragma solidity ^0.4.17; contract A { function f(uint _in) public pure re ...
- solidity语言12
View Functions 函数声明为视图,将无权修改状态 pragma solidity ^0.4.16; contract C { function f(uint a, uint b) publ ...
随机推荐
- Promise个人笔记---【Promise的前世今生】
Promise第一版本 案例是使用Node.js内置的fs模块[就是文件系统模块,负责读写文件.]来模拟异步操作 const fs = require('fs'); function getFileP ...
- rem.js的用法及在浏览器端的适配
首先介绍下自己,我是从后端转前端,对于前端的见识还不深望各位全当一个新手自述....... 随着移动设配的更新换代,市场上涌现了大量的非主流设备分辨率,比如华为手机...... 更新换代快的大前提下自 ...
- Linux-Xshell5
Linux-Xshell5 1.下载 2.安装 3.新建会话(连接) 点击新建 需要知道要连接的 IP, 查看命令 ifconfig 配置 名称可以自己命名,主机写要连接的 IP,其他的不能改 输 ...
- keepalived+lvs简单实现
一,部署实战环节 01,服务架构图: 服务器镜像为centos6.9 02,服务安装: 10.0.0.10: 下载keeplived官方包--> http://www.keepalived. ...
- Ural 1260 Nudnik Photographer
Problem Description If two people were born one after another with one second difference and one of ...
- 简单的 shell 脚本 切分日志
为避免日志过大,需要按天分割日志,定时计划任务脚本如下: /data/shell/backup_yesterday_nginx_log.sh declare logs_path="/data ...
- java使用netty的模型总结
一 由于本人的码云太多太乱了,于是决定一个一个的整合到一个springboot项目里面. 附上自己的github项目地址 https://github.com/247292980/spring-boo ...
- 《Python编程从入门到实践》_第十章_文件和异常
读取整个文件 文件pi_digits.txt #文件pi_digits.txt 3.1415926535 8979323846 2643383279 下面的程序打开并读取整个文件,再将其内容显示到屏幕 ...
- 在浏览器中对访问的网页中的cookie添加和修改
做权限相关的东西,使用到了cookie,关于它的安全性,cookie在浏览器中,通过插件是可以对其进行修改的,如下: 1.FireFox 安装Edit This Cookie 插件,之后点击插件图标即 ...
- 初学Hadoop之中文词频统计
1.安装eclipse 准备 eclipse-dsl-luna-SR2-linux-gtk-x86_64.tar.gz 安装 1.解压文件. 2.创建图标. ln -s /opt/eclipse/ec ...