ethers-io / ethers-ledger

Deprecated; please see `@ethersproject/hardware-wallets` instead
https://github.com/ethers-io/ethers.js/tree/ethers-v5-beta/packages/hardware-wallets
13 stars 11 forks source link

can not send erc20 success #1

Open jason-xie-123 opened 5 years ago

jason-xie-123 commented 5 years ago

`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 commented 4 years ago

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?