eternity-ipfs
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Eternity-ipfs: An NPM package to interact with the Eternity API

Eternity-ipfs is a tiny NPM package to interact with Eternity, an API server you can use to store data eternally on Arweave's Blockchain just by providing an IPFS file hash.

This NPM package is a simple alternative to making API calls to Eternity manually using an HTTP client such as Axios or Fetch. It works on both client and server side.

Installation

It's as easy as:

sudo npm install eternity-ipfs

Usage

You'll need Eternity running locally or at any available endpoint.

Import and Init Eternity-ipfs:

const Eternity = require('eternity-ipfs').Eternity;
// OR
import { Eternity } from "eternity-ipfs";
 
// init with the default endpoint (http://localhost:5000)
let eternity = new Eternity();
 
// Or init with a specific Eternity endpoint
let eternity = new Eternity('https://eternity.example.com');
 

Store data eternally on Arweave's Blockchain with an IPFS file hash:

let main = async () => {
    let data = await eternity.newdata("<IPFS file hash>");
    console.log(data);
    // {"status": "success"}
}
 
main();

Get stored data on Arweave's Blockchain using an IPFS file hash:

let main = async () => {
    let data = await eternity.getdata("<IPFS file hash>");
    console.log(data);
    // {"data": "base64..."}
}
 
main();

It can take up to 10 minutes before the data is available on the Blockchain. You can also use the Eternity Explorer to get the stored files.

Notes:

Here's a file hash you can use to test the package: Qmd286K6pohQcTKYqnS1YhWrCiS4gz7Xi34sdwMe9USZ7u ––– You can verify the file exists at IPFS here.

The source code for the Eternity API is available here.

I created Eternity as a part of a Challenge.

Package Sidebar

Install

npm i eternity-ipfs

Weekly Downloads

6

Version

0.0.5

License

MIT

Unpacked Size

10.3 kB

Total Files

8

Last publish

Collaborators

  • merwane