All Projects → SilentCicero → Ipfs Mini

SilentCicero / Ipfs Mini

Licence: mit
A super tiny module for querying IPFS that works in the browser and node.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ipfs Mini

Hs Web3
Web3 API for Haskell.
Stars: ✭ 127 (+10.43%)
Mutual labels:  ethereum, web3, ipfs
Myetherapi
An API by MyEtherWallet. ETH / Ropsten / JSON RPC / Web3
Stars: ✭ 95 (-17.39%)
Mutual labels:  api, ethereum, web3
Cyb Archeology
🌎 Personal immortal robot for the The Great Web
Stars: ✭ 117 (+1.74%)
Mutual labels:  ethereum, web3, ipfs
Web3x
Ethereum TypeScript Client Library - for perfect types and tiny builds.
Stars: ✭ 197 (+71.3%)
Mutual labels:  api, ethereum, web3
Awesome Web3
🚀 A curated list of tools, libs and resources to help you build awesome dapps
Stars: ✭ 104 (-9.57%)
Mutual labels:  ethereum, web3, ipfs
Alpha
Follow the white rabbit 🐇
Stars: ✭ 304 (+164.35%)
Mutual labels:  ethereum, web3, ipfs
Marketprotocol
Ethereum based derivatives trading protocol creating digital tokens for any asset
Stars: ✭ 78 (-32.17%)
Mutual labels:  ethereum, web3
Trust Wallet Ios
📱 Trust - Ethereum Wallet and Web3 DApp Browser for iOS
Stars: ✭ 1,228 (+967.83%)
Mutual labels:  ethereum, web3
Element
DID Method implementation using the Sidetree protocol on top of Ethereum and IPFS
Stars: ✭ 80 (-30.43%)
Mutual labels:  ethereum, ipfs
Cljs Web3
Clojurescript API for Ethereum Web3 API
Stars: ✭ 84 (-26.96%)
Mutual labels:  ethereum, web3
Vue Ethereum Ipfs
Distributed Application Starter: Vue front-end, Ethereum / IPFS Backend
Stars: ✭ 1,312 (+1040.87%)
Mutual labels:  ethereum, ipfs
Dapp
Censorship resistant democracies.
Stars: ✭ 1,326 (+1053.04%)
Mutual labels:  ethereum, web3
Supply Chain
Supply chain management on blockchain using Angular 4 + Truffle + IPFS + Ethereum
Stars: ✭ 76 (-33.91%)
Mutual labels:  ethereum, ipfs
Colonyjs
The Colony JavaScript client
Stars: ✭ 72 (-37.39%)
Mutual labels:  api, ethereum
Connect
(Aragon 1) Seamlessly integrate DAO functionality into web and node.js apps.
Stars: ✭ 81 (-29.57%)
Mutual labels:  ethereum, web3
Ethjs Provider Signer
A simple web3 standard provider that signs eth_sendTransaction payloads.
Stars: ✭ 65 (-43.48%)
Mutual labels:  ethereum, web3
Web Sdk
Portis Web SDK
Stars: ✭ 65 (-43.48%)
Mutual labels:  ethereum, web3
Starter Kit
An OpenZeppelin starter kit containing React, OpenZeppelin SDK & OpenZeppelin Contracts.
Stars: ✭ 101 (-12.17%)
Mutual labels:  ethereum, web3
Web3 Vs Ethers
A basic cheatsheet of Web3.js vs Ethers (along w/ example apps!)
Stars: ✭ 103 (-10.43%)
Mutual labels:  ethereum, web3
Ipfscloud Web
IpfsCloud: A Decentralized, Anonymous Cloud Storage web client on IPFS.
Stars: ✭ 105 (-8.7%)
Mutual labels:  ethereum, ipfs

ipfs-mini


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

This module was inspired by browser-ipfs.

Install

npm install --save ipfs-mini

Usage

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

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

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'

ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
  console.log(err, result);
});

// result null 'hello world!'

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

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'

ipfs.catJSON('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j').then(console.log).catch(console.log);

// result null { somevalue: 2, name: 'Nick' }

About

A very simple module for querying an IPFS node. This module works for both nodejs and in the browser. It's extremly light, <3 kB when compressed.

This module uses the js-ipfs-api module for the adding operations on nodejs. However, in the browser, it uses a very light FormData Blob handling proceedure which was designed by Pelle Braendgaard, in his browser-ipfs module.

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 ipfs-mini module.

Browser Usage

ipfs-mini is completely browserifiable and webpack ready. The main export found in our distributions dist folder is IPFS. There you will find two builds of ipfs-mini, one compressed and minified ipfs-mini.min.js and one uncompressed ipfs-mini.js.

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

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

Webpack Figures

2.76 kB compressed (not gzipped)

Hash: 55d261679ea2edac14af                                                         
Version: webpack 2.1.0-beta.15
Time: 612ms
        Asset     Size  Chunks             Chunk Names
    ipfs-mini.js  9.55 kB       0  [emitted]  main
ipfs-mini.js.map    11 kB       0  [emitted]  main
    + 3 hidden modules

Hash: 20584eb8548f596cd97d                                                         
Version: webpack 2.1.0-beta.15
Time: 737ms
        Asset     Size  Chunks             Chunk Names
ipfs-mini.min.js  2.76 kB       0  [emitted]  main
    + 3 hidden modules

API Design

constructor

index.js:ipfs-mini

Intakes a single provider object, outputs an ipfs instance.

Parameters

  • provider Object a single provider object, see setProvider for more details

Result output ipfs Object instance.

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

ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
  console.log(err, result);
});

setProvider

index.js:ipfs-mini

Sets the IPFS instance provider.

Parameters

  • provider Object a single provider object.

    default: { host: 'localhost', port: 5001, protocol: 'http', base: '/api/v0' }

No result output.

const IPFS = require('ipfs-mini');
const ipfs = new IPFS();

ipfs.setProvider({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });

ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', cb);

add

index.js:ipfs-mini

Queries /add and adds a single String or Buffer data to IPFS, returns an IPFS hash.

Parameters

  • input String|Buffer the input data to be added to IPFS.

Result output ipfsHash String.

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

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

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'

addJSON

index.js:ipfs-mini

Queries /add and adds stringified JSON to IPFS, returns a single ipfs hash.

Parameters

  • input Object the input data to be added to IPFS.

Result output ipfsHash String.

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

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

// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'

cat

index.js:ipfs-mini

Queries a /cat request, returns data as a String.

Parameters

  • ipfsHash String the ipfs hash string.

Result output data String.

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

ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
  console.log(err, result);
});

// result null 'Hello world!'

catJSON

index.js:ipfs-mini

Queries a /cat request, returns data as a parsed JSON object.

Parameters

  • ipfsHash String the ipfs hash string.

Result output data Object.

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

ipfs.catJSON('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
  console.log(err, result);
});

// result null { somevalue: 2, name: 'Nick' ...}

stat

index.js:ipfs-mini

Queries a /object/stat request, returns data stats object.

Parameters

  • ipfsHash String the ipfs hash string.

Result output stats data Object.

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

ipfs.stat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
  console.log(err, result);
});

/* result null {
  BlockSize: 14595
  CumulativeSize: 14595
  DataSize: 14592
  Hash: "QmbhrsdhbvQy3RyNiDdStgF4YRVc4arteS3wL5ES5M6cVd"
  LinksSize: 3
  NumLinks: 0
}
*/

Contributing

Please help better the ecosystem by submitting issues and pull requests to default. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard and the unix philosophy.

Help out

There is always a lot of work to do, and will have many rules to maintain. So please help out in any way that you can:

  • Create, enhance, and debug silentcicero rules (see our guide to "Working on rules").
  • Improve documentation.
  • Chime in on any open issue or pull request.
  • Open new issues about your ideas for making ipfs-mini better, and pull requests to show us how your idea works.
  • Add new tests to absolutely anything.
  • Create or contribute to ecosystem tools, like modules for encoding or contracts.
  • Spread the word.

Please consult our Code of Conduct docs before helping out.

We communicate via issues and pull requests.

Important documents

Licence

This project is licensed under the MIT license, Copyright (c) 2016 Nick Dodson. For more information see LICENSE.md.

The MIT License

Copyright (c) 2016 Nick Dodson. nickdodson.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].