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

aanupam23/go-stellar-ipfs: A library that is a bridge between Stellar and IPFS.

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

开源软件名称:

aanupam23/go-stellar-ipfs

开源软件地址:

https://github.com/aanupam23/go-stellar-ipfs

开源编程语言:

Go 100.0%

开源软件介绍:

go-stellar-ipfs

Version License Document

Dependencies

Install

go get -u github.com/aanupam23/go-stellar-ipfs

Getting Started

go-stellar-ipfs is a library that acts as a bridge between Stellar and IPFS. It combines the low fee and fast speed stellar with ipfs. Using this library you can build Stellar and IPFS application very quickly.

go-stellar-ipfs implements StellarShell that helps you use premade functions for sending any sort of data to IPFS using stellar transaction, memo, manage data and also allows reading of that data.

This library is divided in modular functions, which you can utilize in your application.

Refer the below examples for sample usage.

Example

A complete example which implements addition of IPFS data in stellar compatible format using memo hash field.

package main

import (
        "fmt"
        "github.com/stellar/go/txnbuild"
        si "github.com/aanupam23/go-stellar-ipfs"
)

func main() {
        kp, _ := keypair.Parse(SECRETKEY)
        client := horizonclient.DefaultTestNetClient
        ar := horizonclient.AccountRequest{AccountID: kp.Address()}
        sourceAccount, err := client.AccountDetail(ar)
        check(err)

        ss := si.NewStellarShell("localhost:5001", "public")

        // Adding file to IPFS
        thash, err := ss.AddIpfsString("Meow")
        if err != nil {
                error := ss.IsListening()
                panic(error) // ends where
        }
        
        op := Payment{
            Destination: DESITINATION,
            Amount:      "10",
            Asset:       NativeAsset{},
        }

        tx := Transaction{
            SourceAccount: &sourceAccount,
            Operations:    []Operation{&op},
            Timebounds:    NewInfiniteTimeout(),
            Memo:          MemoHash(thash),
            Network:       network.TestNetworkPassphrase,
        }

        txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
        if err != nil {
                panic(error)
        }
        fmt.Println(txe)
}

Replace SECRETKEY and DESITINATION with your inputs.

Another example, that reads the IPFS hash data after converting hash to multiaddr IPFS hash.

package main

import (
        "fmt"
        si "github.com/aanupam23/go-stellar-ipfs"
)

func main() {
        ss := si.NewStellarShell("localhost:5001", "public")

        thash, err: ss.ReadMemoHash(txnid)

        output, err := ss.IpfsDataString(thash)
        if err != nil {
                error := ss.IsListening()
                panic(error) // ends where
        }

        fmt.Println(output)
}

If you wish to get data in an io.Reader, than replace IpfsDataString with IpfsData function

        output, err := ss.IpfsData(thash)
        if err != nil {
                error := ss.IsListening()
                panic(error)
        }

Check the godoc for complete list of functions.

Running your code

Start IPFS daemon

ipfs daemon

Once IPFS Daemon is initialized, run your code. If IPFS is not installed on your system, refer this guide for installing IPFS.

Featured

Mentions

Upcoming/Missing Features

This library acts as a bridge between go-ipfs-api and stellar to make features easier to use.

Features Status
1 Private Stellar ✔️
2 IPFS hash validation x
3 IPFS bootstrap x
4 SEP-0022 Support x
5 IPFS Add options x
6 Suggest any feature -

Contribute

go-stellar-ipfs is open source and all contributions are welcome.

Please refer CONTRIBUTING.md for information.

Licence

License

Stellar is trademark of Stellar Development Foundation.

IPFS is trademark of Protocol Labs.




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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