N3 Beta dAPI documentation

Neo2 dAPI N3 Beta dAPI
menu

Example

If you need to call the N3 dAPI monitoring method, you need to initialize NEOLine after initializing NEOLineN3, please refer to the example on the right.


let neoline;
let neolineN3;

function initDapi() {
    const initCommonDapi = new Promise((resolve, reject) => {
        window.addEventListener('NEOLine.NEO.EVENT.READY', () => {
            neoline = new NEOLine.Init();
            if (neoline) {
                resolve(neoline);
            } else {
                reject('common dAPI method failed to load.');
            }
        });
    });
    const initN3Dapi = new Promise((resolve, reject) => {
        window.addEventListener('NEOLine.N3.EVENT.READY', () => {
            neolineN3 = new NEOLineN3.Init();
            if (neolineN3) {
                resolve(neolineN3);
            } else {
                reject('N3 dAPI method failed to load.');
            }
        });
    });
    initCommonDapi.then(() => {
        console.log('The common dAPI method is loaded.');
        return initN3Dapi;
    }).then(() => {
        console.log('The N3 dAPI method is loaded.');
    }).catch((err) => {
        console.log(err);
    })
};

initDapi();
        

getProvider

Returns information about the dAPI provider, including who this provider is, the version of their dAPI, and the NEP that the interface is compatible with.

Input Arguments

None

Success Response
ParameterDescription
name: stringThe name of the wallet provider
website: stringThe website of the wallet provider
version: stringThe version of the dAPI that the the wallet supports
compatibility: string[]A list of all applicable NEPs which the wallet provider supports
extra: objectThis object can contain any attributes specific to the dapi provider, such as an app theme
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.getProvider()
.then(provider => {
    const {
        name,
        website,
        version,
        compatibility,
        extra
    } = provider;

    console.log('Provider name: ' + name);
    console.log('Provider website: ' + website);
    console.log('Provider dAPI version: ' + version);
    console.log('Provider dAPI compatibility: ' + JSON.stringify(compatibility));
    console.log('Extra provider specific atributes: ' + JSON.stringify(compatibility));
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_DENIED':
            console.log('The user rejected the request to connect with your dApp.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    name: 'Awesome Wallet',
    website: 'https://www.neoline.io/',
    version: '1.0.0',
    compatibility: [],
    extra: {}
}

getBalance

Return balance of a specific asset for the given account.

If the asset is omited from a request to MainNet, all asset and token balances will be returned.

Input Arguments
ParameterDescription
params: iBalanceRequest[]A list of Balance Request Objects, specifying which addresses, and which assets to query

BalanceRequest

ParameterDescription
address: stringAddress to check balance(s)
contracts: string[]contracts is a list of contract hash
Success Response
ParameterDescription
[address: string]: iBalanceResponse[]This key is the actual address of the query eg. "NdJqYNVK99srFABQDLPdrpz2By1RX1sLvr"

BalanceResponse

ParameterDescription
contract: stringcontract of the given hash
symbol: stringSymbol of the given contract
amount: stringDouble Value of the balance represented as a String
/* Example */
neolineN3.getBalance()
.then((results) => {
    Object.keys(results).forEach(address => {
        const balances = results[address];
        balances.forEach(balance => {
            const { contract, symbol, amount } = balance

            console.log('Address: ' + address);
            console.log('contract: ' + contract);
            console.log('Asset symbol: ' + symbol);
            console.log('Amount: ' + amount);
        });
    });
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_DENIED':
            console.log('The user rejected the request to connect with your dApp');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

// output
[
    {
        "symbol": "NEO",
        "amount": "5000000",
        "contract": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"
    },
    {
        "symbol": "GAS",
        "amount": "10063.4476161",
        "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf"
    }
]
    

getStorage

Reads the raw value in smart contract storage.

Input Arguments
ParameterDescription
scriptHash: stringScript hash of the smart contract to invoke a read on
key: stringKey of the storage value to retrieve from the contract
Success Response
ParameterDescription
result: stringThe raw value that's stored in the contract
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.getStorage({
    scriptHash: '006b26dd0d2aa076b11082847a094772450f05af',
    key: 'token0',
})
.then(result => {
    const value = result;
    console.log('Storage value: ' + value.result);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_REFUSED':
            console.log('Connection dApp not connected. Please call the "connect" function.');
            break;
        case 'RPC_ERROR':
            console.log('There was an error when broadcasting this transaction to the network.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    result: 'wYCMqLCTIUiax57E8Zd/O9xN3l8='
}
    

invokeRead

Execute a contract invocation in read-only mode.

Input Arguments
ParameterDescription
scriptHash: stringScript hash of the smart contract to invoke a read on
operation: stringOperation on the smart contract to call
args: iArgument[]Any input arguments for the operation
signers: iSigners[]Sender and the effective scope of signature
Success Response

The wallet will return the direct response from the RPC node.

ParameterDescription
script: stringThe script which was run
state: stringStatus of the executeion
gas_consumed: stringEstimated amount of GAS to be used to execute the invocation. (Up to 10 free per transaction)
stack: iArgument[]An array of response arguments

Argument

ParameterDescription
type: 'String' | 'Boolean' | 'Hash160' | 'Hash256' | 'Integer' | 'ByteArray' | 'Array' | 'Address'The type of the argument with you are using. The type is an array, please see the example for the value.
value: stringString representation of the argument which you are using

Signer

ParameterDescription
account: stringscriptHash of the address
scopes: numberiEffective range of the signature
allowedContracts?: ArrayContracts of the signature can take effect, if scopes is CustomContracts
allowedGroups?: ArrayPubkeys of the signature can take effect, if scopes is CustomGroups
rules?: iWitnessRule[]Custom rules for witness to adhere by, if scopes is WitnessRules

Scopes

FieldDescription
0Only transactions are signed and no contracts are allowed to use this signature.
1It only applies to the chain call entry. That is, if the user invokes contract A, and then contract A calls contract B, only contract A can use the signature. It is recommended as the default value for the wallet.
16Custom contract. The signature can be used in the specified contract. It can be used in conjunction with CalledByEntry.
32Custom contract groups that can be used in a specified contract group. It can be used in conjunction with CalledByEntry.
64Indicates that the current context must satisfy the specified rules.
128Global. The risk is extremely high because the contract may transfer all assets in the address. Only choose it when the contract is extremely trusted.

WitnessRule

ParameterDescription
action: 'Deny' | 'Allow'Represents the action of a WitnessRule.
condition: WitnessConditioniRepresents the condition of a WitnessRule.

WitnessCondition

FieldDescription
BooleanWitnessConditioniIndicates that the condition will always be met or not met.
AndWitnessConditioniIndicates that all conditions must be met.
NotWitnessConditioniReverse another condition.
OrWitnessConditioniIndicates that any of the conditions meets.
ScriptHashWitnessConditioniIndicates that the condition is met when the current context has the specified script hash.
GroupWitnessConditioniIndicates that the condition is met when the current context has the specified group.
CalledByEntryWitnessConditioniIndicates that the condition is met when the current context is the entry point or is called by the entry point.
CalledByContractWitnessConditioniIndicates that the condition is met when the current context is called by the specified contract.
CalledByGroupWitnessConditioniIndicates that the condition is met when the current context is called by the specified group.

BooleanWitnessCondition

ParameterDescription
type: 'Boolean'The type of the BooleanWitnessCondition.
expression: booleanThe expression of the BooleanWitnessCondition.

AndWitnessCondition

ParameterDescription
type: 'And'The type of the AndWitnessCondition.
expressions: iWitnessCondition[]The expressions of the AndWitnessCondition.

NotWitnessCondition

ParameterDescription
type: 'Not'The type of the NotWitnessCondition.
expression: WitnessConditioniThe expression of the NotWitnessCondition.

OrWitnessCondition

ParameterDescription
type: 'Or'The type of the OrWitnessCondition.
expressions: iWitnessCondition[]The expressions of the OrWitnessCondition.

ScriptHashWitnessCondition

ParameterDescription
type: 'ScriptHash'The type of the ScriptHashWitnessCondition.
hash: stringThe hash of the ScriptHashWitnessCondition.

GroupWitnessCondition

ParameterDescription
type: 'Group'The type of the GroupWitnessCondition.
group: stringThe group of the GroupWitnessCondition.

CalledByEntryWitnessCondition

ParameterDescription
type: 'CalledByEntry'The type of the CalledByEntryWitnessCondition.

CalledByContractWitnessCondition

ParameterDescription
type: 'CalledByContract'The type of the CalledByContractWitnessCondition.
hash: stringThe hash of the CalledByContractWitnessCondition.

CalledByGroupWitnessCondition

ParameterDescription
type: 'CalledByGroup'The type of the CalledByGroupWitnessCondition.
group: stringThe group of the CalledByGroupWitnessCondition.
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.invokeRead({
    scriptHash: 'd2a4cff31913016155e38e474a2c06d08be276cf',
    operation: 'transfer',
    args: [
        {
            "type": "Hash160",
            "value": "0xebae4ab3f21765e5f604dfdd590fdf142cfb89fa"
        },
        {
            "type": "Hash160",
            "value": "0xebae4ab3f21765e5f604dfdd590fdf142cfb89fa"
        },
        {
            "type": "Integer",
            "value": "10000"
        },
        {
            "type": "String",
            "value": ""
        }
    ],
    signers: [
        {
            account: "2cab903ff032ac693f8514581665be534beac39f",
            scopes: 1
        }
    ],
})
.then(result => {
  console.log('Read invocation result: ' + JSON.stringify(result));
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'NO_PROVIDER':
        console.log('No provider available.');
        break;
    case 'CONNECTION_REFUSED':
        console.log('Connection dApp not connected. Please call the "connect" function.');
        break;
    case 'RPC_ERROR':
        console.log('There was an error when broadcasting this transaction to the network.');
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
    script: "DAABECcMFPqJ+ywU3w9Z3d8E9uVlF/KzSq7rDBT6ifssFN8PWd3fBPblZRfys0qu6xTAHwwIdHJhbnNmZXIMFM924ovQBixKR47jVWEBExnzz6TSQWJ9W1I=",
    state:"HALT",
    stack:[
        {
            type:"Boolean",
            value:false
        }
    ]
}
/* Example, Type is array */
args: [
        {
            type: "Array",
            value: [
              {
                type: "String",
                value: "0x576f726c64"
              }, {
                type: "String",
                value: "0x576f726c64"
              }
            ]
        }
    ]
    

invokeReadMulti

Execute a contract invocation in read-only mode.

Input Arguments
ParameterDescription
scriptHash: stringScript hash of the smart contract to invoke a read on
operation: stringOperation on the smart contract to call
invokeReadArgs: iArgument[]Any input arguments for the operation
Success Response

The wallet will return the direct response from the RPC node.

ParameterDescription
script: stringThe script which was run
state: stringStatus of the executeion
gas_consumed: stringEstimated amount of GAS to be used to execute the invocation. (Up to 10 free per transaction)
stack: iArgument[]An array of response arguments

Argument

ParameterDescription
type: 'String' | 'Boolean' | 'Hash160' | 'Hash256' | 'Integer' | 'ByteArray' | 'Array' | 'Address'The type of the argument with you are using
value: stringString representation of the argument which you are using
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.invokeReadMulti({
    invokeReadArgs: [
        {
            scriptHash: "d2a4cff31913016155e38e474a2c06d08be276cf",
            operation: "balanceOf",
            args: [
                {
                    type: "Address",
                    value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
                }
            ]
        },
        {
            scriptHash: "d2a4cff31913016155e38e474a2c06d08be276cf",
            operation: "balanceOf",
            args: [
                {
                    type: "Address",
                    value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
                }
            ]
        }
    ],
    signers: [
        {
            account: "2cab903ff032ac693f8514581665be534beac39f",
            scopes: 1
        }
    ]
}).then(result => {
    console.log('Read invocation result: ' + JSON.stringify(result));
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'NO_PROVIDER':
        console.log('No provider available.');
        break;
    case 'CONNECTION_REFUSED':
        console.log('Connection dApp not connected. Please call the "connect" function.');
        break;
    case 'RPC_ERROR':
        console.log('There was an error when broadcasting this transaction to the network.');
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
[
    {
        "script": "DBRHsV1d1v6Pnc51X7CYvP4eBbMIAxHAHwwJYmFsYW5jZU9mDBTPduKL0AYsSkeO41VhARMZ88+k0kFifVtS",
        "state": "HALT",
        "stack": [
            {
                "type": "Integer",
                "value": "5293314113"
            }
        ]
    },
    {
        "script": "DBRHsV1d1v6Pnc51X7CYvP4eBbMIAxHAHwwJYmFsYW5jZU9mDBTPduKL0AYsSkeO41VhARMZ88+k0kFifVtS",
        "state": "HALT",
        "stack": [
            {
                "type": "Integer",
                "value": "5293314113"
            }
        ]
    }
]
    

verifyMessage Testbed

Returns whether the provided signature data matches the provided message and was signed by the account of the provided public key. For the complete verification process, please go to Testbed.

Input Arguments
ParameterDescription
message: stringSalt prefix + original message
data: stringSigned message
publicKey: stringPublic key of account that signed message
Success Response
ParameterDescription
result: booleanWhether the provided signature matches the provided message and public key
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.verifyMessage({
  message: '42e038cec78bed9f1e503c4b23254b23Hello world',
  data: 'be506bf7e6851960bfe45968bf5dbbf79a9dc5dc63ee5b88629acfb288c435649c2766e977d4bc76253d8590bb3ca3d9b70efd71d6f7eebdf060dfa58c6601fd',
  publicKey: '03ba9524bd7479414be713c3a4f6f3ef35f90bb4b08f0f552211bf734c24415230'
})
.then(result => {
  console.log('Signature data matches provided message and public key: ' + JSON.stringify(result));
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'NO_PROVIDER':
        console.log('No provider available.');
        break;
    case 'CONNECTION_DENIED':
        console.log('The user rejected the request to connect with your dApp');
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  result: true
}
    

verifyMessageV2 Testbed

Returns whether the provided signature data matches the provided message and was signed by the account of the provided public key. For the complete verification process, please go to Testbed.

Input Arguments
ParameterDescription
message: stringSalt prefix + original message
data: stringSigned message
publicKey: stringPublic key of account that signed message
Success Response
ParameterDescription
result: booleanWhether the provided signature matches the provided message and public key
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.verifyMessageV2({
  message: '543e66d70a56506f0a69aff35f25f794Hello world',
  data: '4fef4abd1ced91577c89eac7909b89ec2aa3d073178c51c3074b7bc5551093b00bf274f35f8166931dc90cbd88346729e86e0bf1c3014fa3587cc167f0cafd4c',
  publicKey: '023e72b8b5a20c00dac7ac01ecd72354a2d7d64620d6615524bb18b9f5a6ca8ef4'
})
.then(result => {
  console.log('Signature data matches provided message and public key: ' + JSON.stringify(result));
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'NO_PROVIDER':
        console.log('No provider available.');
        break;
    case 'CONNECTION_DENIED':
        console.log('The user rejected the request to connect with your dApp');
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  result: true
}
    

getBlock

Get information about a specific block.

Input Arguments
ParameterDescription
blockHeight: numberThe height of the block you would like to get information about
Success Response

The wallet will return the direct response from the RPC node.

Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.getBlock({
    blockHeight: 190,
})
.then(result => {
    console.log('Block information: ' + JSON.stringify(result));
})
.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;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    "hash": "0x70635ef3ab897294bcde97255ea1197f99d7d6c587f720430b78743d25f8b313",
    "size": 689,
    "version": 0,
    "previousblockhash": "0xb2462644577fdc9302abfe3517d07cbb9e7d51354872257901ba3ab1c2f4ead6",
    "merkleroot": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "time": 1616899442433,
    "index": 190,
    "primary": 6,
    "nextconsensus": "NNjNWMEgRw9bnvg7RkjSB9FZfzXUXfqovh",
    "witnesses": [
        {
            "invocation": "DEAl4+T5RivIUYtCcMDCw/W2G3VvNRWRD8iWv447hmeuUo1XxyqHvC9wFYWWu1ar2Qr6sO36mHlJI6W1lmTol7sSDEDZmjj1k/TGr2f4Ii3IUZyxzroJ6/6pBBZhgafUYFPX1zMJBXYPqpGP7Ppqw8n/jUOgYq7u0XAzzbCco7qT4/1mDECVyDVhe2EwxXpvp9bUGgVH9SOoXub7fsN7zB+7kiEXpSNU0Fp7kn4uIsLE8PlDfEyKktFAMPBEzw1+WJZr/MgmDEB0RS82LHuKwwHmQ24QuRfk6YuFs3bLXFdtvL0BrlwpYrtOEDr6hitybvJ6X2NBiRf5+O88MO/ph3KJwIc7deN4DEDOdD1Ks34NSPHqd/7tNt/kqjIokEkRfxSCoXoBdbuSwQBQr5G6q/a9MpE9WQ+td0+XCsOKPi82QzxXo/TLJnoJ",
            "verification": "FQwhAwCbdUDhDyVi5f2PrJ6uwlFmpYsm5BI0j/WoaSe/rCKiDCECPpsy6om5TQZuZJsST9UOOW7pE2no4qauGxHBcNAiJW0MIQNAjc1BY5b2R4OsWH6h4Vk8V9n+qIDIpqGSDpKiWUd4BgwhAqeDS+mzLimB0VfLW706y0LP0R6lw7ECJNekTpjFkQ8bDCECuixw9ZlvNXpDGYcFhZ+uLP6hPhFyligAdys9WIqdSr0MIQPOExCxK5ItwD/pBcxnN+YrOEwO+j8VZouFPQPAFoJb8AwhAuhZNE7zW7H/65wlUytAKMW4d9uGGtsIYcng7dPIxnyLF0F7zmyl"
        }
    ],
    "tx": [],
    "confirmations": 207480,
    "nextblockhash": "0xb95e56772d16a02f54c9f9cf071bdb60c92d4b6dc0f0eddd7c8388d5649f112b"
}
    

getTransaction

Get information about a specific transaction.

Input Arguments
ParameterDescription
txid: stringThe id of the transaction you would like to get information about
Success Response

The wallet will return the direct response from the RPC node.

Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.getTransaction({
    txid: '0xe5a5fdacad0ba4e8d34d2fa0638357adb0f05e7fc902ec150739616320870f50'
})
.then(result => {
    console.log('Transaction details: ' + JSON.stringify(result));
})
.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;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    "hash": "0xc156988547570d1c852d9a56324b2e09d89077ff0aee2070d0b470332ae1e083",
    "size": 244,
    "sys_fee": "0.0997775",
    "net_fee": "0.0124379",
    "block_index": 103879,
    "block_time": 1618238381713,
    "version": 0,
    "transfers": [
        {
            "hash": "0xc156988547570d1c852d9a56324b2e09d89077ff0aee2070d0b470332ae1e083",
            "src": "tx",
            "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
            "from": "",
            "to": "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
            "amount": "0.00004914"
        },
        {
            "hash": "0xc156988547570d1c852d9a56324b2e09d89077ff0aee2070d0b470332ae1e083",
            "src": "tx",
            "contract": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
            "from": "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
            "to": "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
            "amount": "1"
        }
    ]
}
  

getApplicationLog

Get the application log for a given transaction.

Input Arguments
ParameterDescription
txid: stringThe id of the transaction you would like to get the application logs for
Success Response

The wallet will return the direct response from the RPC node.

Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.getApplicationLog({
    txid: '0xe5a5fdacad0ba4e8d34d2fa0638357adb0f05e7fc902ec150739616320870f50',
})
.then(result => {
    console.log('Application log of transaction execution: ' + JSON.stringify(result));
})
.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;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    "blockhash": "0xa8184d1fb08199ca8926f992b6253962c4a8047f7d4cfc5ac420e346fa761b03",
    "executions": [
        {
            "trigger": "OnPersist",
            "vmstate": "HALT",
            "gasconsumed": "0",
            "stack": [],
            "notifications": []
        },
        {
            "trigger": "PostPersist",
            "vmstate": "HALT",
            "gasconsumed": "0",
            "stack": [],
            "notifications": [
                {
                    "contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
                    "eventname": "Transfer",
                    "state": {
                        "type": "Array",
                        "value": [
                            {
                                "type": "Any"
                            },
                            {
                                "type": "ByteString",
                                "value": "iQwOXsDt//2me0sNlRpUdBcVOg4="
                            },
                            {
                                "type": "Integer",
                                "value": "50000000"
                            }
                        ]
                    }
                }
            ]
        }
    ]
}
      

pickAddress

Returns the NEO N3 account selected by the user.

Input Arguments

None

Success Response
ParameterDescription
label: stringA label the users has set to identify their wallet
address: stringThe NEO N3 account address selected by the user
/* Example */
neolineN3.pickAddress()
.then(result => {
    const { label, address } = result;
    console.log('label:' + label);
    console.log('address' + address);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CANCELED':
            console.log('The user cancels, or refuses the dapps request');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    label: 'N3-Name',
    address: 'NfuwpaQ1A2xaeVbxWe8FRtaRgaMa8yF3YM'
}
      

AddressToScriptHash

Converts an address to scripthash.

Input Arguments
ParameterDescription
address: stringN3 account address.
Success Response
ParameterDescription
scriptHash: stringSctiptHash is the script hash of the N3 account.
/* Example */
neolineN3.AddressToScriptHash({ address: 'NQUN2zkzwpypEi6kvGYexy8cQKN2ycyJjF' })
.then(result => {
    const { scriptHash } = result;
    console.log('scriptHash' + scriptHash);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'MALFORMED_INPUT':
            console.log('Please check your input');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    scriptHash: 'f0a33d62f32528c25e68951286f238ad24e30032'
}
      

ScriptHashToAddress

Converts a scripthash to address.

Input Arguments
ParameterDescription
scriptHash: stringSctiptHash is the script hash of the N3 account.
Success Response
ParameterDescription
address: stringN3 account address.
/* Example */
neolineN3.ScriptHashToAddress({ scriptHash: 'f0a33d62f32528c25e68951286f238ad24e30032' })
.then(result => {
    const { address } = result;
    console.log('address' + address);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'MALFORMED_INPUT':
            console.log('Please check your input');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    address: 'NQUN2zkzwpypEi6kvGYexy8cQKN2ycyJjF'
}
      

send

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

Input Arguments
ParameterDescription
fromAddress: stringAddress of the connected account to send the assets from
toAddress: stringAddress of the receiver of the assets to be sent
asset: stringAsset script hash to be sent. Accepts asset symbol only for "MainNet"
amount: stringThe parsed amount of the asset to be sent
fee?: stringThe parsed amount of network fee (in GAS) to include with transaction
broadcastOverride?: booleanIn 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: stringThe transaction ID of the send invocation
nodeURL: stringThe 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: stringThe transaction ID of the send invocation
signedTx: stringThe serialized signed transaction. Only returned if the broadcastOverride input argument was set to True
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
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;
    }
});

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

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
ParameterDescription
scriptHash: stringScript hash of the smart contract to invoke
operation: stringOperation on the smart contract to call
args: iArgument[]Any input arguments for the operation
fee?: stringThe parsed amount of network fee (in GAS) to include with transaction
extraSystemFee?: stringThis fee will be added to system fee
overrideSystemFee?: stringThis fee will override the system fee
broadcastOverride?: booleanIn the case that the dApp would like to be responsible for broadcasting the signed transaction rather than the wallet provider
signers: iSigners[]Sender and the effective scope of signature

Argument

ParameterDescription
type: 'String' | 'Boolean' | 'Hash160' | 'Hash256' | 'Integer' | 'ByteArray' | 'Array' | 'Address'The type of the argument with you are using
value: anyString representation of the argument which you are using

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

ParameterDescription
signedTx: stringThe serialized signed transaction. Only returned if the broadcastOverride input argument was set to True
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
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;
    }
});

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

invokeMultiple

Invoke Multiple functions the same as Invoke, but accepts inputs to execute multiple invokes in the same transaction.

Input Arguments
ParameterDescription
fee?: stringIf a fee is specified then the wallet SHOULD NOT override it, if a fee is not specified the wallet SHOULD allow the user to attach an optional fee
extraSystemFee?: stringThis fee will be added to system fee
overrideSystemFee?: stringThis fee will override the system fee
invokeArgs?: iInvokeArguments[]Array of contract invoke inputs
broadcastOverride?: booleanIf this flag is set to True, the wallet provider will return the signed transaction rather than broadcasting to a node.
signers: iSigners[]Sender and the effective scope of signature

InvokeArguments

ParameterDescription
scriptHash: stringThe script hash of the contract that you wish to invoke
operation: stringThe operation on the smart contract that you wish to call. This can be fetched from the contract ABI
args: iArgument[]A list of arguments necessary to perform on the operation you wish to call

Argument

ParameterDescription
type: 'String' | 'Boolean' | 'Hash160' | 'Hash256' | 'Integer' | 'ByteArray' | 'Array' | 'Address'The type of the argument with you are using
value: anyString representation of the argument which you are using
Success Response

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

ParameterDescription
txid: stringThe transaction ID of the invocation
nodeURL: stringThe 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
signedTx: stringThe serialized signed transaction. Only returned if the broadcastOverride input argument was set to True
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.invokeMultiple({
    invokeArgs: [
        {
            scriptHash: "ef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
            operation: "transfer",
            args: [
                {
                    type: "Address",
                    value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
                },
                {
                    type: "Address",
                    value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
                },
                {
                    type: "Integer",
                    value: "1",
                },
                {
                    type: "Any",
                    value: null
                }
            ]
        },
        {
            scriptHash: "ef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
            operation: "transfer",
            args: [
                {
                    type: "Address",
                    value: "NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq",
                },
                {
                    type: "Address",
                    value: "NPsCvedTnzGcwSYuoxjh7Sec5Zem2vgVmX",
                },
                {
                    type: "Integer",
                    value: "1",
                },
                {
                    type: "Any",
                    value: null
                }
            ]
        }
    ],
    fee: '0.001',
    broadcastOverride: true,
    signers: [
        {
            account: "2cab903ff032ac693f8514581665be534beac39f",
            scopes: 1
        }
    ]
})
.then(({txid, nodeURL}: InvokeOutput) => {
    console.log('Invoke transaction success!');
    console.log('Transaction ID: ' + txid);
    console.log('RPC node URL: ' + 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;
    }
});

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

signMessage Testbed

Signs a provided messaged with an account selected by user. A randomized salt prefix is added to the input string before it is signed, and the specific string 010001f0 0000 is added to the hexString before signed. For the complete signing process, please go to Testbed.

Input Arguments
ParameterDescription
message: stringThe message to sign
isJsonObject?: booleanWhether message is a json object
Success Response
ParameterDescription
publicKey: stringPublic key of account that signed message
data: stringOriginal message signed
salt: stringSalt added to original message as prefix, before signing
message: stringSigned message
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.signMessage({
  message: 'Hello world'
})
.then(signedMessage => {
  const {
    publicKey,
    message,
    salt,
    data
  } = signedMessage;

  console.log('Public key used to sign:', publicKey);
  console.log('Original message:', message);
  console.log('Salt added to message:', salt);
  console.log('Signed data:', data);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'UNKNOWN_ERROR':
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  publicKey: '"03ba9524bd7479414be713c3a4f6f3ef35f90bb4b08f0f552211bf734c24415230"',
  data: '"be506bf7e6851960bfe45968bf5dbbf79a9dc5dc63ee5b88629acfb288c435649c2766e977d4bc76253d8590bb3ca3d9b70efd71d6f7eebdf060dfa58c6601fd"',
  salt: '',
  message: 'Hello world'
}
      

signMessageV2 Testbed

Signs a provided messaged with an account selected by user. A randomized salt prefix is added to the input string before it is signed, and it is encased in a non-executable transaction before signed. This ensures compatibility with Ledger devices. For the complete signing process, please go to Testbed.

Input Arguments
ParameterDescription
message: stringThe message to sign
isJsonObject?: booleanWhether message is a json object
Success Response
ParameterDescription
publicKey: stringPublic key of account that signed message
data: stringOriginal message signed
salt: stringSalt added to original message as prefix, before signing
message: stringSigned message
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.signMessageV2({
  message: 'Hello world'
})
.then(signedMessage => {
  const {
    publicKey,
    message,
    salt,
    data
  } = signedMessage;

  console.log('Public key used to sign:', publicKey);
  console.log('Original message:', message);
  console.log('Salt added to message:', salt);
  console.log('Signed data:', data);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'UNKNOWN_ERROR':
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  publicKey: '023e72b8b5a20c00dac7ac01ecd72354a2d7d64620d6615524bb18b9f5a6ca8ef4',
  data: '4fef4abd1ced91577c89eac7909b89ec2aa3d073178c51c3074b7bc5551093b00bf274f35f8166931dc90cbd88346729e86e0bf1c3014fa3587cc167f0cafd4c',
  salt: '543e66d70a56506f0a69aff35f25f794',
  message: 'Hello world'
}
      

signMessageWithoutSalt Testbed

Signs a provided messaged with an account selected by user. The specific string 010001f0 0000 is added to the hexString before signed. For the complete signing process, please go to Testbed.

Input Arguments
ParameterDescription
message: stringThe message to sign
isJsonObject?: booleanWhether message is a json object
Success Response
ParameterDescription
publicKey: stringPublic key of account that signed message
data: stringOriginal message signed
message: stringSigned message
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.signMessageWithoutSalt({
  message: 'Hello world'
})
.then(signedMessage => {
  const {
    publicKey,
    message,
    data
  } = signedMessage;

  console.log('Public key used to sign:', publicKey);
  console.log('Original message:', message);
  console.log('Signed data:', data);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'UNKNOWN_ERROR':
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  publicKey: '"02f9667a14b62a551f25a1b1ec4562e1c963ec6334d1ef5e088f3b5febddf4e648"',
  data: '"81bab889bb63fa1225cf4dd98f32e89575908b2510377f58c89bf84f4a71c5a6e8ee7a81f857ad9ee4fb30f1c7a97a2a33a597460186c3a854ec2c7f8b8901b0"',
  message: 'Hello world'
}
      

signMessageWithoutSaltV2 Testbed

Signs a provided messaged with an account selected by user. It is encased in a non-executable transaction before signed. This ensures compatibility with Ledger devices. For the complete signing process, please go to Testbed.

Input Arguments
ParameterDescription
message: stringThe message to sign
isJsonObject?: booleanWhether message is a json object
Success Response
ParameterDescription
publicKey: stringPublic key of account that signed message
data: stringOriginal message signed
message: stringSigned message
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.signMessageWithoutSaltV2({
  message: 'Hello world'
})
.then(signedMessage => {
  const {
    publicKey,
    message,
    data
  } = signedMessage;

  console.log('Public key used to sign:', publicKey);
  console.log('Original message:', message);
  console.log('Signed data:', data);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'UNKNOWN_ERROR':
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  publicKey: '023e72b8b5a20c00dac7ac01ecd72354a2d7d64620d6615524bb18b9f5a6ca8ef4',
  data: '1e810cc032025011df057e99245eece3b7697c27e9b482400130bab576c09f30d9f3bb4414de9ffa623241b231e81d1f089522d1520fb1fdf6c6f34cf9aac7d9',
  message: 'Hello world'
}
      

signTransaction

Sign the provided transaction with the account selected by the user.

Input Arguments
ParameterDescription
transaction: TransactionLikeThe transaction to sign
magicNumber?: numberMagic number of network found in protocol.json.
Success Response
ParameterDescription
transaction: TransactionLikeSigned transaction
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neolineN3.signTransaction({
  transaction: {
    version: 0,
    nonce: 1262108766,
    systemFee: 997775,
    networkFee: 122862,
    validUntilBlock: 667132,
    attributes: [],
    signers: [{ account: "8ddd95c4b5aa2b049abae570cf9bd4476e9b7667", scopes: 1 }],
    witnesses: [],
    script: "0b110c1467769b6e47d49bcf70e5ba9a042baab5c495dd8d0c1467769b6e47d49bcf70e5ba9a042baab5c495dd8d14c01f0c087472616e736665720c14f563ea40bc283d4d0e05c48ea305b3f2a07340ef41627d5b52"
  },
  magicNumber: 877933390
})
.then(signedTx => {
  console.log('Signed Transaction:', signedTx);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'UNKNOWN_ERROR':
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  version: 0,
  nonce: 1262108766,
  systemFee: 997775,
  networkFee: 122862,
  validUntilBlock: 667132,
  attributes: [],
  signers: [{ account: "8ddd95c4b5aa2b049abae570cf9bd4476e9b7667", scopes: 1 }],
  witnesses: [{
    invocationScript: "0c408f8bee3201d41706834fb91c8696d59744dfd927bea5a6bddd21d952d231f8836b0386989ecf017a1d0096c0acdb99503d29f65588bc4021b66a80f4b277ad8c",
    verificationScript: "0c2102f9667a14b62a551f25a1b1ec4562e1c963ec6334d1ef5e088f3b5febddf4e6484156e7b327"
  }],
  script: "0b110c1467769b6e47d49bcf70e5ba9a042baab5c495dd8d0c1467769b6e47d49bcf70e5ba9a042baab5c495dd8d14c01f0c087472616e736665720c14f563ea40bc283d4d0e05c48ea305b3f2a07340ef41627d5b52"
}
      

switchWalletNetwork

Allows NeoLine applications ('dapps') to request that the wallet switches its active Neo network.

ParameterDescription
chainId:inumberSwitch the chainId of the network

Success Response

Null

Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neoline.switchWalletNetwork({
  chainId: 3
})
.then(() => {})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case UNKNOWN_ERROR:
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
null
      

switchWalletAccount

Allows NeoLine applications ('dapps') to request that the wallet switches its active account.

Input Arguments

None

Success Response
ParameterDescription
address: stringAddress of the connected account
label?: stringA label the users has set to identify their wallet
isLedger: booleanWhether the connected account is a ledger account
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neoline.switchWalletAccount()
.then(account => {
  const {
    address,
    label,
    isLedger
  } = account;

  console.log('Provider address: ' + address);
  console.log('Provider account label (Optional): ' + label);
  console.log('Provider account is ledger account: ' + isLedger);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case UNKNOWN_ERROR:
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});

/* Example Response */
{
  address: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo',
  label: 'NEOLine',
  isLedger: false
}
      

Example

Please instantiate it before calling the common methods and common events of Neo2 and N3. See the example for details.


window.addEventListener('NEOLine.NEO.EVENT.READY', () => {
    const neoline = new NEOLine.Init();
});
        

getNetworks

Returns the networks the wallet provider has available to connect to, along with the default network the wallet is currently set to.

Input Arguments

None

Success Response
ParameterDescription
networks: string[]Array of network names the wallet provider has available for the dapp developer to connect to
chainId:inumberChainId the wallet is currently set to
defaultNetwork: stringNetwork the wallet is currently set to
Chain IDs Type

These are the IDs of the Neo chain supported by NeoLine.

chainIdDescription
1ChainId 1 is the Neo2 MainNet
2ChainId 2 is the Neo2 TestNet
3ChainId 3 is the N3 MainNet
6ChainId 6 is the N3 TestNet (Currently only N3 TestNet)
0ChainId 0 is the N3 Private Network
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neoline.getNetworks()
.then(result => {
    const {
        chainId,
        networks,
        defaultNetwork
    } = result;

    console.log('chainId: ' + chainId);
    // eg. 6

    console.log('Networks: ' + networks);
    // eg. ["MainNet", "TestNet", "N3TestNet"]

    console.log('Default network: ' + defaultNetwork);
    // eg. "N3TestNet"
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_DENIED':
            console.log('The user rejected the request to connect with your dApp');
            break;
        case 'CHAIN_NOT_MATCH':
            console.log('The currently opened chain does not match the type of the call chain, please switch the chain.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    chainId: 6,
    networks: ["MainNet", "TestNet", "N3TestNet"],
    defaultNetwork: "N3TestNet"
}
        

getAccount

Return the Account that is currently connected to the dApp.

Input Arguments

None

Success Response
ParameterDescription
address: stringAddress of the connected account
label?: stringA label the users has set to identify their wallet
isLedger: booleanWhether the connected account is a ledger account
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neoline.getAccount()
.then(account => {
    const {
        address,
        label,
        isLedger
    } = account;

    console.log('Provider address: ' + address);
    console.log('Provider account label (Optional): ' + label);
    console.log('Provider account is ledger account: ' + isLedger);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_DENIED':
            console.log('The user rejected the request to connect with your dApp');
            break;
        case 'CHAIN_NOT_MATCH':
            console.log('The currently opened chain does not match the type of the call chain, please switch the chain.');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    address: 'NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq',
    label: 'NEOLine',
    isLedger: false
}

getPublicKey

Return the public key of the Account that is currently connected to the dApp.

Input Arguments

None

Success Response
ParameterDescription
address: stringAddress of the connected account
publicKey: stringPublic key of the connected account
Error Response
ParameterDescription
type: stringThe type of error which has occured
description: stringA description of the error which has occured
data: stringAny raw data associated with the error
/* Example */
neoline.getPublicKey()
.then(publicKeyData => {
    const {
        address,
        publicKey
    } = publicKeyData;

    console.log('Account address: ' + address);
    console.log('Account public key: ' + publicKey);
})
.catch((error) => {
    const {type, description, data} = error;
    switch(type) {
        case 'NO_PROVIDER':
            console.log('No provider available.');
            break;
        case 'CONNECTION_DENIED':
            console.log('The user rejected the request to connect with your dApp');
            break;
        default:
            // Not an expected error object.  Just write the error to the console.
            console.error(error);
            break;
    }
});

/* Example Response */
{
    address: 'NaUjKgf5vMuFt7Ffgfffcpc41uH3adx1jq',
    publicKey: '6PYKGV4numxfoswwCedXzhb1oNCC8W4tEdfFPdtWtFa8WidpzYfeJkd2To'
}
    

READY

On a READY event, the callback will fire with a single argument with information about the wallet provider. At any time a READY event listener is added, it will immidiately be called if the provider is already in a ready state. This provides a single flow for dapp developers since this listener should start any and all interactions with the dapi protocol.

ParameterDescription
name: stringThe name of the wallet provider
website: stringThe website of the wallet provider
version: stringThe version of the dAPI that the the wallet supports
compatibility: string[]A list of all applicable NEPs which the wallet provider supports
extra: objectProvider specific attributes
/* Example */
window.addEventListener('NEOLine.NEO.EVENT.READY', () => {
    console.log('dAPI common method loading is complete.');
});
                

ACCOUNT_CHANGED

On a ACCOUNT_CHANGED event, the callback will fire with a single argument of the new account. This occurs when an account is already connected to the dapp, and the user has changed the connected account from the dapi provider side.

ParameterDescription
address: stringAddress of the connected account
label: stringA label the users has set to identify their wallet

/* Example */
neoline.addEventListener(neoline.EVENT.ACCOUNT_CHANGED, (result) => {
    console.log('account changed:', result);
});
/* Another */
window.addEventListener('NEOLine.NEO.EVENT.ACCOUNT_CHANGED', (result) => {
    console.log('account changed:', result.detail);
});
                

CONNECTED

On a CONNECTED event, the user has approved the connection of the dapp with one of their accounts. This will fire the first time any of one of the following methods are called from the dapp: getAccount, invoke, send.

ParameterDescription
address: stringAddress of the new account
label: stringA label the users has set to identify their wallet

/* Example */
neoline.addEventListener(neoline.EVENT.CONNECTED, (result) => {
    console.log('connected account:', result);
});
/* Another */
window.addEventListener('NEOLine.NEO.EVENT.CONNECTED', (result) => {
    console.log('connected account:', result.detail);
});
                

DISCONNECTED

On a DISCONNECTED event, the account connected to the dapp via the dapi provider has been disconnected (logged out).


/* Example */
neoline.addEventListener(neoline.EVENT.DISCONNECTED, () => {
    console.log('dAPI public method loading is complete.');
});
/* Another */
window.addEventListener('NEOLine.NEO.EVENT.DISCONNECTED', () => {
    console.log('dAPI public method loading is complete.');
});
                

NETWORK_CHANGED

On a NETWORK_CHANGED event, the user has changed the network their provider wallet is connected to. The event will return the updated network details.

ParameterDescription
networks: string[]A list of all networks which this wallet provider allows access to
chainId:inumberchainId the wallet is currently set to
defaultNetwork: stringNetwork the wallet is currently set to

/* Example */
neoline.addEventListener(neoline.EVENT.NETWORK_CHANGED, (result) => {
    console.log('network:', result);
});
/* Another */
window.addEventListener('NEOLine.NEO.EVENT.NETWORK_CHANGED', (result) => {
    console.log('network:', result.detail);
});
                

BLOCK_HEIGHT_CHANGED

On a BLOCK_HEIGHT_CHANGED event, the block has advanced to the next.

ParameterDescription
chainId: numberChainId is the type of wallet selection network
blockHeight: numberHeight of the new block
blockTime: numberTimestamp of the new block
blockHash: stringHash of the new block
tx: string[]List of transaction ids executed in the new block

/* Example */
neoline.addEventListener(neoline.EVENT.BLOCK_HEIGHT_CHANGED, (result) => {
    console.log('block height:', result);
});
/* Another */
window.addEventListener('NEOLine.NEO.EVENT.BLOCK_HEIGHT_CHANGED', (result) => {
    console.log('block height:', result.detail);
});
                

TRANSACTION_CONFIRMED

On a TRANSACTION_CONFIRMED event, a previously broadcast transaction via the dapi has been confirmed by the blockchain.

ParameterDescription
chainId: numberChainId is the type of wallet selection network
txid: stringTransaction id which was confirmed on chain
blockHeight: numberHeight of the new block
blockTime: numberTimestamp of the new block

/* Example */
neoline.addEventListener(neoline.EVENT.TRANSACTION_CONFIRMED, (result) => {
    console.log('Transaction confirmation detail:', result);
});
/* Another */
window.addEventListener('NEOLine.NEO.EVENT.TRANSACTION_CONFIRMED', (result) => {
    console.log('Transaction confirmation detail:', result.detail);
});
                

addEventListener

Method is used to add a callback method to be triggered on a specified event.

/* Example */
const fn = (data) => {
    console.log(`Connected Account: ${data.address}`);
}
neoline.addEventListener(neoline.EVENT.ACCOUNT_CHANGED, fn);
/* Another */
const fn = (data) => {
    console.log(`Connected Account: ${data.detail.address}`);
}
window.addEventListener('NEOLine.NEO.EVENT.ACCOUNT_CHANGED', fn) ;
                

removeEventListener

Method is to remove existing callback event listeners.

/* Example */
neoline.removeEventListener(neoline.EVENT.ACCOUNT_CHANGED, fn);
/* Another */
window.removeEventListener('NEOLine.NEO.EVENT.ACCOUNT_CHANGED', fn);

                

Errors

The NEO dAPI will provide these basic errors. It is up to the wallet provider to provide additional information if they choose:

Error TypeMeaning
NO_PROVIDERThrown when there is no interface capable of interacting with NEO blockchain
CONNECTION_DENIEDThrown when API provider refuses to execute a transaction (e.g. trying to execute a transaction on an unavialable network)
RPC_ERRORThrown when a command relying on RPC connection to a network node fails
MALFORMED_INPUTThrown when an input such as the address is not a valid NEO address
CANCELEDThrown when a user cancels, or refuses the dapps request
INSUFFICIENT_FUNDSThrown when the action does not have a sufficient balance
CHAIN_NOT_MATCHThe currently opened chain does not match the type of the call chain, please switch the chain
SCRIPT_ERRORScript creation error, please check whether the parameters are correct
FAILThe request failed