0

What happens when there is a minor change in the smart contract and I run truffle migrate command.

Example:

//before
contract test{
    function display() public returns (string){
       return "message";
    }   
 }

//after
contract test{
    uint temp; //new var
    function display() public returns (string){
       return "updated message"; //changed message
    }   
 }

Ideally, it should deploy the smart contract in a different address. However, in the console, it says: Everything is up to date, there is nothing to compile. Also, in ganache, I don't see a contract creation transaction. Although, in the contracts section of ganache, I can see new storage variable "temp". How is it possible if the new contract is not deployed?

0

Yes, your contract was not deployed. To deploy your new contract you have to use truffle migrate --reset. Be aware that the contract is deployed at a new address and the old contract still remains on the blockchain.

To "override" your current contract (in reality it's not overriden) you have to use the Proxy Pattern. OpenZeppelin provides a good explanation of this: https://docs.openzeppelin.com/upgrades/

2
  • Thanks for answering. I just have a question. If the contract is not deployed then how am I able to access new methods that I added? so basically when I am calling the display method "updated message" is returned. – Arpit Bajpai Jun 22 '20 at 13:06
  • You have to redeploy via truffle migrate --reset – rw026 Jun 22 '20 at 13:39

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.