Nodejs Wrapper
A Highly Efficient Decentralized Storage Network
This is a Nodejs wrapper for Sia. Use it in your apps to easily interact with the Sia storage network via function calls instead of manual http requests.
Prerequisites
Installation
npm install sia.js
Example Usage
// Using promises...// connect to an already running Sia daemon on localhost:9980 and print its version // Or ES7 async/await { try const siad = await const version = await siad console catch e console }
You can also forgo using connect
and use call
directly by providing an API address as the first parameter:
{ try const version = await return version catch e console } console
sia.js
can also launch a siad instance given a path on disk to the siad
binary. launch
takes an object defining the flags to use as its second argument, and returns the child_process
object. You are responsible for keeping track of the state of this child_process
object, and catching any errors launch
may throw.
try // Flags are passed in as an object in the second argument to `launch`. // if no flags are passed, the default flags will be used. const siadProcess = // siadProcess is a ChildProcess class. See https://nodejs.org/api/child_process.html#child_process_class_childprocess for more information on what you can do with it. siadProcess catch e console
The call object passed as the first argument into call() are funneled directly
into the request
library, so checkout
their options to
see how to access the full functionality of Sia's
API
Siad
Should log something like:
null