0

Does someone have a exemple of solidity delegatecall for multiple parameters function?

0

I think you should stick to my example. Delegatecalls cannot return values. Example:

pragma solidity 0.5.10;

contract ContractD {
    address public contract_e_address;

    constructor(address _contract_e_address) public {
        contract_e_address = _contract_e_address;
    }

    function invokeContractE(uint256 _number_1, uint256 _number_2) public { 
        ContractE e = ContractE(contract_e_address);
        e.setN(_number_1, _number_2);
    } 
}

contract ContractE {
    uint256 public number_1;
    uint256 public number_2;

    function setN(uint256 _number_1, uint256 _number_2) public {
        number_1 = _number_1;
        number_2 = _number_2;
    }
}

OR

If ContractE is already running on the blockchain for some time you can call it as interface in the contract you are about to deploy. Example:

pragma solidity 0.5.10;

contract ContractD {
    ContractE e = ContractE(<CONTRACT_E_ADDRESS>);

    function invokeContractE(uint256 _number_1, uint256 _number_2) public { 
        e.setN(_number_1, _number_2);
    } 
}

interface ContractE {
    function setN(uint256 _number_1, uint256 _number_2) external;
}
| improve this answer | |

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.