invoke

Invoke allows for the generic execution of smart contracts on behalf of the user. It is reccommended to have a general understanding of the NEO blockchain, and to be able successfully use all other commands listed previously in this document before attempting a generic contract execution.

Input Arguments

Parameter
Description

scriptHash: string

Script hash of the smart contract to invoke

operation: string

Operation on the smart contract to call

Any input arguments for the operation

fee?: string

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

extraSystemFee?: string

This fee will be added to system fee

overrideSystemFee?: string

This fee will override the system fee

broadcastOverride?: boolean

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

Sender and the effective scope of signature

Argument

Parameter
Description

type: 'String' | 'Boolean' | 'Hash160' | 'Hash256' | 'Integer' | 'ByteArray' | 'Array' | 'Address'

The type of the argument with you are using

value: any

String representation of the argument which you are using

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

Parameter
Description

signedTx: string

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

Error Response

Parameter
Description

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.invoke({
    scriptHash: '0x1415ab3b409a95555b77bc4ab6a7d9d7be0eddbd',
    operation: 'transfer',
    args: [
        {
            type: "Address",
            value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
        },
        {
            type: "Address",
            value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
        },
        {
            type: "Integer",
            value: "1",
        },
        {
            type: "Any",
            value: null,
        }
    ],
    fee: '0.0001',
    broadcastOverride: false,
    signers: [
        {
            account: "2cab903ff032ac693f8514581665be534beac39f",
            scopes: 16,
            allowedContracts: ["0x1415ab3b409a95555b77bc4ab6a7d9d7be0eddbd", "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"],
            allowedGroups: []
        }
    ]
})
.then(result => {
    console.log('Invoke 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 'CANCELED':
            console.log('The user has canceled 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'
};

最后更新于