Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not send erc20 success #1

Open
jason-xie-123 opened this issue Oct 10, 2018 · 1 comment
Open

can not send erc20 success #1

jason-xie-123 opened this issue Oct 10, 2018 · 1 comment

Comments

@jason-xie-123
Copy link

jason-xie-123 commented Oct 10, 2018

`sendERCToken: function ( signer, fromAddress, toAddress, tokenNode, amount, callback ) {
provider.getGasPrice()
.then( function ( gasPrice ) {
const contract = new ethers.Contract( tokenNode.contract, tokenNode.abi, provider );

            contract.estimate.transfer( toAddress, utils.bigNumberify( 0 ) )
                .then( function ( gasLimit ) {
                    let iFace = new ethers.utils.Interface( tokenNode.abi );

                    let callData = iFace.functions.transfer.encode( [ toAddress, utils.parseUnits( amount, tokenNode.decimals ) ] );

                    provider.getTransactionCount( fromAddress )
                        .then( ( nonce ) => {
                            let transaction = {
                                nonce: utils.bigNumberify( nonce ).toHexString(),
                                gasLimit: gasLimit.toHexString(),
                                gasPrice: gasPrice.toHexString(),
                                to: tokenNode.contract,
                                value: "0x00",
                                data: callData,
                                // This ensures the transaction cannot be replayed on different networks
                                chainId: 1234,
                            };

                            signer.sendTransaction( transaction )
                                .then( ( tx ) => {
                                    callback( null, tx );
                                } )
                                .catch( ( error ) => {
                                    callback( error, null );
                                } );
                        } )
                        .catch( error => {
                            callback( error, null );
                        } );

                } )
                .catch( error => {
                    callback && callback( error, null )
                } );
        } )
        .catch( error => {
            callback( error, null );
        } );
}

`

my code as above, I send success, but the receiver can not receive the amount

@ricmoo
Copy link
Member

ricmoo commented Jan 12, 2020

Sorry, just catching up on the issues now. Please see the new ethers.js repo for the updated version.

I've noticed that the Ledger now has a separate setting you require to set in order to enable ERC-20 transactions. Are you still having this problem?

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

No branches or pull requests

2 participants