1

In most contracts with ERC20 standard or with a token there is mostly in the beginning a function that defines the owner of the contract/token after the contract is runned for the first time.

Contract Token {   
  function Token {
    owner = msg.sender;   
  }
}

On websites like MyEtherWallet or others I can access contracts and run all functions of a contract.

So my question is following: If the funtion name would be "TokenFunction","TokenX" or others instead of "Token", could it then be ran by anyone and so the owner variable could be changed? And why is that the only function that can be ran only on first time? Or did I understand something wrong? Thank you!

2

All contracts can have what is known as a constructor function - as long as it has exactly the same name as the contract it will run once when the contract is first deployed and can't be called again after that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.