Question : constructor in solidity
Answered by : shirshak
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
}
Source : | Last Update : Fri, 04 Mar 22
Question : constructor syntax in solidity
Answered by : sagar-shrestha
The constructor is declared by keyword “constructor” with no function
name, followed by access modifier - public or internal.
Source : | Last Update : Mon, 13 Dec 21