Using Yarn:
yarn add @proton/hyperionor using NPM:
npm install --save @proton/hyperionCommonJS
const { JsonRpc } = require("@proton/hyperion")
const fetch = require("isomorphic-fetch")
const endpoint = "https://eos.hyperion.eosrio.io"
const rpc = new JsonRpc(endpoint, { fetch })TypeScript
import { JsonRpc } from "@proton/hyperion"
import fetch from "isomorphic-fetch"
const endpoint = "https://eos.hyperion.eosrio.io"
const rpc = new JsonRpc(endpoint, { fetch })HYPERION_ENDPOINT=<Enter Hyperion Endpoint> # "https://eos.hyperion.eosrio.io"# State
/v2/state/alive
/v2/state/get_key_accounts
/v2/state/get_tokens
/v2/state/get_voters
/v2/state/get_links
# History
/v2/history/get_abi_snapshot
/v2/history/get_actions
/v2/history/get_created_accounts
/v2/history/get_creator
/v2/history/get_deltas
/v2/history/get_transacted_accounts
/v2/history/get_transaction
/v2/history/get_transfers- JsonRpc
- JsonRpc
- RpcError
- RpcStatusError
JsonRpc
endpointstring hyperion endpoint
const endpoint = "https://br.eosrio.io"
const rpc = new JsonRpc(endpoint, { fetch })simple server healthcheck
const response = await rpc.alive();
console.log(response);
// => {"status": "OK"}Returns Promise<Alive> alive
GET /v2/history/get_abi_snapshot
fetch contract abi at specific block
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
optionsobject Optional parameters (optional, default{})
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 voters
accountstring? account to get links for
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
optionsobject Optional parameters (optional, default{})options.proposerstring? filter by proposeroptions.proposalstring? filter by proposal nameoptions.accountstring? filter by either requested or provided accountoptions.requestedstring? filter by requested accountoptions.providedstring? filter by provided accountoptions.trackstring? total results to track (count) [number or true]options.skipnumber? skip [n] actions (pagination)options.limitnumber? limit of [n] actions per page
accountstring? account to get proposals for
Returns Promise<GetProposals> proposals
get actions based on notified account
accountstring notified accountoptionsobject Optional parameters (optional, default{})options.filterstring? code::name filteroptions.skipnumber? skip [n] actions (pagination)options.limitnumber? limit of [n] actions per pageoptions.sortstring? sort directionoptions.afterstring? filter after specified date (ISO8601)options.beforestring? filter before specified date (ISO8601)options.transfer_tostring? transfer filter tooptions.transfer_fromstring? transfer filter fromoptions.transfer_symbolstring? transfer filter symboloptions.act_namestring? act nameoptions.act_accountstring? act account
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 /v2/history/get_created_accounts
get created accounts
accountstring created account
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
accountstring created account
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
codestring contract accountscopestring table scopetablestring table namepayerstring payer accountoptions
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 /v2/history/get_table_state](https://eos.hyperion.eosrio.io/v2/docs/static/index.html#/history/get_v2_history_get_table_state
get table state
codestring contract accounttablestring table nameblock_numstring target blockafter_keystring last key for pagination
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 account by public key
public_keystring Contract account targeted by the action.
const response = await rpc.get_key_accounts("EOS5Mto3Km6BCVxowb6LkkFaT9oaUwLVgswgcxvY4Qgc4rhHry4Tv");
console.log(response.account_names);
// => [ 'eoscafeblock' ]Returns Promise<GetKeyAccounts> key accounts
get tokens
accountstring account
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 /v2/history/get_transaction
get all actions belonging to the same transaction
idstring transaction id
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
simple server healthcheck
const response = await rpc.alive();
console.log(response);
// => {"status": "OK"}Returns Promise<Alive> alive
GET /v2/history/get_abi_snapshot
fetch contract abi at specific block
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
optionsobject Optional parameters (optional, default{})
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 voters
accountstring? account to get links for
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
optionsobject Optional parameters (optional, default{})options.proposerstring? filter by proposeroptions.proposalstring? filter by proposal nameoptions.accountstring? filter by either requested or provided accountoptions.requestedstring? filter by requested accountoptions.providedstring? filter by provided accountoptions.trackstring? total results to track (count) [number or true]options.skipnumber? skip [n] actions (pagination)options.limitnumber? limit of [n] actions per page
accountstring? account to get proposals for
Returns Promise<GetProposals> proposals
get actions based on notified account
accountstring notified accountoptionsobject Optional parameters (optional, default{})options.filterstring? code::name filteroptions.skipnumber? skip [n] actions (pagination)options.limitnumber? limit of [n] actions per pageoptions.sortstring? sort directionoptions.afterstring? filter after specified date (ISO8601)options.beforestring? filter before specified date (ISO8601)options.transfer_tostring? transfer filter tooptions.transfer_fromstring? transfer filter fromoptions.transfer_symbolstring? transfer filter symboloptions.act_namestring? act nameoptions.act_accountstring? act account
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 /v2/history/get_created_accounts
get created accounts
accountstring created account
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
accountstring created account
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
codestring contract accountscopestring table scopetablestring table namepayerstring payer accountoptions
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 /v2/history/get_table_state](https://eos.hyperion.eosrio.io/v2/docs/static/index.html#/history/get_v2_history_get_table_state
get table state
codestring contract accounttablestring table nameblock_numstring target blockafter_keystring last key for pagination
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 account by public key
public_keystring Contract account targeted by the action.
const response = await rpc.get_key_accounts("EOS5Mto3Km6BCVxowb6LkkFaT9oaUwLVgswgcxvY4Qgc4rhHry4Tv");
console.log(response.account_names);
// => [ 'eoscafeblock' ]Returns Promise<GetKeyAccounts> key accounts
get tokens
accountstring account
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 /v2/history/get_transaction
get all actions belonging to the same transaction
idstring transaction id
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