zeroxlive

Sep 21

·3 min read

Have you ever tried to code a smart contract that can hold CET?also it can send CET to another!

in this tutorial we will talk about Send, Transfer and Call in solidiy. stay with me 😉

Transferring Methods

Solidity supports several method to sending native coin to another contract/wallet.

You can send native coin to other contracts by

transfer (2300 gas, throws error)send (2300 gas, returns bool)call (forward all gas or set gas, returns bool)

also a contract receiving native coin must have at least one of the functions below

receive() external payablefallback() external payable

receive() is called if msg.data is empty, otherwise fallback() is called.

call in combination with re-entrancy guard is the recommended method to use after December 2019.

Guard against re-entrancy by

making all state changes before calling other contractsusing re-entrancy guard modifiertransfer vs send vs call

transfer:the receiving smart contract should have a fallback function defined or else the transfer call will throw an error.

Keep reading this article on Blockchain-Medium.

Leave a Reply