I made a delegatecall to the REP contract to approve my contract to spend tokens on behalf of a user and my transaction is failing for some reason here is my code:
(bool b,) = REPAddress.delegatecall(abi.encodeWithSignature("approve(address, uint256)", this, noShowBondPayment));
require(b, "delegatecall failed");
Am I using delegatecall correctly?
approve, it'll update the approval status in storage of the contract delegatecall'ing. This wont update any state in the REP contract and wont allow you to transfer REP from the caller. Could you elaborate on what you're trying to do and what you're trying to accomplish? – natewelch_ Apr 21 '19 at 17:52delegatecallis that it delegates code execution of the current call frame to whatever address it's calling. So any SSTORE/SLOAD opcodes, and even theADDRESSopcode, operates on the contract that called DELEGATECALL. So if contract A delegatecall's to contract B, the code in contract B operates on the storage of contract A, not on contract B. – natewelch_ Apr 21 '19 at 18:15delegatecalling into an ERC20 from a non ERC20 will likely cause failure since it's operating on a completely different storage layout. – natewelch_ Apr 21 '19 at 18:15