其他分享
首页 > 其他分享> > solidity-Receive

solidity-Receive

作者:互联网

test

pragma solidity >=0.7.0 <0.9.0;
contract ReceiveTest {

    string public data;

    receive() external payable{
        data = "receive call";
    }

    fallback() external payable{       
        data = "fallback call";
    }

    function getBalance() public view returns(uint){
        return address(this).balance;
    }
    
}

ganache

 

metamask 设置网络

  

设置部署选项为 Injected Web3

    

 

部署

 

标签:solidity,Web3,Receive,metamask,部署,设置,Injected
来源: https://www.cnblogs.com/apenote/p/16354523.html