草庐IT

20221201

全部标签

solidity基础语法与简单案例20221201

1、回退函数    fallback():当调用的函数不存在或者直接向合约发送主币的时候调用fallback函数。    receive():不能接受数据,仅向合约发送主币时触发//SPDX-License-Identifier:MITpragmasolidity^0.8.7;contractFallback{eventLog(stringfunc,addresssender,uintvalue,bytesdata);fallback()externalpayable{emitLog("fallback",msg.sender,msg.value,msg.data);}//receive不接受

solidity基础语法与简单案例20221201

1、回退函数    fallback():当调用的函数不存在或者直接向合约发送主币的时候调用fallback函数。    receive():不能接受数据,仅向合约发送主币时触发//SPDX-License-Identifier:MITpragmasolidity^0.8.7;contractFallback{eventLog(stringfunc,addresssender,uintvalue,bytesdata);fallback()externalpayable{emitLog("fallback",msg.sender,msg.value,msg.data);}//receive不接受