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?

up vote 1 down vote accepted

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. – user3078335 Jul 11 at 13:11

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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