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)
npm install skycoin
When using async/await, your entire program must be wrapped in an async block:
(async () => {
const api = require('skycoin');
console.log(await api.version());
})();
api.options({
node: 'http://127.0.0.1:6420/', // Change to alternative node (or your own)
proxy: { host: '127.0.0.1', port: 3128 }
});
// 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 } }
console.log(await api.version());
View Response
{ version: '0.21.1', commit: '' }
console.log(await api.pendingTxs());
console.log(await api.transaction(txid));
// 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));
console.log(await api.rawtx(txid));
console.log(await api.injectTransaction(txid));
console.log(await api.resendUnconfirmedTxns());
console.log(await api.metadata());
console.log(await api.progress());
console.log(await api.block({seq: 2760}));
console.log(await api.block({hash: '6eafd13ab6823223b714246b32c984b56e0043412950faf17defdbb2cbf3fe30'}));
console.log(await api.blocks(start, end));
console.log(await api.blocks(num));
console.log(await api.explorer('2CfGyhRyvT8Y4uF9CqoKBgYZuRrgKfCP2nj'));
console.log(await api.uxout(uxid));
console.log(await api.address_uxouts('2CfGyhRyvT8Y4uF9CqoKBgYZuRrgKfCP2nj'));
console.log(await api.defaultConnections());
console.log(await api.connections());
console.log(await api.trust());
console.log(await api.exchange());
console.log(await api.connection(addr));
console.log(await api.coinSupply());
console.log(await api.addresscount());
// 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));