• 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.
    
  • 相关阅读:
    删除功能ThinkPHP
    详解又详解KMP中的next和nextval的算法
    Thinphp ajax搜索框实施搜索提示
    tp3无法select一条数据记录
    一步步学习springcloud之总览(一)
    使用github搭建自己的maven仓库
    Win7 安装7zip后无7zip右键菜单的解决办法
    基于微信的邮箱新邮件推送
    Apache James 使用MySQL存储启动报错Specified key was too long; max key length is 3072 bytes
    错误提示:Error running MainActivity: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled.
  • 原文地址:https://www.cnblogs.com/liujitao79/p/8482857.html
Copyright © 2020-2023  润新知