I've copied the code from here. In the example below, minter's address is kept in the contract:
minter = msg.sender;
In the comments, it's said:
"This is the constructor whose code is run only when the contract is created."
Therefore, minter's address is assigned only once.
Question: When is a contract created?
Is it created when it's called, or when it's deployed (sent to the network)?
pragma solidity ^0.4.0;
contract Coin {
// The keyword "public" makes those variables
// readable from outside.
address public minter;
mapping (address => uint) public balances;
// Events allow light clients to react on
// changes efficiently.
event Sent(address from, address to, uint amount);
// **** This is the constructor whose code is
// run only when the contract is created.
function Coin() {
minter = msg.sender;
}
function mint(address receiver, uint amount) {
if (msg.sender != minter) return;
balances[receiver] += amount;
}
function send(address receiver, uint amount) {
if (balances[msg.sender] < amount) return;
balances[msg.sender] -= amount;
balances[receiver] += amount;
Sent(msg.sender, receiver, amount);
}
}
Also, after the contract is sent to the network, can someone make the contract like:
Coin co=new Coin();
and deploy it to the network? In this case, would co have a different address than the Coin contract?