I find answer how to make upgradable contract here

How to call function from currentVersion with fallback function on web3?

    contract Relay {
    address public currentVersion;
    address public owner;

    function Relay(address initAddr){
        currentVersion = initAddr;
        owner = msg.sender;

    function update(address newAddress){
        if(msg.sender != owner) throw;
        currentVersion = newAddress;

        if(!currentVersion.delegatecall(msg.data)) throw;

2 Answers 2


You can do this with the sendTransaction function, like so:

  from: sendingAccount,
  to: contract.address,
  data: yourData, // optional, if you want to pass data or specify another function to be called by delegateCall you do that here
  gas: requiredGas, // technically optional, but you almost certainly need more than the default 21k gas
  value: value //optional, if you want to pay the contract Ether
  • will contract.address be the address of Relay or the actual contract? Commented Aug 6, 2018 at 10:00
  • And what/how do I write instead of yourData (I want to call a method set() from a contract Contract1. This doesn't seem to work: var addDetails = await Contract1.set(1) var encodedABI = addDetails.encodeABI(); And instead of yourData I wrote encodedABI. Using web3 0.20. Commented Aug 6, 2018 at 10:13

You probably don't need it anymore, but you can retype the Relay address to instance contract:

contract Instance{
   function doSomething(){ ... }

and then if Relay.deployed() is at address 0x12345678, do:

in = Instance.at('0x12345678')
in.then(function(i){ i.doSomething(); })

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.