NAV Navbar

NEO Dapi introduction

NEO Dapi is a generic Dapi standard in the NEO environment that is maintained by NEL in conjunction with O3 and other NEO community members.

The programs that provide Dapi come in a variety of forms, including NEL's Teemo Chrome extension wallet, O3 wallet and other forms.

We do our best to implement the overall consistencey and compatibility of the Dapis, but each Dapi provider (program) varies slightly depending on its own characteristics.

Here we will provide the developer Dapi calling methods (part of which are only related to the NEL's Teemo Chrome extension wallet).

Teemo extension wallet

Teemo is a Chrome extension wallet developed by NEL. The wallet aims to minimize Dapp developers'time spent on the front-end, so that Dapp developers could focus on Dapp development itself, rather than on interactions with NEO.

Another feature of the extension wallet is security.The Teemo wallet protects the user's wallet private key inside the extension, which Dapp cannot access directly. And user authorization is required when signing a signature(sending a transaction) using a private key each time. In fact,the user's address is invisible to the unauthorized Dapp. In this way, users only need to trust and use one and the same wallet and can safely try any novel Dapps without worrying about security issues

Teemo Resources

Teemo Github

Teemo installation and development

Installation and experience

Development Version

Clone the project

Git clone https://github.com/NewEconoLab/TeemoWallet.git

Open Chrome (latest version) Chrome menu - more tools - extensions

Switch to developer mode

Click on "Load unzipped extensions" - select the **TeemoWallet\dist folder

You can configure the **TeemoWallet\test folder as a website (such as http://localhost/).You Can also browse https://teemo.nel.group/test/ ,Free from deploying

Open this website and test the events and all the methods. This website page is also a development example.

Stable Version

Github Release

Download the release ZIP package and unzip it. The other steps are the same as the development version.

Start development

window.addEventListener('Teemo.NEO.READY',(data:CustomEvent)=>{
    console.log("Teemo READY ");
    console.log(JSON.stringify(data.detail))

    const main = new Main();
    main.start();//After listening to this event, you can start the related method call of the plugin.
})

Teemo's Dapi does not need to reference any JS or NPM packages before calling. The JS code that interacts with Teemo is automatically injected into your page, but this injection may not always be done before your first Dapi call code.

In order to always interact with Teemo, we strongly recommend that the "Teemo.NEO.READY" event be captured first before any Dapi method is used. This event represents that the Teemo interaction JS has been injected into your page.

If you are developing with TS (TypeScript), you may also need to add https://github.com/NewEconoLab/TeemoWallet/blob/master/dist/js/inject.d.ts to your directory, which will help the tsc engine. Identify Dapi methods and types.

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

Teemo.NEO.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;
  }
});

Example Response

{
  "name": "TeemoWallet",
  "version": "0.1",
  "website": "nel.group",
  "compatibility": [
    "typescript",
    "javascript"
  ],
  "extra": {
    "theme": "",
    "currency": ""
  }
}

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

dapi.NEO.getNetworks()
.then(response => {
  const {
    networks,
    defaultNetwork,
  } = response.networks;

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

  console.log('Default network: ' + defaultNetwork);
  // eg. "TestNet"
})
.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;
  }
});

Example Response

{
  networks: ["TestNet", "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

Teemo.NEO.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;
  }
});

Example Response

{
  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

getBalance

Teemo.NEO.getBalance({
  params:{  
    "address": "ASBhJFN3XiDu38EdEQyMY3N2XwGh1gd5WW",  
    "assets": ["74f2dc36a68fdc4682034178eb2220729231db76"]
  },
  network: 'TestNet',
})
.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;
  }
});

Single Address with specific balances requested

// input
{
  params: {
    address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
    assets: ["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"]
  },
  network: 'TestNet',
}

// output
{
  AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
    {
      assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'GAS',
      amount: '0.00000233',
    }
  ],
}

Single Address with all balances requested

// input
{
  params: {
    address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
  },
  network: 'TestNet',
}

// output
{
  AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
    {
      assetID: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
      symbol: 'NEO',
      amount: '10',
    },
    {
      assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'GAS',
      amount: '777.0001',
    },
    {
      assetID: '74f2dc36a68fdc4682034178eb2220729231db76',
      symbol: 'CGAS',
      amount: '0.00000233',
    },
    {
      assetID: 'fc732edee1efdf968c23c20a9628eaa5a6ccb934',
      symbol: 'NNC',
      amount: '2000',
    }
  ]
}

Multiple address balance queries

// input
{
  params: [
    {
      address: 'AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru',
    },
    {
      address: 'AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ',
      asset: ["602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"],
    },
  ],
  network: 'TestNet',
}

// output
{
  AeysVbKWiLSuSDhg7DTzUdDyYYKfgjojru: [
    {
      assetID: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
      symbol: 'NEO',
      amount: '10',
    },
    {
      assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'GAS',
      amount: '777.0001',
    },
    {
      assetID: '74f2dc36a68fdc4682034178eb2220729231db76',
      symbol: 'CGAS',
      amount: '0.00000233',
    },
    {
      assetID: 'fc732edee1efdf968c23c20a9628eaa5a6ccb934',
      symbol: 'NNC',
      amount: '2000',
    }
  ],
  AbKNY45nRDy6B65YPVz1B6YXiTnzRqU2uQ: [
    {
      assetID: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
      symbol: 'GAS',
      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 TestNet only) to query the balance for
fetchUTXO? boolean The response will fetch NEO and GAS UTXO's if this attribute is true(Teemo Not yet supported)

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(Teemo Not yet supported)

UTXO (Teemo Not yet supported)

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

Teemo.NEO.getStorage({
    "scriptHash":"03febccf81ac85e3d795bc5cbd4e84e907812aa3",
    "key":"5065746572",
    "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;
  }
});

Example Response

{
  result: '4c696e'
}

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

Teemo.NEO.invokeRead({
  scriptHash: '505663a29d83663a838eee091249abd167e928f5',
  operation: 'calculatorAdd',
  arguments: [
    {
      type: 'integer',
      value: 2
    },
    {
      type: 'integer',
      value: 10
    }
  ],
  network: 'TestNet'
})
.then((result: Object) => {
  console.log('Read invocation result: ' + JSON.stringigy(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;
  }
});

Example Response

{
  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 to "TestNet"

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

invokeReadGroup

Teemo.NEO.invokeReadGroup({
  "group":[
      {
          "scriptHash": "fc732edee1efdf968c23c20a9628eaa5a6ccb934",
          "operation": "totalSupply",
          "arguments": [],
          "network": "TestNet"
      },
      {
          "scriptHash": "fc732edee1efdf968c23c20a9628eaa5a6ccb934",
          "operation": "name",
          "arguments": [],
          "network": "TestNet"
      },
      {
          "scriptHash": "fc732edee1efdf968c23c20a9628eaa5a6ccb934",
          "operation": "symbol",
          "arguments":[],
          "network": "TestNet"
      },
      {
          "scriptHash": "fc732edee1efdf968c23c20a9628eaa5a6ccb934",
          "operation": "decimals",
          "arguments": [],
          "network": "TestNet"
      }
  ]
})
.then((result: Object) => {
  console.log('Read invocation result: ' + JSON.stringigy(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;
  }
});

Example Response

{
  "script": '8h89fh398f42f.....89hf2894hf9834',
  "state": "HALT, BREAK",
  "gas_consumed": "0.648",
  "stack": [
    {
      "type": "ByteArray",
      "value": "00e8764817"
    },
    {
      "type": "ByteArray",
      "value": "4e454f204e616d6520437265646974"
    },
    {
      "type": "ByteArray",
      "value": "4e4e43"
    },
    {
      "type": "Integer",
      "value": "2"
    }
  ]
}

Execute a contract invocation group in read-only mode.You can get multiple information in the contract at one time, such as getting all the basic information of NEP5 at one time.

输入参数

Parameter Type Description
group invokeRead[] An array of invokeRead input arguments

invokeRead

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 to "TestNet"

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

成功的返回

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

Write Methods

Write methods will alter the state on the blockchain, and require a user signature.

send

Teemo.NEO.send({
  fromAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
  toAddress: 'ATaWxfUAiBcQixNPq6TvKHEHPQum9bx79d',
  asset: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
  amount: '0.0001',
  remark: 'Hash puppy clothing purchase. Invoice#abc123',
  fee: '0.0001',
  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;
  }
});

Example Response

{
  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.

Success Response

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

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

Teemo.NEO.invoke({
  "scriptHash":"74f2dc36a68fdc4682034178eb2220729231db76",
  "operation":"transfer",
  "arguments":[
      {
        "type":"Address",
        "value":"AHDV7M54NHukq8f76QQtBTbrCqKJrBH9UF"
      },
      {
        "type":"Address",
        "value":"AbU7BUQHW9sa69pTac7pPR3cq4gQHYC1DH"
      },
      {
        "type":"Integer",
        "value":"100000"
      }
  ],
  "fee":"0.001",
  "description":"NNC transfer",
  "network":"TestNet"
})
.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;
  }
});

Example Response

{
  txid: 'ed54fb38dff371be6e3f96e4880405758c07fe6dd1295eb136fe15f311e9ff77',
  nodeUrl: 'http://seed7.ngd.network:10332',
}:

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

Input arguments

Parameter 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
description String For a brief description of the operation, the description will be displayed on the confirmation page of the wallet to help the user understand (the description will not be stored 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.
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(Teemo Not yet supported)
triggerContractVerification Boolean? Adds the instruction to invoke the contract verifican trigger(Teemo Not yet supported)

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

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(Teemo Not yet supported)

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(Teemo Not yet supported)

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(Teemo Not yet supported)

Parameter Type Description
asset String asset ID
value String asset amount
address String The address to where the user should send their funds

Success Response

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

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

InvokeGroup

Teemo.NEO.invokeGroup({
  "merge": true,
  "group": [
    {
      "scriptHash": "74f2dc36a68fdc4682034178eb2220729231db76",
      "operation": "transfer",
      "arguments": [
        {
          "type": "Address",
          "value": "AHDV7M54NHukq8f76QQtBTbrCqKJrBH9UF"
        },
        {
          "type": "Address",
          "value": "AbU7BUQHW9sa69pTac7pPR3cq4gQHYC1DH"
        },
        {
          "type": "Integer",
          "value": "100000"
        }
      ],
      "description": "NNC transfer",
      "fee": "0",
      "network": "TestNet"
    },
    {
      "scriptHash": "00d00d0ac467a5b7b2ad04052de154bb9fe8c2ff",
      "operation": "setmoneyin",
      "arguments": [
        {
          "type": "Hook_Txid",
          "value": 0
        },
        {
          "type": "Hash160",
          "value": "74f2dc36a68fdc4682034178eb2220729231db76"
        }
      ],
      "description": "Recharge confirmation",
      "fee": "0.001",
      "network": "TestNet"
    }
  ]
})
.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;
  }
});

Example Response

//merge=true
[
  {
    "txid": "0cba61b8779f3343ff39fbecee596395b06490bce7245412ee788c8620813b63",
    "nodeUrl": "https://api.nel.group/api"
  }
]

//merge=false
[
  {
    "txid": "045e1612d2dd2edf29d6bb45657329bacc299072655691f9cc0f486fb649a30d",
    "nodeUrl": "https://api.nel.group/api"
  },
  {
    "txid": "4747e2b50cbd853c13b24e67d59225816f152a13ee281345751eb51bf811355c",
    "nodeUrl": "https://api.nel.group/api"
  }
]

This method constructs a contract to call a transaction group and sends it, and has two modes: merge mode and non-merge mode:

Merge mode: The wallet will construct each Invoke contract call operation to be entered in order into a single contract invoke transaction body, enabling multiple contract methods to be executed in one transaction. This mode is suitable for small transactions (less costly GAS) for multiple different contracts to be merged into one transaction. Regarding the merge mode, it needs to be paid attention to whether the GAS consumption of the script execution will surpass 10GAS after the merge. In the merge mode, the total fee of the transaction is the sum of the fees in each Invoke element.

Non-merge mode: The wallet will construct each Inovke contract call operation to be entered in order as multiple independent contract invoke transaction bodies. Only after the previous transaction is confirmed as consensus (confirmed on the blockchain), the next transaction will be sent. This mode is suitable for a series of associated contract operations, and is automatically lined up and executed in a logical relationship.

Hook_Txid: This type is specific to the InvokeGroup method, which means that the txid of the previous transaction is used as the input parameter of the next transaction, and both the merge mode and the non-merge mode are supported. However, there are the following restrictions:

  1. Hook_Txid cannot appear in the first Invoke element
  2. The value of Hook_Txid must be 0, meaning that only the txid of the first transaction can be taken.
  3. When using Hook_Txid, you can only define up to two Invoke elements in the merge mode.

Input arguments

Parameter Type Description
merge Boolean Choose to use merge mode
group Invoke[] A list of Invoke

Invoke

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
description String For a brief description of the operation, the description will be displayed on the confirmation page of the wallet to help the user understand (the description will not be stored 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.
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(Teemo Not yet supported)
triggerContractVerification Boolean? Adds the instruction to invoke the contract verifican trigger(Teemo Not yet supported)
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

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

Success Response

Parameter Type Description
[] Array A List of Invoke Response

Invoke Response

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

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

Events

Events are a way for the wallet to asynchronously with the DAPP when certain changes occur to the state of the wallet that might be relevant for the

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.

Full event name

Teemo.NEO.READY

Event data

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.

Full event name

Teemo.NEO.ACCOUNT_CHANGED

Event data

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.

Full event name

Teemo.NEO.CONNECTED

Event data

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).

Full event name

Teemo.NEO.DISCONNECTED

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.

Full event name

Teemo.NEO.NETWORK_CHANGED

Event data

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

Event Methods

addEventListener

window.addEventListener('Teemo.NEO.READY',(data:CustomEvent)=>{
    console.log("Teemo READY ");
    console.log(JSON.stringify(data.detail))

    const main = new Main();
    main.start();//After listening to this event, you can start the related method call of the plugin.
})

In the Dapp page, the standard JS event acquisition method window.addEventListener is used to obtain the custom event and event data of the wallet, and the corresponding logic is processed after receiving the event and data.

Note:that events are asynchronous.

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