Skip to content

Node Skycoin API is an asynchronous node.js module designed to interact with the Skycoin blockchain, like Ethereum's web3.js

License

Notifications You must be signed in to change notification settings

jaggedsoft/node-skycoin-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GitHub last commit npm downloads

NPM

Node Skycoin API

This project is designed to help you make your own projects that interact with the Skycoin API. You can query the rich list, total coin supply, download block information, view metadata, get account balances and more. This project seeks to have complete API coverage including wallet functionality and sending transactions.

(Currently an experimental release. Wallet functionality will be added later)

Installation

npm install skycoin

Getting started

When using async/await, your entire program must be wrapped in an async block:

(async () => {
    const api = require('skycoin');
    console.log(await api.version());
})();

Setting optional parameters

api.options({
    node: 'http://127.0.0.1:6420/', // Change to alternative node (or your own)
    proxy: { host: '127.0.0.1', port: 3128 }
});

Get wallet balance

// Accepts single address, or array of addresses. divide balance by 1e6
console.log(await api.balance('2CfGyhRyvT8Y4uF9CqoKBgYZuRrgKfCP2nj'));
View Response
{ confirmed: { coins: 265000000, hours: 108286 },
  predicted: { coins: 265000000, hours: 108286 } }

Get node version info

console.log(await api.version());
View Response
{ version: '0.21.1', commit: '' }

Get unconfirmed transactions

console.log(await api.pendingTxs());

Get transaction info by id

console.log(await api.transaction(txid));

Get transactions that are addresses related

// Addresses can be a single address or an array
// Confirmed can be true or false, defaults to all
console.log(await api.transaction(addresses, confirmed));

Get raw transaction by id

console.log(await api.rawtx(txid));

Inject raw transaction

console.log(await api.injectTransaction(txid));

Resend unconfirmed transactions

console.log(await api.resendUnconfirmedTxns());

Get blockchain metadata

console.log(await api.metadata());

Get blockchain progress

console.log(await api.progress());

Get block by hash or seq

console.log(await api.block({seq: 2760}));
console.log(await api.block({hash: '6eafd13ab6823223b714246b32c984b56e0043412950faf17defdbb2cbf3fe30'}));

Get blocks in specific range

console.log(await api.blocks(start, end));

Get last N blocks

console.log(await api.blocks(num));

Get address affected transactions

console.log(await api.explorer('2CfGyhRyvT8Y4uF9CqoKBgYZuRrgKfCP2nj'));

Get uxout

console.log(await api.uxout(uxid));

Get address affected uxouts

console.log(await api.address_uxouts('2CfGyhRyvT8Y4uF9CqoKBgYZuRrgKfCP2nj'));

Get a list of all default connections

console.log(await api.defaultConnections());

Get a list of all connections

console.log(await api.connections());

Get a list of all trusted connections

console.log(await api.trust());

Get a list of all connections discovered through peer exchange

console.log(await api.exchange());

Get information for a specific connection

console.log(await api.connection(addr));

Coin supply

console.log(await api.coinSupply());

Count unique addresses

console.log(await api.addresscount());

Richlist show top N addresses by uxouts

// amount defaults to 20. -1 returns all accounts
// distributions will include distribution address or not, defaults to false
console.log(await api.richlist(amount, distributions));

Coming soon:

Spend coins from wallet

Update wallet label

Generate new address in wallet

Create a wallet from seed

Generate wallet seed

Get wallet folder name

Get wallets

Get wallet transactions

Get wallet

Views

About

Node Skycoin API is an asynchronous node.js module designed to interact with the Skycoin blockchain, like Ethereum's web3.js

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published