I have a smart contract. I want to update the contents (list of names) of that contract let's say after every 5 minutes. The names change after this set duration. My approach is to create an instance of that contract(new address) and then write the new set of names. I however feel this is not efficient. Is it possible to update stuff without having to change the address or creating a new instance? Is there a better way to do this?

1 Answer 1


in your contract define a setter :

pragma solidity ^0.4.24;

contract Names {

 string[] names;

 function setname(uint i, string s)public returns(bool){

     return true;

and in your front end let's say using javascript after each 5 minutes you call setname function as follow :

var abi=[//your abi array];
    var contractAddress = "//your contract address";
    var contract = web3.eth.contract(abi).at(contractAddress);
     contract.setname.sendTransaction(3,"Brian",{{from:web3.eth.accounts[0]}},function (error, result){   if(!error){
                        } else{

so you keep the interacting with same contract instance, avoiding you paying more gas for deploying new instance.

  • thanks. this was really helpful. I am fairly new to solidity. Jul 11, 2018 at 13:11

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.