0

I want to create a proxy / router contract that stores

  1. addresses of other contracts
  2. function names of other contracts functionality and
  3. accepted parameters in these contracts.
  4. ID for each contract

the proxy contract itself will have an AddContract and RemoveContract that adds these parameters to the registry.

Then I want to be able to use this same contract to proxy calls to other contracts. So if somebody calls a smart contract with ID XYZ, with a function myFunction("Here", "is", 123) it would be routed to the address and function of that defined contract under the same ID.

I would like to be able to add contracts after the original proxy creation too and modify them.

Any ideas on how to go about this?

2
  • The first question is why? After all, a call through a proxy will be more expensive. – Mad Jackal Jan 26 at 11:21
  • Lets say I want to do a DAO. People can create a voting proposal within my deployed contract and then say "Upon a YES Vote execute X contract with Y function and Z parameters" – blockbyblock Jan 26 at 11:30
1

If you want this to be implemented professionally then I suggest to have a look at Augur project, they do all the things you want, they have Factories to instantiate new contracts, and they have proxy functions that do an "exec" of other functions.

This is one example of a call you are looking for:

function executeTransaction(address _to, bytes calldata _data, uint256 _value) external returns (bool) {
    require(authorizedProxies[msg.sender]);
    (bool _didSucceed, bytes memory _resultData) = address(_to).call.value(_value)(_data);
    return _didSucceed;
}

The code is here: https://github.com/AugurProject/augur/blob/942b99fd03a513cc7d304123443979a902b4364c/packages/augur-core/src/contracts/AugurWallet.sol#L68

1
  • Very good answer, exactly what I was looking for. Thank you Nulik! – blockbyblock Jan 26 at 14:52

Your Answer

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

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