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 receiving Ether must have at least one of the functions below
- receive() external payable
- fallback() external payable
- receive() is called if msg.data is empty, otherwise fallback() is called.
以下为示例合约:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;
contract ReceiveEther {
/*
Which function is called, fallback() or receive()?
send Ether
|