Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compare the transfer methods of call, send and transfer

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to conduct call, send and transfer transfer methods and comparison, the editor feels very practical, so share with you to learn, I hope you can learn something after reading this article, say no more, follow the editor to have a look.

Three ways of transferring money 1

two

three

Address.transfer ()

Address.send ()

Address.call.value () .gas ()

Transfer transfer1

two

three

four

five

six

seven

eight

nine

ten

Function transfer (address _ address) public payable {

_ address.transfer (msg.value)

}

Function transfer2 (address _ address) public payable {

_ address.transfer (10 * 10 / 18)

}

Transfer send1

two

three

Function transfer4 (address _ address) public payable {

_ address.send (10 ether)

}

Transfer call1

two

three

Function transfer5 (address _ address) public payable returns (bool) {

Return _ address.call.value (10 ether) ()

}

Comparison and summary 1

two

three

four

five

six

Transfer, similar to send, is a transfer operation.

Transfer makes an error and throws an exception

If an error occurs in send or call, no exception is thrown, but true or false is returned.

Tansfer is more secure than send

Send and call will execute the following code even if the transfer fails.

Be careful to use the call function to transfer money, it is easy to reenter.

The above is how to compare the transfer methods of call, send and transfer. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report