I have create a contract, deployed it and used. My contract has created 4 blocks as of now. Now i want to change the signature of one of my function. so after doing so i need to re-deploy my contract. After re-deploying my contract will start creating the blocks from number 0 again. How do i make my new contract link to the previous block i have created and continue building on that chain.

For example, I have a contract with below function.

function createStudents(string fname, string year, string hash, uint256 _ipfsHash) public {
Student memory student = Student(fname, year, hash);   
studentInfo(fname, year, hash);


this function is pushing value in public variable Students. After deploying the above contract when i call the function the new value is getting pushed and my transaction data is stored in the block (i am using Ganache). So for example if i have called this function 3 times then each time i call, it will push the value in the variable and stores my transaction in the block. Now after pushing values for 3 times, i want to change the year parameter from string to uint256 for some business reason. So after changing the signature of the function i re-deployed the code. After re-deploy the contract address and ABI is changed so i updated my code. Now when i call the same function it is pushing the values in the same variable but i lost the transactions which i pushed before the re-deployment. So i wanted to know is there any way i can have my old data and create new data on top of that. For example if pushed 2000, 2001, 2002, before re-deploying then i would like to have them and my new push should get on top of that. Since the contract address itself has changed i am not sure if this is even possible. But i am thinking about real time problem where will need to change the functions based on the business logic but then in this case how do you get your old data.

I am new in this technology stack.

thanks for your help.

  • 2
    Contracts don't create blocks. Can you explain a little more on what you are trying to do? Sep 8, 2018 at 9:14
  • Are you using Truffle?
    – lunr
    Sep 8, 2018 at 22:01
  • Hi...i have updated the more information in my query. Please check and thanks a lot for your help.
    – SSS
    Sep 9, 2018 at 5:57

1 Answer 1


If I understood correctly, you are asking how you could save old contract's data in a freshly (re)deployed contract.

The straightforward approach is to copy the data from the old contract into the new. You can either do this by coding functionality for it in the new contract which reads data from the old contract, or then do it outside blockchain - some process which reads data from the old contract and sends the data into the new contract.

The more elegant approach is to code your contracts so that they are upgradeable. This means that some parts of the contracts always stay the same but other parts can be upgraded to support new functionality. You can google for many articles about this, here's one decent one: https://medium.com/cardstack/upgradable-contracts-in-solidity-d5af87f0f913


Your Answer

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

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