I must have missed something about deploying contracts, but to be sure:

I'm using Truffle, Does deploying a contract mean it will overwrite the last instance? Since I see that it gets a new address each time I deploy it. But at the same time, calling the contract in the webUI will always go to only one specific contract.

Does this depend on which user I am? Do I have to be the one that deployed it, or at least have access to it? And if so, how do you best define access to a contract in soldity?


3 Answers 3


No, once a contract is deployed it cannot be overwritten.

Your web UI will need to be updated with the address of whichever contract you want to interact with.

Anyone can invoke a contract. A contract function can check msg.sender and return (or throw) immediately if the sender should not have access to the contract. A modifier can help isolate this logic:

modifier onlyowner {
    if (isOwner(msg.sender))

Then a function can be labelled with that modifier, like:

function foo() onlyowner returns (bytes32 r)

See the wallet contract for an example, and how isOwner can be defined.

  • can you explain how Truffle resolves the call to contracts, ie. the method name? How does it determine which address to.. address?
    – TrySpace
    Jun 3, 2016 at 9:13
  • 1
    You might need another question if you need to explain more. Truffle puts data about compiled and deployed contracts under the environment directory: such data has the contract's address and its methods.
    – eth
    Jun 3, 2016 at 9:20

A contract deployed has one address and its content cannot be modified. If you deploy the same contract a second time, it has an another address.

Imagine this case: your contract give a token for each user using it. Users of the first deployed contract and users of the second deployed contract will have different tokens. These two tokens are not compatible.

So, if you deploy a contract and think to change in future, you need to prepare a migration process. Do not forget that contract can use contracts! And many contracts have a kill function to unable them.

You should look for design patterns for ethereum/Dapps like DOUG/Name Registry. http://fr.slideshare.net/mids106/dapp-design-patterns.

  • The dApp design patterns link is dead:-( But here's a video about these interesting design patterns. youtu.be/XkJ8mg-R7C0
    – devdanke
    Feb 9 at 6:58

Re-running the migration will re-deploy it to the blockchain at a new address. It will also overwrite the ABIs inside of /build/contracts/. I accidentally did this while trying my contract on another test network so be careful.

  • This answer was flagged as low-quality because of its length and content. Suggest improving it to answer the question clearly.
    – eth
    Sep 18, 2017 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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