Hyperion HTTP API Javascript library
npm install @proton/hyperionUsing Yarn:
``bash`
yarn add @proton/hyperion
or using NPM:
`bash`
npm install --save @proton/hyperion
CommonJS
`js
const { JsonRpc } = require("@proton/hyperion")
const fetch = require("isomorphic-fetch")
const endpoint = "https://eos.hyperion.eosrio.io"
const rpc = new JsonRpc(endpoint, { fetch })
`
TypeScript
`ts
import { JsonRpc } from "@proton/hyperion"
import fetch from "isomorphic-fetch"
const endpoint = "https://eos.hyperion.eosrio.io"
const rpc = new JsonRpc(endpoint, { fetch })
`
`bash`
HYPERION_ENDPOINT=
`bashState
/v2/state/alive
/v2/state/get_key_accounts
/v2/state/get_tokens
/v2/state/get_voters
/v2/state/get_links
API
#### Table of Contents
- JsonRpc
- Parameters
- Examples
- alive
- Examples
- get_abi_snapshot
- Parameters
- Examples
- get_voters
- Parameters
- Examples
- get_links
- Parameters
- Examples
- get_proposals
- Parameters
- get_actions
- Parameters
- Examples
- get_created_accounts
- Parameters
- Examples
- get_creator
- Parameters
- Examples
- get_deltas
- Parameters
- Examples
- get_table_state
- Parameters
- Examples
- get_key_accounts
- Parameters
- Examples
- get_tokens
- Parameters
- Examples
- get_transaction
- Parameters
- Examples
- JsonRpc
- alive
- Examples
- get_abi_snapshot
- Parameters
- Examples
- get_voters
- Parameters
- Examples
- get_links
- Parameters
- Examples
- get_proposals
- Parameters
- get_actions
- Parameters
- Examples
- get_created_accounts
- Parameters
- Examples
- get_creator
- Parameters
- Examples
- get_deltas
- Parameters
- Examples
- get_table_state
- Parameters
- Examples
- get_key_accounts
- Parameters
- Examples
- get_tokens
- Parameters
- Examples
- get_transaction
- Parameters
- Examples
- RpcError
- RpcStatusError
$3
JsonRpc
#### Parameters
-
endpoint string hyperion endpoint#### Examples
`javascript
const endpoint = "https://br.eosrio.io"
const rpc = new JsonRpc(endpoint, { fetch })
`#### alive
simple server healthcheck
##### Examples
`javascript
const response = await rpc.alive();
console.log(response);
// => {"status": "OK"}
`Returns Promise<Alive> alive
#### get_abi_snapshot
GET /v2/history/get_abi_snapshot
fetch contract abi at specific block
##### Parameters
-
contract string contract account
- block
- number number target block##### Examples
`javascript
const response = await rpc.get_abi_snapshot("eosio", 200);
console.log(response.version);
// => "eosio::abi/1.0"for (const table of response.tables) {
console.log(table);
// => { name: 'producers', index_type: 'i64', key_names: [ 'owner' ], key_types: [ 'uint64' ], type: 'producer_info' }
}
`Returns Promise<GetAbiSnapshot> abi snapshot
#### get_voters
get voters
##### Parameters
-
options object Optional parameters (optional, default {})
- options.producer string? filter by voted producer (comma separated)
- options.proxy boolean? true or false
- options.skip number? skip [n] actions (pagination)
- options.limit number? limit of [n] actions per page##### Examples
`javascript
const response = await rpc.get_voters({ producer: "eoscafeblock", limit: 100 });
console.log(response.voters);
// => "[{
// "account": "guzdkmrtgage",
// "weight": 78434695236505280,
// "last_vote": 64804768
// }]"
`Returns Promise<GetVoters> voters
#### get_links
get voters
##### Parameters
-
account string? account to get links for##### Examples
`javascript
const response = await rpc.get_links("eoscafeblock");
console.log(response.links);
// => "[{
"block_num":26088072,
"timestamp":"2019-11-22T23:17:42.000",
"account":"eosriobrazil",
"permission":"claim2",
"code":"eosio",
"action":"voteproducer"
}]"
`Returns Promise<GetLinks> links
#### get_proposals
get proposals
##### Parameters
-
options object Optional parameters (optional, default {})
- options.proposer string? filter by proposer
- options.proposal string? filter by proposal name
- options.account string? filter by either requested or provided account
- options.requested string? filter by requested account
- options.provided string? filter by provided account
- options.track string? total results to track (count) [number or true]
- options.skip number? skip [n] actions (pagination)
- options.limit number? limit of [n] actions per page
- account string? account to get proposals forReturns Promise<GetProposals> proposals
#### get_actions
get actions based on notified account
##### Parameters
-
account string notified account
- options object Optional parameters (optional, default {})
- options.filter string? code::name filter
- options.skip number? skip [n] actions (pagination)
- options.limit number? limit of [n] actions per page
- options.sort string? sort direction
- options.after string? filter after specified date (ISO8601)
- options.before string? filter before specified date (ISO8601)
- options.transfer_to string? transfer filter to
- options.transfer_from string? transfer filter from
- options.transfer_symbol string? transfer filter symbol
- options.act_name string? act name
- options.act_account string? act account##### Examples
`javascript
const response = await rpc.get_actions("eoscafeblock", {
filter: "eosio.token:*",
skip: 100,
limit: 100,
});for (const action of response.actions) {
console.log(action);
// => { act: { account: 'eosio.token', name: 'transfer', ... } }
}
`Returns Promise<GetActions> get actions
#### get_created_accounts
GET /v2/history/get_created_accounts
get created accounts
##### Parameters
-
account string created account##### Examples
`javascript
const response = await rpc.get_created_accounts("eosnationftw");
console.log(response);
// => {"accounts": [{"name":"eosnationdsp","trx_id":"728d4a4da36a98d9048080461dacaf975ad083e8158ef84edea60cc755ab2c1a","timestamp":"2019-02-28T22:36:45.000"}, ... ]}
`Returns Promise<GetCreatedAccounts> get creator
#### get_creator
get creator
##### Parameters
-
account string created account##### Examples
`javascript
const response = await rpc.get_creator("eosnationftw");
console.log(response);
// => { account: 'eosnationftw', creator: 'gyztcmrvgqge', timestamp: '2018-06-10T13:06:43.500', ... }
`Returns Promise<GetCreator> get creator
#### get_deltas
get deltas
##### Parameters
-
code string contract account
- scope string table scope
- table string table name
- payer string payer account
- options ##### Examples
`javascript
const response = await rpc.get_deltas("eosio.token", "eosnationftw", "accounts", "eosnationftw");
console.log(response);
// => { "query_time": 19, "total": { "value": 486, "relation": "eq" }, "deltas": [ ... ] }
`Returns Promise<GetDeltas> get deltas
#### get_table_state
[GET /v2/history/get_table_state]\(
get table state
##### Parameters
-
code string contract account
- table string table name
- block_num string target block
- after_key string last key for pagination##### Examples
`javascript
const response = await rpc.get_table_state("eosio.token", "stat", "1000", "");
console.log(response);
// => { "query_time": 19, "code": "eosio.token", "table": "stat", "block_num": 1000, "next_key": "........ehbo5-5459781",, "results": [ ... ] }
`Returns Promise<GetTableState> get table state
#### get_key_accounts
get account by public key
##### Parameters
-
public_key string Contract account targeted by the action.##### Examples
`javascript
const response = await rpc.get_key_accounts("EOS5Mto3Km6BCVxowb6LkkFaT9oaUwLVgswgcxvY4Qgc4rhHry4Tv");
console.log(response.account_names);
// => [ 'eoscafeblock' ]
`Returns Promise<GetKeyAccounts> key accounts
#### get_tokens
get tokens
##### Parameters
-
account string account##### Examples
`javascript
const response = await rpc.get_tokens("eosnationftw");
for (const token of response.tokens) {
console.log(token);
// => { symbol: 'ZOS', precision: 4, amount: 140, contract: 'zosdiscounts' }
}
`Returns Promise<GetTokens> get tokens
#### get_transaction
GET /v2/history/get_transaction
get all actions belonging to the same transaction
##### Parameters
-
id string transaction id##### Examples
`javascript
const response = await rpc.get_transaction("42dacd5722001b734be46a2140917e06cd21d42425f927f506c07b4388b07f62");
for (const action of response.actions) {
console.log(action);
// => { act: { account: 'eosio', name: 'buyrambytes', ... }}
}
`Returns Promise<GetTransaction> transaction
$3
#### alive
simple server healthcheck
##### Examples
`javascript
const response = await rpc.alive();
console.log(response);
// => {"status": "OK"}
`Returns Promise<Alive> alive
#### get_abi_snapshot
GET /v2/history/get_abi_snapshot
fetch contract abi at specific block
##### Parameters
-
contract string contract account
- block
- number number target block##### Examples
`javascript
const response = await rpc.get_abi_snapshot("eosio", 200);
console.log(response.version);
// => "eosio::abi/1.0"for (const table of response.tables) {
console.log(table);
// => { name: 'producers', index_type: 'i64', key_names: [ 'owner' ], key_types: [ 'uint64' ], type: 'producer_info' }
}
`Returns Promise<GetAbiSnapshot> abi snapshot
#### get_voters
get voters
##### Parameters
-
options object Optional parameters (optional, default {})
- options.producer string? filter by voted producer (comma separated)
- options.proxy boolean? true or false
- options.skip number? skip [n] actions (pagination)
- options.limit number? limit of [n] actions per page##### Examples
`javascript
const response = await rpc.get_voters({ producer: "eoscafeblock", limit: 100 });
console.log(response.voters);
// => "[{
// "account": "guzdkmrtgage",
// "weight": 78434695236505280,
// "last_vote": 64804768
// }]"
`Returns Promise<GetVoters> voters
#### get_links
get voters
##### Parameters
-
account string? account to get links for##### Examples
`javascript
const response = await rpc.get_links("eoscafeblock");
console.log(response.links);
// => "[{
"block_num":26088072,
"timestamp":"2019-11-22T23:17:42.000",
"account":"eosriobrazil",
"permission":"claim2",
"code":"eosio",
"action":"voteproducer"
}]"
`Returns Promise<GetLinks> links
#### get_proposals
get proposals
##### Parameters
-
options object Optional parameters (optional, default {})
- options.proposer string? filter by proposer
- options.proposal string? filter by proposal name
- options.account string? filter by either requested or provided account
- options.requested string? filter by requested account
- options.provided string? filter by provided account
- options.track string? total results to track (count) [number or true]
- options.skip number? skip [n] actions (pagination)
- options.limit number? limit of [n] actions per page
- account string? account to get proposals forReturns Promise<GetProposals> proposals
#### get_actions
get actions based on notified account
##### Parameters
-
account string notified account
- options object Optional parameters (optional, default {})
- options.filter string? code::name filter
- options.skip number? skip [n] actions (pagination)
- options.limit number? limit of [n] actions per page
- options.sort string? sort direction
- options.after string? filter after specified date (ISO8601)
- options.before string? filter before specified date (ISO8601)
- options.transfer_to string? transfer filter to
- options.transfer_from string? transfer filter from
- options.transfer_symbol string? transfer filter symbol
- options.act_name string? act name
- options.act_account string? act account##### Examples
`javascript
const response = await rpc.get_actions("eoscafeblock", {
filter: "eosio.token:*",
skip: 100,
limit: 100,
});for (const action of response.actions) {
console.log(action);
// => { act: { account: 'eosio.token', name: 'transfer', ... } }
}
`Returns Promise<GetActions> get actions
#### get_created_accounts
GET /v2/history/get_created_accounts
get created accounts
##### Parameters
-
account string created account##### Examples
`javascript
const response = await rpc.get_created_accounts("eosnationftw");
console.log(response);
// => {"accounts": [{"name":"eosnationdsp","trx_id":"728d4a4da36a98d9048080461dacaf975ad083e8158ef84edea60cc755ab2c1a","timestamp":"2019-02-28T22:36:45.000"}, ... ]}
`Returns Promise<GetCreatedAccounts> get creator
#### get_creator
get creator
##### Parameters
-
account string created account##### Examples
`javascript
const response = await rpc.get_creator("eosnationftw");
console.log(response);
// => { account: 'eosnationftw', creator: 'gyztcmrvgqge', timestamp: '2018-06-10T13:06:43.500', ... }
`Returns Promise<GetCreator> get creator
#### get_deltas
get deltas
##### Parameters
-
code string contract account
- scope string table scope
- table string table name
- payer string payer account
- options ##### Examples
`javascript
const response = await rpc.get_deltas("eosio.token", "eosnationftw", "accounts", "eosnationftw");
console.log(response);
// => { "query_time": 19, "total": { "value": 486, "relation": "eq" }, "deltas": [ ... ] }
`Returns Promise<GetDeltas> get deltas
#### get_table_state
[GET /v2/history/get_table_state]\(
get table state
##### Parameters
-
code string contract account
- table string table name
- block_num string target block
- after_key string last key for pagination##### Examples
`javascript
const response = await rpc.get_table_state("eosio.token", "stat", "1000", "");
console.log(response);
// => { "query_time": 19, "code": "eosio.token", "table": "stat", "block_num": 1000, "next_key": "........ehbo5-5459781",, "results": [ ... ] }
`Returns Promise<GetTableState> get table state
#### get_key_accounts
get account by public key
##### Parameters
-
public_key string Contract account targeted by the action.##### Examples
`javascript
const response = await rpc.get_key_accounts("EOS5Mto3Km6BCVxowb6LkkFaT9oaUwLVgswgcxvY4Qgc4rhHry4Tv");
console.log(response.account_names);
// => [ 'eoscafeblock' ]
`Returns Promise<GetKeyAccounts> key accounts
#### get_tokens
get tokens
##### Parameters
-
account string account##### Examples
`javascript
const response = await rpc.get_tokens("eosnationftw");
for (const token of response.tokens) {
console.log(token);
// => { symbol: 'ZOS', precision: 4, amount: 140, contract: 'zosdiscounts' }
}
`Returns Promise<GetTokens> get tokens
#### get_transaction
GET /v2/history/get_transaction
get all actions belonging to the same transaction
##### Parameters
-
id string transaction id##### Examples
`javascript
const response = await rpc.get_transaction("42dacd5722001b734be46a2140917e06cd21d42425f927f506c07b4388b07f62");
for (const action of response.actions) {
console.log(action);
// => { act: { account: 'eosio', name: 'buyrambytes', ... }}
}
``Returns Promise<GetTransaction> transaction