transaction

Subscribes/Unsubscribes to a specific transaction.

Make sure you're connected.

Request

Every new transaction:

{"jsonrpc":"2.0","id":2,"method":"subscribe","params":["transaction"]}

Specific pending transaction:

{"jsonrpc":"2.0","id":2,"method":"subscribe","params":["transaction",{"hash":"0xf16c9f57349e6d094ceba3fadf612da3f68802d8fbf0dd06b52ed7da56b43a81"}]}
ParamTypeDescription
hash*stringThe transaction hash.

*required

Response

"result": {
  "blockchainId": "1c9c969065fcd1cf",
  "hash": "0xf16c9f57349e6d094ceba3fadf612da3f68802d8fbf0dd06b52ed7da56b43a81",
  "nonce": 2,
  "blockHash": "0xb21c6e17b4839be5c9b36b38a9fa3a5af7074e5c1a60e2a47eaf7f8ccef4e319",
  "blockNumber": 7555594,
  "transactionIndex": 117,
  "from": "0xba3be3e78ca2b6860160f6b9d54df7d58d92d19a",
  "functionCalls": null,
  "numFunctionCalls": null,
  "to": "0x689c56aef474df92d44a1b70850f808488f9769c",
  "tos": null,
  "value": 1337315988539598,
  "input": "0x",
  "gasPrice": 12600000000,
  "gas": 21000,
  "cumulativeGasUsed": 3011092,
  "gasUsed": 21000,
  "contractAddress": null,
  "status": "0x1",
  "numLogs": 0,
  "timestamp": 1555104943000,
  "timestampNanoseconds": 0,
  "optionalProperties": {
    "logsBloom": "0x000000...",
    "r": "0x6959460cc63670ad286f93f35333861a330969b025294a1f8ec83d8768b5f658",
    "s": "0x7b374450a5663156ca98e77eeb82c23dcf0296681942a44fa2e3565771b3590f",
    "v": 38
  }
}

Example

const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.web3api.io', {headers: {x-api-key:'<api_key>'}});

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['transaction', {hash: '0x6c80ebbe94deb54d84e7d22b0eac014275d3a2df97e5afa0e7bf408ae9bc8b22'}],
      id: 1,
    }));
});

ws.on('message', data => {
  console.log(JSON.stringify(JSON.parse(data), null, 2));
});

Supported Blockchains

BlockchainNetworkSlug (x-amberdata-blockchain-id)
BitcoinMainnetbitcoin-mainnet
Bitcoin CashMainnetbitcoin-abc-mainnet
EthereumMainnetethereum-mainnet
LitecoinMainnetlitecoin-mainnet
ZcashMainnetzcash-mainnet