Skip to content

Latest commit

 

History

History
111 lines (75 loc) · 2.65 KB

README.md

File metadata and controls

111 lines (75 loc) · 2.65 KB

BTFS-mini


A super tiny module for querying an btfsnode, that works in the browser and in Node. Only 2.76 kB compressed!

Install

npm install --save btfs-sdk-mini

Usage

const btfs= require('btfs-sdk-mini');
const btfs= new BTFS({ host: 'xxxx', port: 5001, protocol: 'https' });

BTFS.add('hello world!').then(console.log).catch(console.log);

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'

// result null 'hello world!'

BTFS.addJSON({ somevalue: 2, name: 'Nick' }, (err, result) => {
  console.log(err, result);
});

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'

Examples

An example of the module in use for the browser, can be found in ./example.

Inside is a single, no configuration required, HTML file using the btfs-sdk-mini module.

Browser Usage

btfs-sdk-mini is completely browserifiable and webpack ready. The main export found in our distributions dist folder is BTFS.

<html>
  <body>
    <script type="text/javascript" src="btfs-mini.min.js">
    <script type="text/javascript">
      var btfs= new BTFS({ provider: 'xxxx', protocol: 'https' });

      // ...
    </script>
  </body>
</html>

API Design

add

Result output BTFSHash String.

const btfs= require('BTFS-mini');
const btfs= new BTFS({ host: 'BTFS.infura.io', port: 5001, protocol: 'https' });

BTFS.add('hello world!', (err, result) => {
  console.log(err, result);
});

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'