Fund:0.015 ETH / $8.68
Question is solved

3 general Solidity questions

1 month ago

Hi, I am just getting into Solidity and have a few questions that I’ve saved up.
1. What is the default visibility of methods? And fields?
2. Who is the owner of the contract? Always a person who created it?
3. Where does contract balance go upon suicide/kill?


Welcome to the world of Ethereum!

1. Default visibility for functions is public and for fields it is private. I highly recommend play playing around with the remix solidity editor. It assists you while writing your code and will tell you what the default visibility is for each.
2. The owner of the contract can change depending on the contract. Generally it is set so that the address that created the contract is the owner but the owner can change. For example, if I had a function like:
function changeOwner(address newOwner) {
owner = newOwner;
Then the owner of the contract would be whatever address is passed in as “newOwner”.
3. The ETH is returned to the owner upon calling “selfdestruct(owner)”. The term “suicide” has been changed to “selfdestruct”. Be careful if you have any tokens in the contract as they will not be withdrawn by this method, Only ether will.
1 month ago
You can play around in the editor and it will tell you the defaults as you type them out. Remix editor is a good one.
1 month ago

Your question is successfully refund. You will be redirect in few seconds.