Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Nov 6, 2019
1 parent b5ee5a2 commit 358fe95
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Expand Up @@ -13,6 +13,35 @@
- [EOSIO v1 History](https://developers.eos.io/eosio-nodeos/reference)
- [Hyperion](https://github.com/eosrio/Hyperion-History-API)

### Example - NodeJS/Javascript

**install**

```bash
$ npm install node-fetch eosjs
```

**example.js**

```js
const fetch = require("node-fetch");
const { JsonRpc } = require("eosjs");

const rpc = new JsonRpc("https://api.eosn.io", { fetch });

const code = "blocktivity1";
const scope = "blocktivity1";
const table = "sum";

rpc.get_table_rows({ json: true, code, scope, table }).then((data => {
console.log(data.rows[0]);
// { hour: 815997,
// day: 20310523,
// week: 128191484,
// last_updated: '2019-11-06T15:48:24' }
}))
```

### cURL - `periods`

Request **periods** (hourly intervals of 7200 blocks)
Expand Down
17 changes: 17 additions & 0 deletions examples/sum.js
@@ -0,0 +1,17 @@
const fetch = require("node-fetch");
const { JsonRpc } = require("eosjs");

const rpc = new JsonRpc("https://api.eosn.io", { fetch });

const code = "blocktivity1";
const scope = "blocktivity1";
const table = "sum";

rpc.get_table_rows({ json: true, code, scope, table }).then((data => {
console.log(data.rows[0]);
// { hour: 815997,
// day: 20310523,
// week: 128191484,
// last_updated: '2019-11-06T15:48:24' }
}))

0 comments on commit 358fe95

Please sign in to comment.