Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Forwarder Construction #9

Open
primozkocevar opened this issue Nov 5, 2018 · 4 comments
Open

Forwarder Construction #9

primozkocevar opened this issue Nov 5, 2018 · 4 comments

Comments

@primozkocevar
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

cauta commented Mar 5, 2019

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

@nguyennk92
Copy link

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')

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants