BitGo / eth-multisig-v2

Multi-Sig Wallet v2, supporting original Wallet.sol methods with additional confirmAndExecute improvements to allow for single-transaction signing by multiple owners.
Apache License 2.0
270 stars 99 forks source link

Forwarder Construction #9

Open primozkocevar opened 5 years ago

primozkocevar commented 5 years ago

When Forwarder is constructed by the WalletSimple contract by calling createForwarder() it does not return an address of a newly created Forwarder contract. This error occurs when running on the main chain but everything works when using a local test chain.

acinmavi commented 5 years ago

Same here , I used Ropsten Testnet. If deploy Forwarder only , it works fine , return contract address and forward any coin deposit to this contract address. But if deploy WalletSimple and call createForwarder() , it return an transaction info without contract address. I wonder why WalletSimple has include this function , what purpose of this ?

primozkocevar commented 5 years ago

I actually have a solution for this in my version of the contracts with 2 added global variables. I describe this here: https://medium.com/valus/forwarder-contract-for-ether-and-erc-20-tokens-e257a621889d However, the implemented contract here is also a bit different as it is a bit simpler but you can only add the public variables and it should work. P.S.: If it helps I can also make a merge request with my fork.

cauta commented 5 years ago

if you use createForwarder by WalletSimple. the new forwarder will be displayed in internal transaction

image
nguyennk92 commented 4 years ago

The Forwarder address can actually be calculated in advance, it is basically keccak256 of the contract address and its nonce in hex. The implementation in JS is as follow:

    import * as utils from "ethereumjs-util";

    const nonceContract = await web3.eth.getTransactionCount(contractAddress)
    nonceHex = web3.utils.toHex(nonceContract)
    const rlpEncoded = utils.rlp.encode([contractAddress, nonceHex])
    const forwarderAddr = "0x" + utils.keccak256(rlpEncoded).slice(12).toString('hex')