0

I'm currently trying to pass a Smart Contract (which is NOT deployed) in byte code format as an argument to another Smart Contract (which is deployed).

From within the deployed contract I want to run the other contracts byte code and call a function on it.

Here's a quick example which illustrates the idea (I haven't included any byte code just yet to keep it simple):

pragma solidity ^0.4.23;

// The NOT deployed contract

contract NotDeployed {
    function getGreeting(string name) public returns (string) {
        return string(abi.encodePacked("Hello", " ", name));
    }

}
pragma solidity ^0.4.23;

// The deployed contract

contract Deployed {
    string name;

    constructor(string _name) public {
        name = _name;
    }

    // The arguments should be the byte code of the `NotDeployed` contract
    // alongside the function which should be invoked
    function greet(NotDeployed notDeployed) public {
        string greeting = notDeployed.getGreeting(name);
        // ... snip
    }
}

The use case for this invocation model is that I want to deploy one Smart Contract on the blockchain which is capable of invoking other, custom logic which is unknown at deployment time.

E.g. one could write a Smart Contract locally and "inject" it into the deployed contract via Web3 which will then just call the logic of the "local" contract.

I found the following resources which look promising but I'm not entirely sure if the EVM supports this kind of workflow:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.