Horje
constructor in solidity Code Example
constructor in solidity
contract Will {
    address owner;
    uint fortune;
    bool deceased;
    //constructor is special function that's going to execute
    //when we deploy our solidity 
    //payable is the function that allow send or recieve ethers
    constructor() payable  public {
        owner= msg.sender; // msg.sender represents address that is being called
        fortune=msg.value; //msg.value tells us how much ether is being sent
        deceased=false;
    }
    //create modifier so the only person who can call the contract is the owner
}
constructor syntax in solidity
The constructor is declared by keyword “constructor” with no function 
name, followed by access modifier - public or internal.




26

Related
solidity contract transfer all ether Code Example solidity contract transfer all ether Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10