Ether
Ether Units A literal number can take a suffix of wei, finney, szabo or ether to convert between the subdenominations of Ether, where Ether currency numbers without a postfix are assumed to be Wei, e.g. 2 ether == 2000 finney evaluates to true. 引用自here
以下这些单位都是solidity中可以使用的关键词
- ether
- finney
- szabo
- wei
Ether的Demo合约
pragma solidity 0.4.10;
contract demo {
uint public balance;
function demo() {
balance = 1 ether;
}
function addFinney() {
balance += 1 finney;
}
function addSzabo() {
balance += 1 szabo;
}
function addWei() {
balance += 1 wei;
}
}
Time
有以下几种Time类型
- seconds
- minutes
- hours
- days
- weeks
- years
- now
Time的Demo合约
pragma solidity 0.4.10;
contract demo {
uint public a;
function demo() {
// a = now;
a = 10000000000;
}
function addSeconds(uint num) {
a += num;
}
function addMinutes(uint num) {
a += num * 1 minutes;
}
function addHours(uint num) {
a += num * 1 hours;
}
function addDays(uint num) {
a += num * 1 days;
}
function addWeeks(uint num) {
a += num * 1 weeks;
}
function addYears(uint num) {
a += num * 1 years;
}
}
原文:http://www.ethchinese.com/?p=1113
QQ群:559649971 (区块链学堂粉丝群)
个人微信:steven_k_colin
获取最新区块链咨询,请关注《以太中文网》微信公众号:以太中文网