以太坊 — Solidity智能合约

首个智能合约demo

// GreetMeeting.sol
pragma solidity^0.4.19;

contract GreetMeeting{
    string name;
    
    function GreetMeeting(string _name) public{
        name = _name;
    }
    
    function getName() public view returns(string){
        return name;
    }
    
    function setName(string _name) public{
        name = _name;
    }
    
    
}

​

第二个智能合约demo

​// money.sol
pragma solidity^0.4.19;

contract money{
    function getBalance() public view returns(uint){
        //msg.sender
        return address(msg.sender).balance;
    }
}

​

 

你可能感兴趣的:(Ethereum)