Solidity 常用方法總結

2021-09-01 00:22:53 字數 1659 閱讀 7730

block.blockhash(uint blocknumber) returns (bytes32):給定塊的雜湊 - 僅適用於256個最近的塊

block.coinbase (address):當前塊礦工的位址

block.difficulty (uint):當前塊難度

block.gaslimit (uint):當前塊gaslimit

block.number (uint):當前塊號

block.timestamp (uint):當前塊的時間戳

msg.data (bytes):完整的calldata

msg.gas (uint): 剩餘gas

msg.sender (address): 訊息的傳送者(當前呼叫)

msg.value (uint): 與訊息一起傳送的數量

now (uint):當前塊時間戳(block.timestamp的別名)

.balance (uint256): 餘額位址在wei

.send(uint256 amount) returns (bool): wei傳送給定量到位址,失敗時返回假

.transfer(uint256 amount): 發給定量的wei先解決,丟擲失敗

tx.gasprice (uint): gas**的交易

tx.origin (address) :交易的傳送者(全呼叫鏈)

assert(bool condition): 如果條件為false,則中止執行並恢復狀態更改(用於內部錯誤)

require(bool condition): 如果條件為false,則中止執行並恢復狀態更改(用於格式錯誤的輸入或外部元件中的錯誤)

revert(): 中止執行並恢復狀態更改

keccak256(…) returns (bytes32):計算(緊密包裝)引數的ethereum-sha-3(keccak-256)雜湊

sha3(…) returns (bytes32):keccak256的別名

sha256(…) returns (bytes32): 計算(緊密包裝)引數的sha-256雜湊

ripemd160(…) returns (bytes20) : 計算(緊密包裝)引數的ripemd-160雜湊值

ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address) : 從橢圓曲線簽名恢復與公鑰相關聯的位址,錯誤返回零

addmod(uint x, uint y, uint k) returns (uint) : 計算(x + y)%k,其中以任意精度執行加法,並且不在2 ** 256周圍

mulmod(uint x, uint y, uint k) returns (uint) : 計算(x * y)%k,其中以任意精度執行乘法,並且不會在2 ** 256周圍

this (current contract』s type) : 目前的合約,明確轉換為位址

super : 較高的繼承層次結構中的合同乙個級別

selfdestruct(address recipient) : 摧毀目前的合約,將資金送到給定位址

suicide(address recipieint) : selfdestruct的別名

solidity細節總結

返回值出現乙個view不知道什麼意思?function getbalance address addr public view returns uint 解釋 函式 function private public internal external modifier pure constant vi...

mysql方法總結 Mysql常用方法總結

ascii str 返回字串str的最左面字元的ascii 值。如果str是空字串,返回0。如果str是null,返回null。ord str 如果字串str最左面字元是乙個多位元組字元,通過以格式 first byte ascii code 256 second byte ascii code 2...

solidity合約呼叫合約方法的方式

1.通過介面的形式 pragma solidity 0.7.0 0.8.0 spdx license identifier mit inte ce irc20 contract attack function despoit public payable tract.withdraw 1 ether...