send

Invoke a transfer of a specified amount of a given asset from the connected account to another account.

Input Arguments

ParameterDescription

fromAddress: string

Address of the connected account to send the assets from

toAddress: string

Address of the receiver of the assets to be sent

asset: string

Asset script hash to be sent. Accepts asset symbol only for "MainNet"

amount: string

The parsed amount of the asset to be sent

fee?: string

The parsed amount of network fee (in GAS) to include with transaction

broadcastOverride?: boolean

In the case that the dApp would like to be responsible for broadcasting the signed transaction rather than the wallet provider

Success Response

In the case where the "broadcastOverride" input argument is not set, or set to false.

ParameterDescription

txid: string

The transaction ID of the send invocation

nodeURL: string

The node which the transaction was broadcast to. Returned if transaction is broadcast by wallet provider

In the case where the "broadcastOverride" input argument is set to True.

ParameterDescription

txid: string

The transaction ID of the send invocation

signedTx: string

The serialized signed transaction. Only returned if the broadcastOverride input argument was set to True

Error Response

ParameterDescription

type: string

The type of error which has occured

description: string

A description of the error which has occured

data: string

Any raw data associated with the error

Example

Request

neolineN3.send({
    fromAddress: 'NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq',
    toAddress: 'NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq',
    asset: 'GAS',
    amount: '1',
    fee: '0.0001',
    broadcastOverride: false
})
.then(result => {
    console.log('Send transaction success!');
    console.log('Transaction ID: ' + result.txid);
    console.log('RPC node URL: ' + result.nodeURL);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'RPC_ERROR':
            console.log('There was an error when broadcasting this transaction to the network.');
            break;
        case 'MALFORMED_INPUT':
            console.log('The receiver address provided is not valid.');
            break;
        case 'CANCELED':
            console.log('The user has canceled this transaction.');
            break;
        case 'INSUFFICIENT_FUNDS':
            console.log('The user has insufficient funds to execute this transaction.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

Response

{
    txid: '0xd6e4edeb66a75b79bec526d14664017eef9ccee5650c32facb1a4d4fe3640808',
    nodeURL: 'https://neo3-testnet.neoline.vip'
};

最后更新于