zoukankan      html  css  js  c++  java
  • 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.
    
  • 相关阅读:
    系统的访问
    tomcat 和 数据库的连接
    实体类编写规则
    webmagic 爬虫
    docker安装官方Redis镜像并启用密码认证
    解决Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. 问题
    Springboot配置druid报错Failed to bind properties under 'spring.datasource' to javax.sql.DataSource
    阿里云centos7.6搭建SVN远程仓库和Git远程仓库
    java 三大特性封装继承多态
    使用easyui tab需要注意的问题
  • 原文地址:https://www.cnblogs.com/liujitao79/p/8482857.html
Copyright © 2011-2022 走看看