• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

imerkle/arweave-ipfs: A simple, lightweight library to "permapin" IPFS ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

imerkle/arweave-ipfs

开源软件地址:

https://github.com/imerkle/arweave-ipfs

开源编程语言:

TypeScript 95.9%

开源软件介绍:

arweave-ipfs Test Status

A simple, lightweight library to "permapin" IPFS files into Arweave blockchain.

This library is written closely to the official ipfs js library and provides easy integration with existing ipfs apps to permapin their data in arweave.

IPFS+Arweave Hackathon

This project is part of IPFS+Arweave Hackathon:-

This project contains three repos:

If you just want to see it in action:

Server-Less

Requires a wallet doesn't depends on any central service, it's permanently available on internet as long as IPFS & Arweave nodes exists

Server-Backed

Does not requires any wallet, automatically pins ipfs hashes not existing in arweave even if you're just viewing them.

It also displays/downloads the content you have uploaded , just add #/your-ipfs-hash at end of url

QmQeEyDPA47GqnduyVVWNdnj6UBPXYPVWogAQoqmAcLx6y on Server-Less Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a on Server-Less

QmQeEyDPA47GqnduyVVWNdnj6UBPXYPVWogAQoqmAcLx6y on Server-Backed Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a on Server-Backed

Features

  • Checks for duplicate hashes before pinning
  • Supports multiple hashes in one request
  • Native library with no dependency on centralized servers
  • Highly customizable options
  • Cross Compatibility with both client and server side js

Install

$ yarn install https://github.com/imerkle/arweave-ipfs.git

Initialisation

import ArweaveIpfs from 'arweave-ipfs';

const ar = new ArweaveIpfs();

// Or specify your own options
const ar = new ArweaveIpfs({
    //ipfs opts
    host: 'ipfs.infura.io',
    port: 5001,
    protocol: 'https' 
},{
  //arweave opts
    host: 'arweave.net',
    port: 443,
    protocol: 'https'
});

Example

This example shows integration with existing ipfs apps. The snippet is taken from ipfs/interface-js-ipfs-core

const files = [
  {
    path: '/tmp/myfile.txt',
    content:  Ipfs.Buffer.from('ABC')
  }
]
const results = await ipfs.add(files)

// just add this single line to permapin to arweave
const arweave_result = await ar.add(results);

Usage

add

add takes ipfs hashes, stores the raw bytes of files and returns the respective arweave txid. It also does additional checks to ensure same data is not stored multiple times.

Note: jwk is the json of arweave wallet keyfile see arweave docs for more info
const results = await ar.add("Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a", jwk);

The results array:

[
    {
        "Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a": "1U5kug5cr6j7vBt71FJYNLDFmqliUMm_1BCG6fjLSW8"
    }
]

add also accepts array of hashes

const result = await ar.add(["Qmy...", "Qmx.."], jwk);

get

get takes ipfs hashes or valid IPFS-Add arweave tx ids and returns data as raw bytes. It first looks for data in arweave blockchain if not found it fetches it from ipfs node.

If the ipfs data is not found in arweave blockchain it automagically permapins the data in arweave blockchain provided the jwk is given.
const results = await ar.get("Qmx...");
// or
const results = await ar.get(["Qmx...", "Qmy..."]);
// it also accepts arweave tx ids
const results = await ar.get(["1U5...", "Qmx..."]);

The results array:

[
    {
        "Qmx...": [1,2,3,4,5,6,7...],
        "Qmy...": [8,9,10,11,12,13...]
    }
]

get also accepts a second parameter jwk which is an arweave key. when jwk is supplied any ipfs hash not found in arweave is stored in the blockchain.

// you get the data and the hash is stored in arweave next time someone tries to fetch it
const result = await ar.get("Qm...notinarweavehash", jwk)

For more details see documentation or generate locally using typedoc --out docs src in project root.

Arweave-IPFS Server

If you want to provide a centralized service where users would be able to upload ipfs hashes into permaweb without requiring arweave keyfile then take a look at arweave-ipfs-server

Arweave-IPFS Explorer

arweave-ipfs-explorer is an easy to use permaweb dapp that uses arweave-ipfs andarweave-ipfs-server to display and store ipfs hashes into blockchain.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap