Getting Started
What is the dAPI?
The dAPI is a package interface for communicating with the NEO blockchain. The methods are handled by an existing wallet provider, such as the NeoLogin or O3 wallets, and help to reduce the development overhead associated with creating dApps on NEO.
By offloading the responsibility of NEO blockchain interactions to a wallet provider, dApp developers do no have to worry about managing users private keys or how to format transactions to be signed and broadcast. The developer no long has to worry about user onboarding flows related to creating and managing a users secure credentials, and can just focus on the development of their core dApp.
On the user side, since all transactions that a dApp needs to broadcast to the blockchain will be handled by the users wallet proivder, they can feel safe knowing that they never need to copy and paste their private key into a dApp again. Any transaction that a user signs will be done so in the wallet, and their private key will never be provided to the dApp.
Installation
dAPI client integrations are currently facilited via a versioned JS package, and can be imported to your application either via CDN or NPM.
Install via CDN
<script src="https://neologin.io/neologin.js"></script>
window.neologin
window.neologin
Just add a script tag referencing https://neologin.io/neologin.js
to your HTML.
Install via NPM
npm i --save neologin
or
yarn add neologin
var neologin = require('neologin');
or
import neologin from 'neologin';
var neologin = require('neologin');
or
import neologin from 'neologin';
When installing via NPM, it's always advised to lockdown your package version to either the specific version only, or to patch updates.
Mobile Compatibility
We suggest doing the majority of your development using a desktop browser and Chrome's mobile device simulator. Once your app is fully functional on desktop, the neologin wallet will automatically adapt to work on mobile browsers without requiring any additional changes.
Tutorials
Calling dAPI methods
As a general rule, please keep in mind that all methods on the dAPI are asynchronous, and will return a Promise.
In cases where the method is clasified in the API documentation as a "read" method, the Promise will resolve with a result that was either successfully ready from the NEO blockchain or from the users wallet. In the case that it was rejected, it either means the request to the NEO blockchain failed, or the user rejected the request to provide the information from their wallet.
For "write" methods, these will require a signature from the user in the wallet, and will, in most cases, broadcast the signed transaction to the NEO blockchain on behalf of the user. In this case, a resolved Promise will return the transaction id that can be referenced by the dApp to later confirm that it was processes, and a rejected Promise indicates that either the user has denied the request to sign the transaction, or the transaction was rejected by the NEO blockchain.
For all rejected promises, an error object is returned that will describe the reason for which the rejection occured.
Get user address
One of the first basic tasks for any dapp is to get the address of the account which the user would like to utilize with a dApp. In order to do this, we can use the method getAccount
. This method will prompt the user, requesting them to log in their account and, if they have already done so, letting them know that your dApp is requesting that they provide the address of their NeoLogin wallet.
Assuming that you have already included the neologin JS package into your application, you can call the method getAccount
, as follows:
neologin.getAccount()
.then((account: Account) => {
const {
address,
label,
} = account;
console.log('Account address: ' + address);
console.log('Account label: ' + label);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getAccount()
.then((account) => {
const {
address,
label,
} = account;
console.log('Account address: ' + address);
console.log('Account label: ' + label);
})
.catch(({type, description, data}) => {
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;
}
});
This method, like all methods on the dAPI return a JS Promise object. This promise will resolve or reject, based on whether the user has approve or denied your request.
In the case that the request to getAccount
, resolves the Promise, you will be returned an object with the parameters address
and label
. The address
is the NEO address for the account which the user would like to interact with your dApp.
From here, the dApp can use this address to query additional information from the dAPI that are relevant to that specific user, or simply have an address for which assets will be sent.
Getting asset balances
neologin.getBalance({
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
},
network: 'MainNet',
})
.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(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getBalance({
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
},
network: 'MainNet',
})
.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(({type, description, data}) => {
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;
}
});
Whether it be for the account the user has provided to your dApp via getAccount, or you would like to get asset balance information for another account, the getBalance
method can be used. By default, for a provided address, the wallet provider will query the status of the NEO block for the latest asset balances for NEO, GAS, and any NEP5 tokens. This balance request does not require permission from the user, and will return the balances immidiately in the resolve of the returned Promise.
In this first example, we have requested the default balances for the address AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru
on MainNet
. Similarly, you can change the network from which the balances are pulled from. For example, if you are still in development, you can change the network field to TestNet
, and the asset balances for that account will be returned from the NEO test net.
Advanced attributes
neologin.getBalance({
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
assets: ['GAS'],
fetchUTXO: true,
},
network: 'MainNet',
})
neologin.getBalance({
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
assets: ['GAS'],
fetchUTXO: true,
},
network: 'MainNet',
})
Alternatively, this same getBalance
method can accept additional parameters for fetching the balance for only specific assets, or even return the NEO and GAS UTXOs for these balances. This is of course a more advanced usecase, and will probably not be required for the average dApp.
Request assets from user
neologin.send({
fromAddress: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
asset: 'GAS',
amount: '0.01',
network: 'MainNet',
})
.then(({txid, nodeUrl}: SendOutput) => {
console.log('Send transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type: string, description: string, data: any}) => {
switch(type) {
case NO_PROVIDER:
console.log('No provider available.');
break;
case SEND_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;
}
});
neologin.send({
fromAddress: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
asset: 'GAS',
amount: '0.01',
network: 'MainNet',
})
.then(({txid, nodeUrl}) => {
console.log('Send transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type, description, data}) => {
switch(type) {
case "NO_PROVIDER":
console.log('No provider available.');
break;
case "SEND_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;
}
});
In the case where the dApp would like to request a payment or any general sending of assets from the users wallet address to another address. The dAPI provides a method called send
. The send
method accepts the basic parameters for from which address the assets are to be sent from, the address which wil be receiving the assets, what asset to send, and the amount to be sent.
In this basic example, we are conducting a basic send of 0.01 GAS from the address that we got from calling getAccount
, to the dApp address.
Advanced attributes
neologin.send({
fromAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
asset: 'GAS',
amount: '0.01',
network: 'MainNet',
remark: 'Hash puppy clothing purchase. Invoice#abc123',
fee: '0.0011',
})
neologin.send({
fromAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
asset: 'GAS',
amount: '0.01',
network: 'MainNet',
remark: 'Hash puppy clothing purchase. Invoice#abc123',
fee: '0.0011',
})
The send
method can also accept an option parameter called remark
. This will allow you to attach a short message description for the send transaction. This will be recorded on the blockchain as a part of the transaction.
The dApp can also specific a network fee amount attached to the transaction under the parameter fee
. This network fee will be paid by the user in GAS, and will help to aid to get the transaction processed quicker when the mempool is full with free of lower fee transactions.
API Methods
Read Methods
Read methods do not alter the state of the blockchain. It can help you query information about your user, and provide you with relevant information:
getProvider
neologin.getProvider()
.then((provider: Provider) => {
const {
name,
website,
version,
compatibility,
extra,
} = provider;
const {
theme,
currency,
} = extra;
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('Provider UI theme: ' + theme);
console.log('Provider Base currency: ' + currency);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getProvider()
.then((provider) => {
const {
name,
website,
version,
compatibility,
extra,
} = provider;
const {
theme,
currency,
} = extra;
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('Provider UI theme: ' + theme);
console.log('Provider Base currency: ' + currency);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
name: 'Awesome Wallet',
website: 'https://www.awesome.com',
version: 'v0.0.1',
compatibility: [
'NEP-14',
'NEP-23',
'NEP-29'
],
extra: {
theme: 'Dark Mode',
currency: 'USD',
}
}
{
name: 'Awesome Wallet',
website: 'https://www.awesome.com',
version: 'v0.0.1',
compatibility: [
'NEP-14',
'NEP-23',
'NEP-29'
],
extra: {
theme: 'Dark Mode',
currency: 'USD',
}
}
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
Parameter | Type | Description |
---|---|---|
name | String | The name of the wallet provider |
website | String | The website of the wallet provider |
version | String | The version of the dAPI that the the wallet supports |
compatibility | String[] | A list of all applicable NEPs which the wallet provider supports |
extra | Object | Provider specific attributes |
extra
Parameter | Type | Description |
---|---|---|
theme | string | UI theme of the provider |
currency | string | Base currency set by user |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getNetworks
neologin.getNetworks()
.then(response => {
const {
networks,
defaultNetwork,
} = response;
console.log('Networks: ' + networks);
// eg. ["MainNet", "TestNet", "PrivateNet"]
console.log('Default network: ' + defaultNetwork);
// eg. "MainNet"
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getNetworks()
.then(response => {
const {
networks,
defaultNetwork,
} = response;
console.log('Networks: ' + networks);
// eg. ["MainNet", "TestNet", "PrivateNet"]
console.log('Default network: ' + defaultNetwork);
// eg. "MainNet"
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
networks: ["MainNet", "TestNet", "PrivateNet"],
defaultNetwork: "TestNet",
}
{
networks: ["MainNet", "TestNet", "PrivateNet"],
defaultNetwork: "TestNet",
}
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
Parameter | Type | Description |
---|---|---|
networks | String[] | A list of all networks which this wallet provider allows access to |
defaultNetwork | String | Network the wallet is currently set to |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getAccount
neologin.getAccount()
.then((account: Account) => {
const {
address,
label,
} = account;
console.log('Account address: ' + address);
console.log('Account label: ' + label);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getAccount()
.then((account) => {
const {
address,
label,
} = account;
console.log('Account address: ' + address);
console.log('Account label: ' + label);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
label: 'My Spending Wallet'
}
{
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
label: 'My Spending Wallet'
}
Return the Account that is currently connected to the dApp.
Success Response
Parameter | Type | Description |
---|---|---|
address | String | The address of the account that is currently connected to the dapp |
label | String | A label the users has set to identify their wallet |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getPublicKey
neologin.getPublicKey()
.then((publicKeyData: PublicKeyData) => {
const {
address,
publicKey,
} = publicKeyData;
console.log('Account address: ' + address);
console.log('Account public key: ' + publicKey);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getPublicKey()
.then((publicKeyData) => {
const {
address,
publicKey,
} = publicKeyData;
console.log('Account address: ' + address);
console.log('Account public key: ' + publicKey);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
address: 'ATUaTd3LA4kZiyB6it9fdb5oJpZYMBF4DX',
publicKey: '03fa41b6ff75ebeff8464556629cfceae7402f5d815626a7a6542f786974b942e0'
}
{
address: 'ATUaTd3LA4kZiyB6it9fdb5oJpZYMBF4DX',
publicKey: '03fa41b6ff75ebeff8464556629cfceae7402f5d815626a7a6542f786974b942e0'
}
Return the public key of the Account that is currently connected to the dApp.
Success Response
Parameter | Type | Description |
---|---|---|
address | String | The address of the account that is currently connected to the dapp |
publicKey | String | The public key of the account that is currently connected to the dapp |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getBalance
neologin.getBalance({
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
assets: ['NKN']
},
network: 'MainNet',
})
.then((results: BalanceResults) => {
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(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getBalance({
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
assets: ['NKN']
},
network: 'MainNet',
})
.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(({type, description, data}) => {
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;
}
});
Single Address with specific balances requested
// input
{
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
assets: ['NKN']
},
network: 'MainNet',
}
// output
{
AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
{
assetID: 'c36aee199dbba6c3f439983657558cfb67629599',
symbol: 'NKN',
amount: '0.00000233',
}
],
}
// input
{
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
assets: ['NKN']
},
network: 'MainNet',
}
// output
{
AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
{
assetID: 'c36aee199dbba6c3f439983657558cfb67629599',
symbol: 'NKN',
amount: '0.00000233',
}
],
}
Single Address with all balances requested
// input
{
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
},
network: 'MainNet',
}
// output
{
AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
{
assetID: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
symbol: 'NEO',
amount: '10',
},
{
assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
symbol: 'GAS',
amount: '777.0001',
},
{
assetID: 'c36aee199dbba6c3f439983657558cfb67629599',
symbol: 'NKN',
amount: '0.00000233',
},
{
assetID: 'fc732edee1efdf968c23c20a9628eaa5a6ccb934',
symbol: 'NNC',
amount: '2000',
}
]
}
// input
{
params: {
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
},
network: 'MainNet',
}
// output
{
AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
{
assetID: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
symbol: 'NEO',
amount: '10',
},
{
assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
symbol: 'GAS',
amount: '777.0001',
},
{
assetID: 'c36aee199dbba6c3f439983657558cfb67629599',
symbol: 'NKN',
amount: '0.00000233',
},
{
assetID: 'fc732edee1efdf968c23c20a9628eaa5a6ccb934',
symbol: 'NNC',
amount: '2000',
}
]
}
Multiple address balance queries
// input
{
params: [
{
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
},
{
address: 'AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ',
assets: ['PHX'],
},
],
network: 'MainNet',
}
// output
{
AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
{
assetID: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
symbol: 'NEO',
amount: '10',
},
{
assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
symbol: 'GAS',
amount: '777.0001',
},
{
assetID: 'c36aee199dbba6c3f439983657558cfb67629599',
symbol: 'NKN',
amount: '0.00000233',
},
{
assetID: 'fc732edee1efdf968c23c20a9628eaa5a6ccb934',
symbol: 'NNC',
amount: '2000',
}
],
AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ: [
{
assetID: '1578103c13e39df15d0d29826d957e85d770d8c9',
symbol: 'PHX',
amount: '11000',
}
]
}
// input
{
params: [
{
address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
},
{
address: 'AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ',
assets: ['PHX'],
},
],
network: 'MainNet',
}
// output
{
AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
{
assetID: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
symbol: 'NEO',
amount: '10',
},
{
assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
symbol: 'GAS',
amount: '777.0001',
},
{
assetID: 'c36aee199dbba6c3f439983657558cfb67629599',
symbol: 'NKN',
amount: '0.00000233',
},
{
assetID: 'fc732edee1efdf968c23c20a9628eaa5a6ccb934',
symbol: 'NNC',
amount: '2000',
}
],
AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ: [
{
assetID: '1578103c13e39df15d0d29826d957e85d770d8c9',
symbol: 'PHX',
amount: '11000',
}
]
}
Allows the DAPP to query the balance of a user, this includes both native assets (NEO/GAS) and NEP-5 tokens
Input Arguments
Parameter | Type | Description |
---|---|---|
params | BalanceRequest or BalanceRequest[] | A list of Balance Request Objects, specifying which addresses, and which assets to query |
network | String | The call will only work for the networks available in the GetNetworks command |
Balance Request
Parameter | Type | Description |
---|---|---|
address | String | The address whose balance you want to query |
assets | String[] | A list of contract hash (or symbold on MainNet only) to query the balance for |
fetchUTXO? | boolean | The response will fetch NEO and GAS UTXO's if this attribute is true |
Success Response
Parameter | Type | Description |
---|---|---|
address_1 | BalanceResponse[] | This key is the actual address of the query eg. "AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru" |
address_2 | BalanceResponse[] | This key is the actual address of the query eg. "AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ" |
address_n | BalanceResponse[] | This key is the actual address of the query eg. "AUdawyrLMskxXMUE8osX9mSLKz8R7777kE" |
BalanceResponse
Parameter | Type | Description |
---|---|---|
assetID | String | ID of the given asset |
symbol | String | Symbol of the given asset |
amount | String | Double 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
Parameter | Type | Description |
---|---|---|
asset | String | Script hash of the native asset |
createdAtBlock | String | Block number where this utxo was created |
index | Int | Output index of the UTXO relative to the txid in which it was created |
txid | String | The transaction id of this UTXO |
value | String | The double value of this UTXO represented as a String |
getStorage
neologin.getStorage({
scriptHash: 'b3a14d99a3fb6646c78bf2f4e2f25a7964d2956a',
key: '74657374',
network: 'TestNet'
})
.then(res => {
const value = res.result;
console.log('Storage value: ' + value);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getStorage({
scriptHash: 'b3a14d99a3fb6646c78bf2f4e2f25a7964d2956a',
key: '74657374',
network: 'TestNet'
})
.then(res => {
const value = res.result;
console.log('Storage value: ' + value);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
result: 'hello world'
}
{
result: 'hello world'
}
Returns the raw value located in contract storage
Input Arguments
Parameter | Type | Description |
---|---|---|
scriptHash | String | Scripthash of the contract whose storage you are querying on |
key | String | Key of the storage value to retrieve from the contract |
network | String | Network alias to submit this request to. |
Success Response
Parameter | Type | Description |
---|---|---|
result | String | The raw value located in contract storage |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
invokeRead
neologin.invokeRead({
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'calculatorAdd',
args: [
{
type: neologin.Constants.ArgumentDataType.INTEGER,
value: 2
},
{
type: neologin.Constants.ArgumentDataType.INTEGER,
value: 10
}
],
network: 'TestNet'
})
.then((result: Object) => {
console.log('Read invocation result: ' + JSON.stringify(result));
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.invokeRead({
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'calculatorAdd',
args: [
{
type: neologin.Constants.ArgumentDataType.INTEGER,
value: 2
},
{
type: neologin.Constants.ArgumentDataType.INTEGER,
value: 10
}
],
network: 'TestNet'
})
.then((result) => {
console.log('Read invocation result: ' + JSON.stringify(result));
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
script: '8h89fh398f42f.....89hf2894hf9834',
state: 'HALT, BREAK',
gas_consumed: '0.13',
stack: [
{
type: 'Integer',
value: '1337'
}
]
}
{
script: '8h89fh398f42f.....89hf2894hf9834',
state: 'HALT, BREAK',
gas_consumed: '0.13',
stack: [
{
type: 'Integer',
value: '1337'
}
]
}
Execute a contract invocation in read-only mode.
Input Arguments
Parameter | Type | Description |
---|---|---|
scriptHash | String | The script hash of the contract you want to invoke a read on |
operation | String | The operation on the smart contract that you want to invoke a read on |
args | Argument[] | The input arguments necessary to perform this operation |
network | String | Network alias to submit this request to. If omitted, will default the network which the wallet is set to |
Argument
Parameter | Type | Description |
---|---|---|
type | String | The type of the argument with you are using |
value | String | String representation of the argument which you are using |
Success Response
The wallet will return the direct response from the RPC node.
Parameter | Type | Description |
---|---|---|
script | String | The script which was run |
state | String | Status of the executeion |
gas_consumed | String | Estimated amount of GAS to be used to execute the invocation. (Up to 10 free per transaction) |
stack | Argument[] | An array of response arguments |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
verifyMessage
neologin.verifyMessage({
message: '058b9e03e7154e4db1e489c99256b7faHello World!',
data: '0147fb89d0999e9d8a90edacfa26152fe695ec8b3770dcad522048297ab903822e12472364e254ff2e088fc3ebb641cc24722c563ff679bb1d1623d08bd5863d0d',
publicKey: '0241392007396d6ef96159f047967c5a61f1af0871ecf9dc82afbedb68afbb949a',
})
.then(({result: bool}) => {
console.log('Signature data matches provided message and public key: ' + result);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.verifyMessage({
message: '058b9e03e7154e4db1e489c99256b7faHello World!',
data: '0147fb89d0999e9d8a90edacfa26152fe695ec8b3770dcad522048297ab903822e12472364e254ff2e088fc3ebb641cc24722c563ff679bb1d1623d08bd5863d0d',
publicKey: '0241392007396d6ef96159f047967c5a61f1af0871ecf9dc82afbedb68afbb949a',
})
.then(({result}) => {
console.log('Signature data matches provided message and public key: ' + result);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
result: true,
}
{
result: true,
}
Returns whether the provided signature data matches the provided message and was signed by the account of the provided public key.
Input Arguments
Parameter | Type | Description |
---|---|---|
message | String | The original signed message |
data | String | The signature data |
publicKey | String | The public key of the account used to sign the message |
Success Response
Parameter | Type | Description |
---|---|---|
result | Boolean | Whether the provided signature matches the provided message and public key |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occurred |
description | String | A description of the error which has occurred |
data | String? | Any raw data associated with the error |
getBlock
neologin.getBlock({
blockHeight: 2619690,
network: 'TestNet'
})
.then((result: Object) => {
console.log('Block information: ' + JSON.stringify(result));
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getBlock({
blockHeight: 2619690,
network: 'TestNet'
})
.then((result) => {
console.log('Block information: ' + JSON.stringify(result));
})
.catch(({type, description, data}) => {
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;
}
});
Get information about a specific block.
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": 70,
"nextblockhash": "0x2c9d6a107b21e83e09dd1b89df344a726895147d410120c46996290692ba29aa"
}
{
"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": 70,
"nextblockhash": "0x2c9d6a107b21e83e09dd1b89df344a726895147d410120c46996290692ba29aa"
}
Execute a contract invocation in read-only mode.
Input Arguments
Parameter | Type | Description |
---|---|---|
blockHeight | integer | The height of the block you would like to get information about. |
network | String | Network alias to submit this request 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
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getBlockHeight
neologin.getBlockHeight({
network: 'TestNet'
})
.then((res: {result: number}) => {
console.log('Block height: ' + res.result);
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getBlockHeight({
network: 'TestNet'
})
.then((res) => {
console.log('Block height: ' + res.result);
})
.catch(({type, description, data}) => {
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;
}
});
Get the height of the current block.
Example Response
{
"result": 2619690
}
Execute a contract invocation in read-only mode.
Input Arguments
Parameter | Type | Description |
---|---|---|
network | String | Network alias to submit this request to. If omitted, will default the network which the wallet is set to |
Success Response
Parameter | Type | Description |
---|---|---|
result | Number | Height of the current block |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getTransaction
neologin.getTransaction({
txid: '7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2',
network: 'TestNet'
})
.then((result: Object) => {
console.log('Transaction details: ' + JSON.stringify(result));
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getTransaction({
txid: '7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2',
network: 'TestNet'
})
.then((result) => {
console.log('Transaction details: ' + JSON.stringify(result));
})
.catch(({type, description, data}) => {
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;
}
});
Get information about a specific transaction.
Example Response
{
"txid": "0x7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2",
"size": 556,
"type": "InvocationTransaction",
"version": 1,
"attributes": [
{
"usage": "Script",
"data": "296ac124021a71c449a9bad320c16429b08ad6ee"
},
{
"usage": "Remark",
"data": "cbb549adec34d741"
}
],
"vin": [],
"vout": [],
"sys_fee": "0",
"net_fee": "0",
"scripts": [
{
"invocation": "4072b83e8aca62c27dc36b032b895e757db00620384e26f43cd0ecc9904bff1e652dd94a03226d6dcb0b6f91104cb40be6455aa0fc3b474a8a8e5fa43ff4b10b8d40af726dc0976f15cd8a134634074c5613ab1e59979fec37b611392975c92afa11038fd9d96ddfb306df12ae200dc3c15fa17cb9530389e28f090fd8c9721c3307",
"verification": "53c56b6c766b00527ac46c766b51527ac4616c766b00c36121022949376faacb0c6783da8ab63548926cb3a2e8d786063a449833f927fa8853f0ac642f006c766b51c361210292a25f5f0772d73d3fb50d42bb3cb443505b15e106789d19efa4d09c5ddca756ac635f006c766b00c361210292a25f5f0772d73d3fb50d42bb3cb443505b15e106789d19efa4d09c5ddca756ac642f006c766b51c36121022949376faacb0c6783da8ab63548926cb3a2e8d786063a449833f927fa8853f0ac62040000620400516c766b52527ac46203006c766b52c3616c7566"
}
],
"script": "0400e1f505147869ef9732cdf6f6d54adaa5cae3b55a9396bceb14296ac124021a71c449a9bad320c16429b08ad6ee53c1087472616e7366657267f1dfcf0051ec48ec95c8d0569e0b95075d099d84f10400e1f50514b1fdddf658ce5ff9f83e66ede2f333ecfcc0463e14296ac124021a71c449a9bad320c16429b08ad6ee53c1087472616e7366657267f1dfcf0051ec48ec95c8d0569e0b95075d099d84f1",
"gas": "0",
"blockhash": "0x4ea57fe267a392933d2b03fa733fbf1fa12c13f7e8ae2051e45465800e1a7cdb",
"confirmations": 9,
"blocktime": 1557377749
}
{
"txid": "0x7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2",
"size": 556,
"type": "InvocationTransaction",
"version": 1,
"attributes": [
{
"usage": "Script",
"data": "296ac124021a71c449a9bad320c16429b08ad6ee"
},
{
"usage": "Remark",
"data": "cbb549adec34d741"
}
],
"vin": [],
"vout": [],
"sys_fee": "0",
"net_fee": "0",
"scripts": [
{
"invocation": "4072b83e8aca62c27dc36b032b895e757db00620384e26f43cd0ecc9904bff1e652dd94a03226d6dcb0b6f91104cb40be6455aa0fc3b474a8a8e5fa43ff4b10b8d40af726dc0976f15cd8a134634074c5613ab1e59979fec37b611392975c92afa11038fd9d96ddfb306df12ae200dc3c15fa17cb9530389e28f090fd8c9721c3307",
"verification": "53c56b6c766b00527ac46c766b51527ac4616c766b00c36121022949376faacb0c6783da8ab63548926cb3a2e8d786063a449833f927fa8853f0ac642f006c766b51c361210292a25f5f0772d73d3fb50d42bb3cb443505b15e106789d19efa4d09c5ddca756ac635f006c766b00c361210292a25f5f0772d73d3fb50d42bb3cb443505b15e106789d19efa4d09c5ddca756ac642f006c766b51c36121022949376faacb0c6783da8ab63548926cb3a2e8d786063a449833f927fa8853f0ac62040000620400516c766b52527ac46203006c766b52c3616c7566"
}
],
"script": "0400e1f505147869ef9732cdf6f6d54adaa5cae3b55a9396bceb14296ac124021a71c449a9bad320c16429b08ad6ee53c1087472616e7366657267f1dfcf0051ec48ec95c8d0569e0b95075d099d84f10400e1f50514b1fdddf658ce5ff9f83e66ede2f333ecfcc0463e14296ac124021a71c449a9bad320c16429b08ad6ee53c1087472616e7366657267f1dfcf0051ec48ec95c8d0569e0b95075d099d84f1",
"gas": "0",
"blockhash": "0x4ea57fe267a392933d2b03fa733fbf1fa12c13f7e8ae2051e45465800e1a7cdb",
"confirmations": 9,
"blocktime": 1557377749
}
Execute a contract invocation in read-only mode.
Input Arguments
Parameter | Type | Description |
---|---|---|
txid | String | The id of the transaction you would like to get information about. |
network | String | Network alias to submit this request 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
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
getApplicationLog
neologin.getApplicationLog({
txid: '7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2',
network: 'TestNet'
})
.then((result: Object) => {
console.log('Application log of transaction execution: ' + JSON.stringify(result));
})
.catch(({type: string, description: string, data: any}) => {
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;
}
});
neologin.getApplicationLog({
txid: '7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2',
network: 'TestNet'
})
.then((result) => {
console.log('Application log of transaction execution: ' + JSON.stringify(result));
})
.catch(({type, description, data}) => {
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;
}
});
Get the application log for a given transaction.
Example Response
{
"txid": "0x7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2",
"executions": [
{
"trigger": "Application",
"contract": "0x72985e7f2cea98b89af54d8607bc6400814c4b45",
"vmstate": "HALT",
"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"
}
]
}
}
]
}
]
}
{
"txid": "0x7e049fd7c253dabf38e4156df30c78b30d49f307196aa89b99a47d2330789bf2",
"executions": [
{
"trigger": "Application",
"contract": "0x72985e7f2cea98b89af54d8607bc6400814c4b45",
"vmstate": "HALT",
"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"
}
]
}
}
]
}
]
}
Execute a contract invocation in read-only mode.
Input Arguments
Parameter | Type | Description |
---|---|---|
txid | String | The id of the transaction you would like to get the application logs for. |
network | String | Network alias to submit this request 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
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
Encrypt
neologin.encrypt({
recipientPublicKey: "03ca7443e1ec9e9c502ebe5a8f6d76f02f9b74bf9063bf3921ad9b76d389218529",
data: "Guess what"
})
.then(({iv, data, mac}: EncryptOutput) => {
console.log('Data encrypted success!');
console.log('Iv: 'iv);
console.log('Mac: ' + mac);
console.log('Encrypted data: ' + data);
})
.catch(({type: string, description: string, data: any}) => {
switch(type) {
case MALFORMED_INPUT:
console.log('Input not valid.');
break;
}
});
neologin.send({
recipientPublicKey: "03ca7443e1ec9e9c502ebe5a8f6d76f02f9b74bf9063bf3921ad9b76d389218529",
data: "Guess what"
})
.then(({txid, nodeUrl}) => {
console.log('Data encrypted success!');
console.log('Iv: 'iv);
console.log('Mac: ' + mac);
console.log('Encrypted data: ' + data);
})
.catch(({type, description, data}) => {
switch(type) {
case MALFORMED_INPUT:
console.log('Input not valid.');
break;
}
});
Example Response
{
iv: "459d0efdfcd2091f6c6d2dbe2a763a1e",
mac: "16f413e85e85594180e889db139306e4aab75df4a6d6c5e211473e8b4d3527f3",
data: "73bb2f041bf8cad3cbb514b092dadcd3"
}
{
iv: "459d0efdfcd2091f6c6d2dbe2a763a1e",
mac: "16f413e85e85594180e889db139306e4aab75df4a6d6c5e211473e8b4d3527f3",
data: "73bb2f041bf8cad3cbb514b092dadcd3"
}
Encrypts data using a public key. Aes 256 cbc encryption.
Input Arguments
Parameter | Type | Description |
---|---|---|
recipientPublicKey | String | Recipient's public key |
data | String or Buffer | Data you want to encrypt |
Success Response
Parameter | Type | Description |
---|---|---|
iv | String | Initialization vector (nonce). Necessary to decrypt |
mac | String | Message authentication code. Necessary to decrypt |
data | String | Encrypted data. Necessary to decrypt |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
Decrypt
neologin.decrypt({
senderPublicKey: "029c6fac1f105c2eef68a220018eada4740d013e0cf0091e9aa1fb95f2e328d1c8",
iv: "3ad568936c20b8e15c1e2c6ca72db446",
mac: "a27507c744d99405e772ff1f96ec276eadb1ba50373bbeb74a5a5d2935269a8d",
data: "4580a73371ef75f4c14b3b46835ea055"
})
.then(({bufferData, data}: DecryptOutput) => {
console.log('Data decrypted success!');
console.log('Decrypted data: ' + data);
})
.catch(({type: string, description: string, data: any}) => {
switch(type) {
case MALFORMED_INPUT:
console.log('Input not valid.');
break;
case BAD_MAC:
console.log('Bad mac')
}
});
neologin.send({
senderPublicKey: "029c6fac1f105c2eef68a220018eada4740d013e0cf0091e9aa1fb95f2e328d1c8",
iv: "3ad568936c20b8e15c1e2c6ca72db446",
mac: "a27507c744d99405e772ff1f96ec276eadb1ba50373bbeb74a5a5d2935269a8d",
data: "4580a73371ef75f4c14b3b46835ea055"
})
.then(({bufferData, data}) => {
console.log('Data decrypted success!');
console.log('Decrypted data: ' + data);
})
.catch(({type, description, data}) => {
switch(type) {
case MALFORMED_INPUT:
console.log('Input not valid.');
break;
case BAD_MAC:
console.log('Bad mac')
}
});
Example Response
{
bufferData: Uint8Array(10), //[71, 117, 101, 115, 115, 32, 119, 104, 97, 116]
data: "Guess what"
}
{
bufferData: Uint8Array(10), //[71, 117, 101, 115, 115, 32, 119, 104, 97, 116]
data: "Guess what"
}
Decrypts data using user's private key. Data must have been encrypted with his public key. Aes 256 cbc decryption.
Input Arguments
Parameter | Type | Description |
---|---|---|
senderPublicKey | String | Sender's public key |
iv | String | Initialization vector |
mac | String | Message authentication code |
data | String | Data encypted |
Success Response
Parameter | Type | Description |
---|---|---|
bufferData | Uint8Array | Decrypted data |
data | String | Decrypted data |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
Write Methods
Write methods will alter the state on the blockchain, and require a user signature.
send
neologin.send({
fromAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
asset: 'GAS',
amount: '0.0001',
remark: 'Hash puppy clothing purchase. Invoice#abc123',
fee: '0.0001',
network: 'MainNet',
broadcastOverride: false,
})
.then(({txid, nodeUrl}: SendOutput) => {
console.log('Send transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type: string, description: string, data: any}) => {
switch(type) {
case NO_PROVIDER:
console.log('No provider available.');
break;
case SEND_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;
}
});
neologin.send({
fromAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
asset: 'GAS',
amount: '0.0001',
remark: 'Hash puppy clothing purchase. Invoice#abc123',
fee: '0.0001',
network: 'MainNet',
broadcastOverride: false,
})
.then(({txid, nodeUrl}) => {
console.log('Send transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type, description, data}) => {
switch(type) {
case "NO_PROVIDER":
console.log('No provider available.');
break;
case "SEND_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;
}
});
Example Response
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
The send API can be used for accepting payments from the user in a cryptocurrency that is located on the NEO blockchain. It requires user authentication in order for the transaction to be relayed. The transaction will be relayed by the wallet.
Input Arguments
Parameter | Type | Description |
---|---|---|
fromAddress | String | The address from where the transaction is being sent. This will be the same value as the one received from the getAccount API |
toAddress | String | The address to where the user should send their funds |
asset | String | The asset which is being requested for payment...e.g NEP5 scripHash, GAS or CGAS |
amount | String | The amount which is being requested for payment |
remark | String? | A transaction attribute remark which may be placed in the transaction, this data will appear in the transaction record on the blockchain |
fee | String? | If 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 | String | Network alias to submit this request to. |
broadcastOverride | Boolean? | If this flag is set to True, the wallet provider will return the signed transaction rather than broadcasting to a node. |
Success Response
In the case where the "broadcastOverride" input argument is not set, or set to false.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
nodeURL | String | The node to which the transaction was submitted to |
In the case where the "broadcastOverride" input argument is set to True.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
signedTx | String | The serialized signed transaction |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
invoke
neologin.invoke({
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'storeData',
args: [
{
type: neologin.Constants.ArgumentDataType.STRING,
value: 'hello'
}
],
attachedAssets: {
NEO: '100',
GAS: '0.0001',
},
fee: '0.001',
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(({type: string, description: string, data: any}) => {
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;
}
});
neologin.invoke({
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'storeData',
args: [
{
type: neologin.Constants.ArgumentDataType.STRING,
value: 'hello'
}
],
attachedAssets: {
NEO: '100',
GAS: '0.0001',
},
fee: '0.001',
network: 'TestNet',
broadcastOverride: false,
txHashAttributes: [
{
type: 'Boolean',
value: true,
txAttrUsage: 'Hash1'
}
]
})
.then(({txid, nodeUrl}) => {
console.log('Invoke transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
Invoke allows for the generic execution of smart contracts on behalf of the user. It is recommended to have a general understanding of the NEO blockchain, and to be able successfully use all other commands listed previously in this document before attempting a generic contract execution.
Input arguments
Parameter | Type | Description |
---|---|---|
scriptHash | String | The script hash of the contract that you wish to invoke |
operation | String | The operation on the smart contract that you wish to call. This can be fetched from the contract ABI |
args | Argument[] | A list of arguments necessary to perform on the operation you wish to call |
fee | String? | If 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 | String | Network alias to submit this request to. |
attachedAssets | AttachedAssets? | Describes the assets to attach with the smart contract, e.g. attaching assets to mint tokens during a token sale |
assetIntentOverrides | AssetIntentOverrides | Used to specify the exact UTXO's to use for attached assets. If this is provided fee and attachedAssets will be ignored |
triggerContractVerification | Boolean? | Adds the instruction to invoke the contract verifican trigger |
broadcastOverride | Boolean? | If this flag is set to True, the wallet provider will return the signed transaction rather than broadcasting to a node. |
txHashAttributes | TxHashAttribute[]? | Optional list of tx attribute hash values to be added |
Argument
Parameter | Type | Description |
---|---|---|
type | String | The type of the argument with you are using |
value | String | String representation of the argument which you are using |
TxHashAttribute
Parameter | Type | Description |
---|---|---|
type | String | The type of the argument with you are using |
value | String | String representation of the argument which you are using |
txAttrUsage | String | Attribute usage value |
AttachedAssets
Parameter | Type | Description |
---|---|---|
NEO | String? | The amount of NEO to attach to the contract invocation |
GAS | String? | The amount of GAS to attach to the contract invocation |
AssetIntentOverrides
Parameter | Type | Description |
---|---|---|
inputs | AssetInput[] | A list of UTXO inputs to use for this transaction |
outputs | AssetOutput[] | A list of UTXO outputs to use for this transaction |
AssetInput
Parameter | Type | Description |
---|---|---|
txid | String | Transaction id to be used as input |
index | String | Index of the UTXO, can be found from transaction details |
AssetOutput
Parameter | Type | Description |
---|---|---|
asset | String | Asset of the UTXO |
address | String | Address to receive the UTXO |
value | String | String 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.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
nodeURL | String | The node to which the transaction was submitted to |
In the case where the "broadcastOverride" input argument is set to True.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
signedTx | String | The serialized signed transaction |
Set script transaction attribute 0x20 according to the following conditions:
- If triggerContractVerification is set to true, set 0x20 to scriptHash of the contract being invoked
- If there is no fee, attachedAssets, or 'assetIntentOverrides', set 0x20 to the users address
- If there are assetIntentOverrides but none of the inputs belong to the user address, set 0x20 to user address
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
invokeMulti
neologin.invokeMulti({
invokeArgs: [
{
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'storeData',
args: [
{
type: neologin.Constants.ArgumentDataType.STRING,
value: 'hello'
}
],
attachedAssets: {
NEO: '100',
GAS: '0.0001',
},
triggerContractVerification: true,
},
{
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'purchaseTicket',
args: [
{
type: neologin.Constants.ArgumentDataType.INTEGER,
value: '10'
}
],
}
],
fee: '0.001',
network: 'TestNet',
broadcastOverride: false,
txHashAttributes: [
{
type: neologin.Constants.ArgumentDataType.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(({type: string, description: string, data: any}) => {
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;
}
});
neologin.invokeMulti({
invokeArgs: [
{
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'storeData',
args: [
{
type: neologin.Constants.ArgumentDataType.STRING,
value: 'hello'
}
],
attachedAssets: {
NEO: '100',
GAS: '0.0001',
},
triggerContractVerification: true,
},
{
scriptHash: '505663a29d83663a838eee091249abd167e928f5',
operation: 'purchaseTicket',
args: [
{
type: neologin.Constants.ArgumentDataType.INTEGER,
value: '10'
}
],
}
],
fee: '0.001',
network: 'TestNet',
broadcastOverride: false,
txHashAttributes: [
{
type: neologin.Constants.ArgumentDataType.BOOLEAN,
value: true,
txAttrUsage: 'Hash1'
}
]
})
.then(({txid, nodeUrl}) => {
console.log('Invoke transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type, description, data}) => {
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;
}
});
Example Response
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
Invoke Multi functions the same as Invoke, but accepts inputs to execute multiple invokes in the same transaction.
Input arguments
Parameter | Type | Description |
---|---|---|
fee | String? | If 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 | String | Network alias to submit this request to. |
assetIntentOverrides | AssetIntentOverrides | Used to specify the exact UTXO's to use for attached assets. If this is provided fee and attachedAssets will be ignored |
invokeArgs | InvokeArguments[] | Array of contract invoke inputs |
broadcastOverride | Boolean? | If this flag is set to True, the wallet provider will return the signed transaction rather than broadcasting to a node. |
txHashAttributes | TxHashAttribute[]? | Optional list of tx attribute hash values to be added |
InvokeArguments
Parameter | Type | Description |
---|---|---|
scriptHash | String | The script hash of the contract that you wish to invoke |
operation | String | The operation on the smart contract that you wish to call. This can be fetched from the contract ABI |
args | Argument[] | 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 | Boolean? | Adds the instruction to invoke the contract verifican trigger |
Argument
Parameter | Type | Description |
---|---|---|
type | String | The type of the argument with you are using |
value | String | String representation of the argument which you are using |
TxHashAttribute
Parameter | Type | Description |
---|---|---|
type | String | The type of the argument with you are using |
value | String | String representation of the argument which you are using |
txAttrUsage | String | Attribute usage value |
AttachedAssets
Parameter | Type | Description |
---|---|---|
NEO | String? | The amount of NEO to attach to the contract invocation |
GAS | String? | The amount of GAS to attach to the contract invocation |
AssetIntentOverrides
Parameter | Type | Description |
---|---|---|
inputs | AssetInput[] | A list of UTXO inputs to use for this transaction |
outputs | AssetOutput[] | A list of UTXO outputs to use for this transaction |
AssetInput
Parameter | Type | Description |
---|---|---|
txid | String | Transaction id to be used as input |
index | String | Index of the UTXO, can be found from transaction details |
AssetOutput
Parameter | Type | Description |
---|---|---|
asset | String | A list of UTXO inputs to use for this transaction |
address | String | A list of UTXO outputs to use for this transaction |
value | String | String 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.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
nodeURL | String | The node to which the transaction was submitted to |
In the case where the "broadcastOverride" input argument is set to True.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
signedTx | String | The serialized signed transaction |
Set script transaction attribute 0x20 according to the following conditions:
- If triggerContractVerification is set to true, set 0x20 to scriptHash of the contract being invoked
- If there is no fee, attachedAssets, or 'assetIntentOverrides', set 0x20 to the users address
- If there are assetIntentOverrides but none of the inputs belong to the user address, set 0x20 to user address
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occured |
description | String? | A description of the error which has occured |
data | String? | Any raw data associated with the error |
signMessage
neologin.signMessage({
message: 'Hello World!',
})
.then((signedMessage: 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(({type: string, description: string, data: any}) => {
switch(type) {
case UNKNOWN_ERROR:
console.log(description);
break;
}
});
neologin.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(({type, description, data}) => {
switch(type) {
case "UNKNOWN_ERROR":
console.log(description);
break;
}
});
Example Response
{
publicKey: '0241392007396d6ef96159f047967c5a61f1af0871ecf9dc82afbedb68afbb949a',
data: '0147fb89d0999e9d8a90edacfa26152fe695ec8b3770dcad522048297ab903822e12472364e254ff2e088fc3ebb641cc24722c563ff679bb1d1623d08bd5863d0d',
salt: '058b9e03e7154e4db1e489c99256b7fa',
message: 'Hello World!',
}
{
publicKey: '0241392007396d6ef96159f047967c5a61f1af0871ecf9dc82afbedb68afbb949a',
data: '0147fb89d0999e9d8a90edacfa26152fe695ec8b3770dcad522048297ab903822e12472364e254ff2e088fc3ebb641cc24722c563ff679bb1d1623d08bd5863d0d',
salt: '058b9e03e7154e4db1e489c99256b7fa',
message: 'Hello World!',
}
Signs a provided messaged with an account selected by user. A salt prefix is added to the input string, and provided as a part of the data while signing. In the example, the signed value would be 058b9e03e7154e4db1e489c99256b7faHello World!
.
Input Arguments
Parameter | Type | Description |
---|---|---|
message | String | The message to sign |
Success Response
Parameter | Type | Description |
---|---|---|
publicKey | String | The public key used to sign message |
data | String | The signed data |
salt | String | The salt prefix added to the original message before signing |
message | String | The original message |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occurred |
description | String | A description of the error which has occurred |
data | String? | Any raw data associated with the error |
deploy
neologin.deploy({
network: 'TestNet',
name: 'Hello world!',
version: 'v0.0.1',
author: 'John Smith',
email: 'neo@neologin.io',
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(({type: string, description: string, data: any}) => {
switch(type) {
case UNKNOWN_ERROR:
console.log(description);
break;
}
});
neologin.deploy({
network: 'TestNet',
name: 'Hello world!',
version: 'v0.0.1',
author: 'John Smith',
email: 'neo@neologin.io',
description: 'My first contract.',
needsStorage: true,
dynamicInvoke: false,
isPayable: false,
parameterList: '0710',
returnType: '05',
code: '53c56b0d57616b652075702c204e454f21680f4e656f2e52756e74696d652e4c6f6761006c7566',
networkFee: '0.001',
})
.then(({txid, nodeUrl}) => {
console.log('Deploy transaction success!');
console.log('Transaction ID: ' + txid);
console.log('RPC node URL: ' + nodeUrl);
})
.catch(({type, description, data}) => {
switch(type) {
case "UNKNOWN_ERROR":
console.log(description);
break;
}
});
Example Response
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
{
txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
nodeUrl: 'http://seed7.ngd.network:10332',
}
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
Parameter | Type | Description |
---|---|---|
network | String | Network alias to submit this request to. |
name | String | The name of the contract to be deployed |
version | String | The version of the contract to be deployed |
author | String | The author of the contract to be deployed |
String | The email of the contract to be deployed | |
description | String | The description of the contract to be deployed |
needsStorage | Boolean | Whether or not the contract will use storage |
dynamicInvoke | Boolean | Whether or not the contract will be performing dynamic invocations of other smart contracts |
isPayable | Boolean | Whether or not the contract will be able to accept native assets |
parameterList | String | The list of input argument types for the Main function on the contract. https://docs.neo.org/en-us/sc/Parameter.html |
returnType | String | The list of output returnType argument types. https://docs.neo.org/en-us/sc/Parameter.html |
code | String | The hex of the compiled smart contract avm |
networkFee | String | The network fee to execute the transaction, in addition to the deploy fee which will be added automatically |
broadcastOverride | Boolean? | If this flag is set to True, the wallet provider will return the signed transaction rather than broadcasting to a node. |
Success Response
In the case where the "broadcastOverride" input argument is not set, or set to false.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
nodeURL | String | The node to which the transaction was submitted to |
In the case where the "broadcastOverride" input argument is set to True.
Parameter | Type | Description |
---|---|---|
txid | String | The transaction id of the send request which can be queried on the blockchain |
signedTx | String | The serialized signed transaction |
Error Response
Parameter | Type | Description |
---|---|---|
type | String | The type of error which has occurred |
description | String | A description of the error which has occurred |
data | String? | Any raw data associated with the error |
Event Methods
addEventListener
neologin.addEventListener(neologin.Constants.EventName.ACCOUNT_CHANGED, data => {
console.log(`Connected Account: ${data.address}`);
});
neologin.addEventListener(neologin.Constants.EventName.ACCOUNT_CHANGED, data => {
console.log(`Connected Account: ${data.address}`);
});
Method is used to add a callback method to be triggered on a specified event.
removeEventListener
neologin.removeEventListener(neologin.Constants.EventName.ACCOUNT_CHANGED);
neologin.removeEventListener(neologin.Constants.EventName.ACCOUNT_CHANGED);
Method is to remove existing callback event listeners.
Events
Events are a way for the wallet to asynchronously communicate to the DAPP the ocurrence of certain changes on the state of the blockchain that might be relevant for the DAPP.
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 immediately 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.
Parameter | Type | Description |
---|---|---|
name | String | The name of the wallet provider |
website | String | The website of the wallet provider |
version | String | The version of the dAPI that the the wallet supports |
compatibility | String[] | A list of all applicable NEPs which the wallet provider supports |
extra | Object | Provider specific attributes |
extra
Parameter | Type | Description |
---|---|---|
theme | string | UI theme of the provider |
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.
Parameter | Type | Description |
---|---|---|
address | String | Address of the new account |
label | String | A label the users has set to identify their wallet |
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
.
Parameter | Type | Description |
---|---|---|
address | String | Address of the new account |
label | String | A label the users has set to identify their wallet |
DISCONNECTED
On a DISCONNECTED event, the account connected to the dapp via the dapi provider has been disconnected (logged out).
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.
Parameter | Type | Description |
---|---|---|
networks | String[] | A list of all networks which this wallet provider allows access to |
defaultNetwork | String | Network the wallet is currently set to |
BLOCK_HEIGHT_CHANGED
On a BLOCK_HEIGHT_CHANGED event, the block has advanced to the next.
Parameter | Type | Description |
---|---|---|
network | String | Network of the block which changed |
blockHeight | Number | Height of the new block |
blockTime | Number | Timestamp of the new block |
blockHash | String | Hash of the new block |
tx | String[] | List of transaction ids executed in the new block |
TRANSACTION_CONFIRMED
On a TRANSACTION_CONFIRMED event, a previously broadcast transaction via the dapi has been confirmed by the blockchain.
Parameter | Type | Description |
---|---|---|
txid | String | Transaction id which was confirmed on chain |
blockHeight | Number | Height of the new block |
blockTime | Number | Timestamp of the new block |
Errors
The NEO dAPI will provide these basic errors. It is up to the wallet provider to provide additional information if they choose:
Error Type | Meaning |
---|---|
NO_PROVIDER | Could not find an instance of the dAPI in the webpage |
CONNECTION_DENIED | The dAPI provider refused to process this request |
RPC_ERROR | An RPC error occured when submitting the request |
MALFORMED_INPUT | An input such as the address is not a valid NEO address |
CANCELED | The user cancels, or refuses the dapps request |
INSUFFICIENT_FUNDS | The user does not have a sufficient balance to perform the requested action |
Utils
These are a collection of commonly used utilities for parsing responses from smart contracts.
hex2str
const hex2strInput = '68656c6c6f';
const hex2strExpected = 'hello';
const hex2strResult = neologin.utils.hex2str(hex2strInput);
console.log('hex2str', hex2strExpected === hex2strResult);
const hex2strInput = '68656c6c6f';
const hex2strExpected = 'hello';
const hex2strResult = neologin.utils.hex2str(hex2strInput);
console.log('hex2str', hex2strExpected === hex2strResult);
Converts a hex string to a string.
str2hex
const str2hexInput = 'hello';
const str2hexExpected = '68656c6c6f';
const str2hexResult = neologin.utils.str2hex(str2hexInput);
console.log('str2hex', str2hexExpected === str2hexResult);
const str2hexInput = 'hello';
const str2hexExpected = '68656c6c6f';
const str2hexResult = neologin.utils.str2hex(str2hexInput);
console.log('str2hex', str2hexExpected === str2hexResult);
Converts a string to a hex string.
hex2int
const hex2intInput = '00e1f505';
const hex2intExpected = 100000000;
const hex2intResult = neologin.utils.hex2int(hex2intInput);
console.log('hex2int', hex2intExpected === hex2intResult);
const hex2intInput = '00e1f505';
const hex2intExpected = 100000000;
const hex2intResult = neologin.utils.hex2int(hex2intInput);
console.log('hex2int', hex2intExpected === hex2intResult);
Converts a hex string to an integer.
int2hex
const int2hexInput = 100000000;
const int2hexExpected = '00e1f505';
const int2hexResult = neologin.utils.int2hex(int2hexInput);
console.log('int2hex', int2hexExpected === int2hexResult);
const int2hexInput = 100000000;
const int2hexExpected = '00e1f505';
const int2hexResult = neologin.utils.int2hex(int2hexInput);
console.log('int2hex', int2hexExpected === int2hexResult);
Converts an integer to a hex string.
reverseHex
const reverseHexInput = 'bc99b2a477e28581b2fd04249ba27599ebd736d3';
const reverseHexExpected = 'd336d7eb9975a29b2404fdb28185e277a4b299bc';
const reverseHexResult = neologin.utils.reverseHex(reverseHexInput);
console.log('reverseHex', reverseHexExpected === reverseHexResult);
const reverseHexInput = 'bc99b2a477e28581b2fd04249ba27599ebd736d3';
const reverseHexExpected = 'd336d7eb9975a29b2404fdb28185e277a4b299bc';
const reverseHexResult = neologin.utils.reverseHex(reverseHexInput);
console.log('reverseHex', reverseHexExpected === reverseHexResult);
Converts the endian of a hex string, big to little, or little to big.
address2scriptHash
const address2scriptHashInput = 'Ab2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU';
const address2scriptHashExpected = 'd336d7eb9975a29b2404fdb28185e277a4b299bc';
const address2scriptHashResult = neologin.utils.address2scriptHash(address2scriptHashInput);
console.log('address2scriptHash', address2scriptHashExpected === address2scriptHashResult);
const address2scriptHashInput = 'Ab2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU';
const address2scriptHashExpected = 'd336d7eb9975a29b2404fdb28185e277a4b299bc';
const address2scriptHashResult = neologin.utils.address2scriptHash(address2scriptHashInput);
console.log('address2scriptHash', address2scriptHashExpected === address2scriptHashResult);
Converts an address to a script hash.
scriptHash2address
const scriptHash2addressInput = 'd336d7eb9975a29b2404fdb28185e277a4b299bc';
const scriptHash2addressExpected = 'Ab2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU';
const scriptHash2addressResult = neologin.utils.scriptHash2address(scriptHash2addressInput);
console.log('scriptHash2address', scriptHash2addressExpected === scriptHash2addressResult);
const scriptHash2addressInput = 'd336d7eb9975a29b2404fdb28185e277a4b299bc';
const scriptHash2addressExpected = 'Ab2fvZdmnM4HwDgVbdBrbTLz1wK5TcEyhU';
const scriptHash2addressResult = neologin.utils.scriptHash2address(scriptHash2addressInput);
console.log('scriptHash2address', scriptHash2addressExpected === scriptHash2addressResult);
Converts a script hash to an address.