current position:Home>How does a smart contract receive Ethernet?

How does a smart contract receive Ethernet?

2022-02-03 20:51:57 Q & A of Denglian community

How do smart contracts receive ether ? Where can I see... After receiving etheric money ? There are no examples ?




Take the answer 1:

stay Solidity 0.6 Before , You need to implement one in the contract payable The regression function of , Code such as :

contract  Test {    function() external payable {         // some code    }}

stay Solidity 0.6.0 after , A new keyword was used receive To accept ether

contract  Test {    receive() external payable {         // some code    }}

Transfer to the contract only needs to be made in the wallet , Target address: fill in the address of the contract . If you want to program transfer , have access to web3 Interface sendtransaction




copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032051551911.html

Random recommended