1.2.2 • Published 4 years ago

steem-interface v1.2.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Steem Interface

An interface to the Steem blockchain which supports multi-node redundancy for high availability systems.

Installation

npm install steem-interface

Usage

const steem_interface = require('steem-interface');

steem_interface.init();
steem_interface.stream({ on_op: onOperation });

Methods

Init

Initialize the library and connect to the RPC nodes. Calling init() with no parameters will initialize with the default options, or you can specify an options object as shown below.

steem_interface.init({
  logging_level: 3,   // Level of console logging. 1 = minimal, 4 = full
	rpc_error_limit: 5,   // The number of errors responses from an RPC node in a 1 minute period before it's disabled for an hour
	rpc_nodes: ["https://api.steemit.com", "https://anyx.io", "https://rpc.usesteem.com"],  // Array of RPC node URLs
	save_state: saveState,  // Function to call to save the last block read to persistent storage. The last block number will be passed as a function parameter.
	load_state: loadState   // Function to call to load the last block from persistent storage so the app can pick up from where it left off after a downtime
});

Stream

Streams blocks from the blockchain as they come in.

steem_interface.stream({ 
  on_op: onOperation,   // Function to call every time a new operation is received
  on_block: onBlock     // Function to call every time a new block is received
});

function onBlock(block) { ... }
function onOperation(op, block_num, block_id, previous_block_id, transaction_id, block_time) { ... }

Api

Make a database API to the Steem RPC node(s).

steem_interface.api(method_name, params)
  .then(result => console.log(result))
  .catch(err => console.log(err));

Broadcast

Broadcast a transaction to the Steem blockchain.

steem_interface.broadcast(method_name, params, key)
  .then(result => console.log(result))
  .catch(err => console.log(err));

Transfer

Helper function to broadcast a transfer operation. Note that amount must be in the format #.### [STEEM|SBD].

steem_interface.transfer(from, to, amount, memo, key);

Custom JSON

Helper function to broadcast a custom_json operation. This function will retry the transaction up to 3 times if it fails after a delay to deal with the one custom_json transaction per account per block restriction on the Steem blockchain. After HF21 (scheduled for August, 2019) this limit will be increased to 5 custom_json transactions per account per block so this may no longer be necessary.

steem_interface.custom_json(id, json, account, key, use_active);
1.2.2

4 years ago

1.2.1

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago