Neo2 dAPI documentation

Neo2 dAPI N3 Beta DAPI
menu

Example


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

        

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 */
neoline.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: [
    'NEP-14',
    'NEP-23',
    'NEP-29'
  ],
  extra: {
    theme: 'Dark Mode',
    currency: 'USD'
  }
}

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
defaultNetwork: stringNetwork the wallet is currently set to
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 {
    networks,
    defaultNetwork
  } = result;

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

  console.log('Default network: ' + defaultNetwork);
  // eg. "MainNet"
})
.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 */
{
  networks: ["MainNet", "TestNet"],
  defaultNetwork: "TestNet"
}

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;
    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
}

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: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo',
  publicKey: '03ba9524bd7479414be713c3a4f6f3ef35f90bb4b08f0f552211bf734c24415230'
}
    

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 | BalanceRequest[]A list of Balance Request Objects, specifying which addresses, and which assets to query
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to.

BalanceRequest

ParameterDescription
address: stringAddress to check balance(s)
assets?: string | string[]Asset ID or script hash to check balance
fetchUTXO?: booleanFetches to UTXO data for NEO and/or GAS if attribute is 'true'
Success Response
ParameterDescription
[address: string]: iBalanceResponse[]This key is the actual address of the query eg. "AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo"

BalanceResponse

ParameterDescription
assetID: stringID of the given asset
symbol: stringSymbol of the given asset
amount: stringDouble Value of the balance represented as a String
unspent: UTXO[]?If fetch utxo's was turned on then the utxo array will be returned for the native assets NEO and GAS

UTXO

ParameterDescription
asset: stringScript hash of the native asset
createdAtBlock: intBlock number where this utxo was created
index: intOutput index of the UTXO relative to the txid in which it was created
txid: stringThe transaction id of this UTXO
value: stringThe double value of this UTXO represented as a String
/* Example */
neoline.getBalance({
  params: [
    {
      address: 'AUhp11NZfZEDKXWuSo5TPdGhnMx9wG2pdc',
      assets: ['GAS','MCT', '0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b', 'NEO']
    },{
      address: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo'
    }
  ],
  network: 'TestNet'
})
.then((results) => {
  Object.keys(results).forEach(address => {
    const balances = results[address];
    balances.forEach(balance => {
      const { assetID, symbol, amount } = balance

      console.log('Address: ' + address);
      console.log('Asset ID: ' + assetID);
      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;
  }
});

/* Single asset balance request sample */
// input
{
  params: {
    address: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo',
    assets: ['NEO']
  },
  network: 'TestNet'
}

// output
{
  AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo: [
    {
      assetID: '0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
      symbol: 'NEO',
      amount: '6319'
    }
  ],
}

/* Single account balances request sample */
// input
{
  params: {
    address: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo',
  },
  network: 'TestNet'
}

// output
{
  AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo: [
    {
      assetID: '0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
      symbol: 'NEO',
      amount: '6319'
    },
    {
      assetID: '0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'GAS',
      amount: '2958.1094388'
    }
  ]
}

/* Multiple account balances request sample */
// input
{
  params: [
    {
      address: 'AUhp11NZfZEDKXWuSo5TPdGhnMx9wG2pdc'
    },
    {
      address: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo',
      asset: 'NEO'
    }
  ],
  network: 'TestNet'
}

// output
{
  AUhp11NZfZEDKXWuSo5TPdGhnMx9wG2pdc: [
    {
      assetID: '0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'NEO',
      amount: '1'
    },
    {
      assetID: '0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
      symbol: 'GAS',
      amount: '1'
    },
  ],
  AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo: [
    {
      assetID: '0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
      symbol: 'NEO',
      amount: '6319'
    },
    {
      assetID: '0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'GAS',
      amount: '2958.1094388'
    }
  ]
}
    

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
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to
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 */
neoline.getStorage({
  scriptHash: '03febccf81ac85e3d795bc5cbd4e84e907812aa3',
  key: 'Peter',
  network: 'TestNet'
})
.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: 'Lin'
}
    

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
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to.
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 */
neoline.invokeRead({
  scriptHash: '0x96ef49bb4f67e25235a4cd4455d2f10779186ab2',
  operation: 'balanceOf',
  args: [
    {
      type: 'Address',
      value: 'AY5xLg4RPZPcYoD1fW7j455PkAybbU2x42'
    }
  ]
})
.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: '14b2ed6ac7d282933322293e5a0c5c8bb12f9477f251c10962616c616e63654f6667b26a187907f1d25544cda43552e2674fbb49ef96',
  state: 'HALT',
  gas_consumed: '0.315',
  stack: [
    {
      type: 'ByteArray',
      value: '00902f5009'
    }
  ]
}
    

verifyMessage

Returns whether the provided signature data matches the provided message and was signed by the account of the provided public key.

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 */
neoline.verifyMessage({
  message: 'Hello 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
}
    

getBlock

Get information about a specific block.

Input Arguments
ParameterDescription
blockHeight: numberThe height of the block you would like to get information about
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to. If omitted, will default the network which the wallet is set to
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 */
neoline.getBlock({
  blockHeight: 2619690,
  network: 'TestNet'
})
.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: "0xc1668a114ee680597196ed402a0e0507fd8348e6090a54250d7accfadbd74b6e",
  size: 686,
  version: 0,
  previousblockhash: "0xbae289c94e17ae90022673186fd6e1e48b7dd7afb89319bff0e2832db06d16b3",
  merkleroot: "0x07d70f7337d3869a7daa538425d78a47212fb8c6130d66d84ac48526853a4e51",
  time: 1557376153,
  index: 2619690,
  nonce: "8efd62ebb85ee68b",
  nextconsensus: "AWZo4qAxhT8fwKL93QATSjCYCgHmCY1XLB",
  script: {
    invocation: "402a1dab9e5593d1d7d2a22a36772d4541b8053d33f8b8474b7d5a20066c1bd821e051fc252ed16146930d55ecb17fbb74972fba4c4b27af81a707999ca1313dd2401520eba2dd3b54a74a798cbb716c484ba6f6f21218f099e3d622a0fbd15989f38f9b0b344daf9b89175055d3a92f49df65118e8598735d651bedd4f1811baeb140e6491c03f3057f404d2fe7db50e40e82ade405a9dc7fccd81f4ba0b499a4a29f8570d631b8d40c5995b17d9391fe9ff8c73f28a4e1eb922b7a1ce9d1a5dc0448402cfcdede54828875d45402120aa2d8f78c7bd40df5e5d3b1873fd7e4d03672ebd0904f90c90fa519c623968f55550ae55374de66dc0db9c9d865c593bb95be5640214db0cd3cea6f4ad866df4129d482b89583805d1bdb08ce8399881e70351778a3e4a4093cf69aa7b99b83347fbfd38d85ff45d6a78ca2ab8cacffbfbc8c2d16",
    verification: "5521030ef96257401b803da5dd201233e2be828795672b775dd674d69df83f7aec1e36210327da12b5c40200e9f65569476bbff2218da4f32548ff43b6387ec1416a231ee821025bdf3f181f53e9696227843950deb72dcd374ded17c057159513c3d0abe20b64210266b588e350ab63b850e55dbfed0feeda44410a30966341b371014b803a15af0721026ce35b29147ad09e4afe4ec4a7319095f08198fa8babbe3c56e970b143528d222103c089d7122b840a4935234e82e26ae5efd0c2acb627239dc9f207311337b6f2c12103fd95a9cb3098e6447d0de9f76cc97fd5e36830f9c7044457c15a0e81316bf28f57ae"
  },
  tx: [
    {
      txid: "0x07d70f7337d3869a7daa538425d78a47212fb8c6130d66d84ac48526853a4e51",
      size: 10,
      type: "MinerTransaction",
      version: 0,
      attributes: [],
      vin: [],
      vout: [],
      sys_fee: "0",
      net_fee: "0",
      scripts: [],
      nonce: 3093227147
    }
  ],
  confirmations: 104111,
  nextblockhash: "0x2c9d6a107b21e83e09dd1b89df344a726895147d410120c46996290692ba29aa"
}
    

getTransaction

Get information about a specific transaction.

Input Arguments
ParameterDescription
txid: stringThe id of the transaction you would like to get information about
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to. If omitted, will default the network which the wallet is set to
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 */
neoline.getTransaction({
  txid: '0xfb3ecd6070e819187acaa307fb303fda7ae18577d98f948c4a4e13bce7ece474',
  network: 'MainNet'
})
.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 */
{
  txID: "0xfb3ecd6070e819187acaa307fb303fda7ae18577d98f948c4a4e13bce7ece474,
  vin: [
    {
      address: "AZy5LGtAvwpyJMYq39xX4MsDzAL2B6pEZn",
      assetID: "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
      n: 0,
      txid: "0xd7769e675a47bea100e1e9ea5e1723ec181d90b601884ffc4837844d4ca95103",
      value: "4"
    }
  ],
  vout: [
    {
      address: "AZy5LGtAvwpyJMYq39xX4MsDzAL2B6pEZn",
      assetID: "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
      n: 0,
      value: "4"
    }
  ],
  sys_fee: "0",
  net_fee: "0",
  blockIndex: 3840003,
  blocktime: 1559707311
}
  

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
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to. If omitted, will default the network which the wallet is set to
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 */
neoline.getApplicationLog({
  txid: '7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2',
  network: 'TestNet'
})
.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 */
{
  txid: "0x7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2",
  executions: [
    {
      trigger: "Application",
      contract: "0x72985e7f2cea98b89af54d8607bc6400814c4b45",
      vmstate: "HALT, BREAK",
      gas_consumed: "5.292",
      stack: [],
      notifications: [
        {
          contract: "0x849d095d07950b9e56d0c895ec48ec5100cfdff1",
          state: {
            type: "Array",
            value: [
              {
                type: "ByteArray",
                value: "7472616e73666572"
              },
              {
                type: "ByteArray",
                value: "296ac124021a71c449a9bad320c16429b08ad6ee"
              },
              {
                type: "ByteArray",
                value: "7869ef9732cdf6f6d54adaa5cae3b55a9396bceb"
              },
              {
                type: "ByteArray",
                value: "00e1f505"
              }
            ]
          }
        },
        {
          contract: "0x849d095d07950b9e56d0c895ec48ec5100cfdff1",
          state: {
            type: "Array",
            value: [
              {
                type: "ByteArray",
                value: "7472616e73666572"
              },
              {
                type: "ByteArray",
                value: "296ac124021a71c449a9bad320c16429b08ad6ee"
              },
              {
                type: "ByteArray",
                value: "b1fdddf658ce5ff9f83e66ede2f333ecfcc0463e"
              },
              {
                type: "ByteArray",
                value: "00e1f505"
              }
            ]
          }
        }
      ]
    }
  ]
}
      

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
remark?: stringDescription of the transaction to be made
fee?: stringThe parsed amount of network fee (in GAS) to include with transaction
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to
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 */
neoline.send({
  fromAddress: 'AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo',
  toAddress: 'ALWNCcuQDoE287UWvYhRZYpPBDfswggbTX',
  asset: 'NEO',
  amount: '1',
  remark: 'NEOLine',
  fee: '0.0001',
  network: 'TestNet',
  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: 'cb0cf81cdd75762545965038cea350c717a5d500bb40d4ca80fe45f416f564ac',
  nodeURL: 'https://testnet.api.neoline.io'
}
      

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
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to
attachedAssets?: iAttachedAssetsDescribes the assets to attach with the smart contract, e.g. attaching assets to mint tokens during a token sale
assetIntentOverrides?: iAssetIntentOverridesA hard override of all transaction utxo inputs and outputs.

IMPORTANT: If provided, fee and attachedAssets will be ignored.

triggerContractVerification?: booleanAdds the instruction to invoke the contract verification trigger
broadcastOverride?: booleanIn the case that the dApp would like to be responsible for broadcasting the signed transaction rather than the wallet provider
txHashAttributes?: iTxHashAttribute[]Adds transaction attributes for the "Hash" usage block

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

TxHashAttribute

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
txAttrUsage: 'Hash1' | 'Hash2' | 'Hash3' | 'Hash4' | 'Hash5' | 'Hash6' | 'Hash7' | 'Hash8' | 'Hash9' | 'Hash10' | 'Hash11' | 'Hash12' | 'Hash13' | 'Hash14' | 'Hash15'Attribute usage value

AttachedAssets

ParameterDescription
NEO?: stringThe amount of NEO to attach to the contract invocation
GAS?: stringThe amount of GAS to attach to the contract invocation

AssetIntentOverrides

ParameterDescription
inputs: iAssetInput[]A list of UTXO inputs to use for this transaction
outputs: iAssetOutput[]A list of UTXO outputs to use for this transaction

AssetInput

ParameterDescription
txid: stringTransaction id to be used as input
index: numberIndex of the UTXO, can be found from transaction details

AssetOutput

ParameterDescription
asset: stringAsset of the UTXO
address: stringAddress to receive the UTXO
value: stringString representation of double or integer value to be used as output
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
txid: stringThe transaction ID of the 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 */
neoline.invoke({
  scriptHash: 'af7c7328eee5a275a3bcaee2bf0cf662b5e739be',
  operation: 'balanceOf',
  args: [
    {
      type: 'Hash160',
      value: '91b83e96f2a7c4fdf0c1688441ec61986c7cae26'
    }
  ],
  attachedAssets: {
    NEO: '1',
    GAS: '0.0001'
  },
  fee: '0.001',
  network: 'TestNet',
  broadcastOverride: false,
  txHashAttributes: [
    {
      type: 'Boolean',
      value: true,
      txAttrUsage: 'Hash1'
    }
  ]
})
.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: 'd08c5f58675376832480f2959732caa2a0e024ad0304ed77c62146a9621124d6',
  nodeUrl: 'https://testnet.api.neoline.io'
};
      

invokeMulti

Invoke Multi 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
network: stringNetwork alias to submit this request to.
assetIntentOverrides?: iAssetIntentOverridesUsed to specify the exact UTXO's to use for attached assets. If this is provided fee and attachedAssets will be ignored
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.
txHashAttributes?: iTxHashAttribute[]Optional list of tx attribute hash values to be added

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
attachedAssets?: AttachedAssets[]Describes the assets to attach with the smart contract, e.g. attaching assets to mint tokens during a token sale
triggerContractVerification: bolean?Adds the instruction to invoke the contract verifican trigger

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

TxHashAttribute

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
txAttrUsage: 'Hash1' | 'Hash2' | 'Hash3' | 'Hash4' | 'Hash5' | 'Hash6' | 'Hash7' | 'Hash8' | 'Hash9' | 'Hash10' | 'Hash11' | 'Hash12' | 'Hash13' | 'Hash14' | 'Hash15'Attribute usage value

AssetIntentOverrides

ParameterDescription
inputs: iAssetInput[]A list of UTXO inputs to use for this transaction
outputs: iAssetOutput[]A list of UTXO outputs to use for this transaction

AssetInput

ParameterDescription
txid: stringTransaction id to be used as input
index: numberIndex of the UTXO, can be found from transaction details

AssetOutput

ParameterDescription
asset: stringAsset of the UTXO
address: stringAddress to receive the UTXO
value: stringString representation of double or integer value to be used as output
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
txid: stringThe transaction ID of the 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 */
neoline.invokeMulti({
    invokeArgs: [
        {
            scriptHash: "808f0823a811cdb7d80af3509e900cc2f594ceb1",
            operation: "transfer",
            args: [
            {
                    "type": "Address",
                    "value": "AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo"
                },
                {
                    "type": "Address",
                    "value": "AY69kajrRx1Qk29AeLxvkXHYf2h3pQw9yK"
                },
                {
                    "type": "Integer",
                    "value": "100000000"
                }

            ],
            attachedAssets: {
                NEO: '1',
                GAS: '0.0001'
            },
        },
        {
            scriptHash: "808f0823a811cdb7d80af3509e900cc2f594ceb1",
            operation: "transfer",
            args: [
            {
                    "type": "Address",
                    "value": "AWSEU4BXpjGVdw9ajnFBXh8Rg8cgw9f3Zo"
                },
                {
                    "type": "Address",
                    "value": "AY69kajrRx1Qk29AeLxvkXHYf2h3pQw9yK"
                },
                {
                    "type": "Integer",
                    "value": "300000000"
                }
            ],
            attachedAssets: {
                NEO: '2',
                GAS: '0.01'
            },
        }
    ],
    fee: '0.01',
    network: 'TestNet',
    broadcastOverride: false,
    txHashAttributes: [
        {
            type: 'Boolean',
            value: true,
            txAttrUsage: 'Hash1'
        }
    ]
})
.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: "8979389ac095c37c43fa6922ae3f1180e33082394b43108b82cb0ca37d900541",
    nodeURL: "https://testnet.api.neoline.io"
};
      

signMessage

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.

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 */
neoline.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'
}
      

deploy

Will deploy a compiled smart contract to the blockchain with the provided input parameters. The GAS cost for deploying the contract will be calculated by the provider, and displayed to the user upon tx acceptance or rejection.

Input Arguments
ParameterDescription
network?: stringNetwork to submit this request to. If omitted, will default to network the wallet is currently set to
name: stringThe name of the contract to be deployed
version: stringThe version of the contract to be deployed
author: stringThe author of the contract to be deployed
email: stringThe email of the contract to be deployed
description: stringThe description of the contract to be deployed
needsStorage?: booleanWhether or not the contract will use storage
dynamicInvoke?: booleanWhether or not the contract will be performing dynamic invocations of other smart contracts
isPayable?: booleanWhether or not the contract will be able to accept native assets
parameterList: stringThe list of input argument types for the Main function on the contract. https://docs.neo.org/en-us/sc/Parameter.html
returnType: stringThe list of output returnType argument types. https://docs.neo.org/en-us/sc/Parameter.html
code: stringThe hex of the compiled smart contract avm
netowrkFee: numberThe network fee to execute the transaction, in addition to the deploy fee which will be added automatically
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 invocation
nodeURL: stringThe node which the transaction was broadcast to. Returned if transaction is broadcast by wallet

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

ParameterDescription
txid: stringThe transaction ID of the 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 */
neoline.deploy({
  network: 'TestNet',
  name: 'Hello world!',
  version: 'v1.0.0',
  author: 'NEOLine',
  email: 'info@neoline.network',
  description: 'My first contract.',
  needsStorage: true,
  dynamicInvoke: false,
  isPayable: false,
  parameterList: '0710',
  returnType: '05',
  code: '53c56b0d57616b652075702c204e454f21680f4e656f2e52756e74696d652e4c6f6761006c7566',
  networkFee: '0.001'
})
.then(({txid, nodeURL}: InvokeOutput) => {
  console.log('Deploy transaction success!');
  console.log('Transaction ID: ' + txid);
  console.log('RPC node URL: ' + nodeURL);
})
.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 */
{
  txid: '629b5f35e42aa6b65cd97ae3a95f89547596f4e2783c8778428c7f32df07918e',
  nodeUrl: 'https://testnet.api.neoline.io'
};
      

switchWalletNetwork

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

ParameterDescription
chainId:inumberSwitch the chainId of the network

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
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
}
      

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
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
network?: stringNetwork of the block which changed
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
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
FAILThe request failed