Skip to content

can not send erc20 success #1

@jason-xie-123

Description

@jason-xie-123

`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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions