首页 > TAG信息列表 > Soldity0.8
Soldity0.8-Sending Ether
Sending Ether (transfer, send, call) How to send Ether? You can send Ether to other contracts by transfer (2300 gas, throws error) send (2300 gas, returns bool) call (forward all gas or set gas, returns bool) How to receive Ether? A contract receivingSoldity0.8-Delegatecall
delegatecall is a low level function similar to call. When contract A executes delegatecall to contract B, B's code is executed with contract A's storage, msg.sender and msg.value. // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; // NSoldity0.8-Hashing with Keccak256
keccak256 computes the Keccak-256 hash of the input. Some use cases are: Creating a deterministic unique ID from a input Commit-Reveal scheme Compact cryptographic signature (by signing the hash instead of a larger input) // SPDX-License-Identifier: MISoldity0.8-Constants
Constants are variables that cannot be modified. Their value is hard coded and using constants can save gas cost. // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; contract Constants { // coding convention to uppercase constant variablesSoldity0.8-Inheritance
Solidity supports multiple inheritance. Contracts can inherit other contract by using the is keyword. Function that is going to be overridden by a child contract must be declared as virtual. Function that is going to override a parent function must use thSoldity0.8-Function Selector
When a function is called, the first 4 bytes of calldata specifies which function to call. This 4 bytes is called a function selector. Take for example, this code below. It uses call to execute transfer on a contract at the address addr. addr.call(aSoldity0.8.0-import
You can import local and external files in Solidity. Local Here is our folder structure. ├── Import.sol └── Foo.sol Foo.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; struct Point { uint x; uint y; } error Unauthorized(add