Solidity 언어 학습 노트 - 5, 전역 변수
3992 단어 【블록체인】————Solidity
abi.encode(...) returns (bytes)
: 주어진 매개 변수를 ABI 인코딩합니다. abi.encodePacked(...) returns (bytes)
: Performes packed encoding of the given arguments abi.encodeWithSelector(bytes4 selector, ...) returns (bytes)
: 주어진 매개 변수를 ABI 인코딩하기 - 두 번째 미리 설정된 4바이트 선택기부터 시작abi.encodeWithSignature(string signature, ...) returns (bytes)
: abi.encodeWithSelector(bytes4(keccak256(signature), ...)
에 해당함block.blockhash(uint blockNumber) returns (bytes32)
: 주어진 블록의hash값은 최근에 작업한 256개 블록의hash값만 0.4.22 이후에 사용하십시오blockhash(uint blockNumber)
. block.coinbase
(address
): 현재 블록의 광부 주소block.difficulty
(uint
: 현재 블록의 난이도block.gaslimit
(uint
: 현재 블록의gaslimitblock.number
uint
: 현재 블록 수block.timestamp
(uint
: 현재 블록의 시간 스탬프gasleft() returns (uint256)
: 남은 가스msg.data
(bytes
): 온전한calldatamsg.gas
(uint
): 남은 가스-0.4.21 후 gasleft()
msg.sender
(address
: 메시지의 발송자(현재 호출)msg.value
(uint
): 메시지와 함께 발송된wei의 수량now
(uint
: 현재 블록의 타임 스탬프(block.timestamp
의 별칭)tx.gasprice
(uint
): 거래의gas가격tx.origin
(address
): 거래의 발송자(전체 호출체인)assert(bool condition)
: abort execution and revert state changes if condition isfalse
(내부 오류용)require(bool condition)
: abort execution and revert state changes if condition isfalse
(입력 오류나 외부 구성 요소에 대한 오류)require(bool condition, string message)
: abort execution and revert state changes if condition isfalse
(입력 오류나 외부 구성 요소에 대한 오류).오류 정보를 제공합니다. revert()
: 상태 변경 실행 중단 및 복원 revert(string message)
: 상태 변경 실행 중지 및 복원, 설명 문자열 제공blockhash(uint blockNumber) returns (bytes32)
: 주어진 블록의hash값, 최근에 작업한 256개 블록의hash값만 있음keccak256(...) returns (bytes32)
: 매개변수의 이더리움-SHA3 해시 값을 계산합니다.sha3(...) returns (bytes32)
: an alias to keccak256
sha256(...) returns (bytes32)
: 매개변수의 SHA256 hash 값 계산ripemd160(...) returns (bytes20)
: RIPEMD 매개변수 계산ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)
: 타원 곡선 서명 키 복구, 오류 시 0 반환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
. Assert that k != 0
starting from version 0.5.0. mulmod(uint x, uint y, uint k) returns (uint)
: compute (x * y) % k
where the multiplication is performed with arbitrary precision and does not wrap around at 2**256
. Assert that k != 0
starting from version 0.5.0. this
(current contract's type): 현재 계약, 주소에서 현식 변환super
: 차원 관계에 있어서의 계약selfdestruct(address recipient)
: 현재 계약을 파기하고 지정된 자금으로 보내기address
suicide(address recipient)
: a deprecated alias to selfdestruct
.balance
(uint256
):address주소의 계좌 잔액(wei단위).send(uint256 amount) returns (bool)
: 일정량의 wei를address 주소로 보내고 만약 실패하면 되돌려줍니다false
. .transfer(uint256 amount)
: 일정량의 wei를address 주소에 보내고 이상이 발생하면 던집니다. 주해
네가 무엇을 하는지 알지 않으면
block.timestamp
, now
에 의존하지 마라.시간 스탬프와 덩어리 해시는 어느 정도 광부들의 영향을 받는다.예를 들어 발굴 지역사회의 나쁜 역할은 선택한 산열에서 카지노 지불 함수를 운행할 수 있다. 만약에 그들이 아무런 돈을 받지 못하면 다른 산열을 다시 시도하기만 하면 된다.
현재 블록의 타임 스탬프는 마지막 블록의 타임 스탬프보다 엄격해야 하지만 유일한 보증은 사양 체인에 있는 두 연속 블록의 타임 스탬프 사이에 있다는 것입니다.
주해
블록체인이 변하기 때문에 블록 해시는 모든 블록에 사용할 수 없습니다.최근 256개의 블록에 대한 해시 값에만 액세스할 수 있으며 다른 모든 블록은 0이 됩니다.