The Fabric Token SDK is a set of API and services that lets developers create token-based distributed application on Hyperledger Fabric.

Fabric Token SDK

License Go Report Card Go CodeQL

The Fabric Token SDK is a set of API and services that let developers create token-based distributed application on Hyperledger Fabric.

Useful Links

  • Documentation: Discover the design principles of the Fabric Token SDK.

  • Examples: Learn how to use the Fabric Smart Client via examples. There is nothing better than this.

  • Feedback: Your help is the key to the success of the Fabric Token SDK.

  • Fabric Smart Client: The Token SDK leverages the Fabric Smart Client for transaction orchestration, storing tokens and wallets, and more. Check it out.

Disclaimer

Fabric Token SDK has not been audited and is provided as-is, use at your own risk. The project will be subject to rapid changes to complete the open-sourcing process, and the list of features.

Motivation

Hyperledger Fabric is a permissioned, modular, and extensible open-source DLT platform. Fabric architecture follows a novel execute-order-validate paradigm that supports distributed execution of untrusted code in an untrusted environment. Indeed, Fabric-based distributed applications can be written in any general-purpose programming language.
Fabric does not depend on a native cryptocurrency as it happens for existing blockchain platforms that require “smart-contracts” to be written in domain-specific languages or rely on a cryptocurrency.

Blockchain technologies are accelerating the shifting towards a decentralised economy. Cryptocurrencies are reshaping the financial landscape to the extent that even central banks are now testing the technology to propose what is known as the central bank digital currency. But it is more than this. Real-world assets are being tokenised as fungible or non-fungible assets represented by tokens on a blockchain. Thus enabling business opportunities to extract more value.

Developing token-based applications for Hyperledger Fabric is not easy. Fabric does not provide an out-of-the-box SDK that let developers create tokens that represents any kind of asset. Developers are left on their own and this exposes them to useless duplication of code and security vulnerabilities.

What would happen if the developers could use a Fabric Token SDK that let:

  • Create tokens that represents any kind of asset (baked by a real-world asset or virtual);
  • Choose the privacy level that best fits the use-case without changing the application logic;
  • Orchestrate token transaction in a peer-to-peer fashion;
  • Perform atomic swaps;
  • Audit transactions before they get committed;
  • Interoperate with token systems in other blockchain networks;
  • Add a token layer to existing Fabric distributed application?

Developing Enterprise Token-based distributed applications would become simpler and more secure.

Use the Fabric Token SDK

Install

The Fabric Token SDK can be downloaded using go get as follows:

go get github.com/hyperledger-labs/fabric-token-sdk

The above command clones the repo under $GOPATH/github.com/hyperledger-labs/fabric-token-sdk.

We recommend to use go 1.14.13. We are testing the Token SDK also against more recent versions of the go-sdk to make sure the Token SDK works properly.

Makefile

The Token SDK is equipped with a Makefile to simplify some tasks. Here is the list of commands available.

  • make checks: check code formatting, style, and licence header.
  • make unit-tests: execute the unit-tests.
  • make integration-tests: execute the integration tests. The integration tests use ginkgo. Please, make sure that $GOPATH/bin is in your PATH env variable.
  • make clean: clean the docker environment, useful for testing.

Executes the above from $GOPATH/github.com/hyperledger-labs/fabric-token-sdk.

Testing Philosophy

Write tests. Not too many. Mostly Integration

We also believe that when developing new functions running tests is preferable than running the application to verify the code is working as expected.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the Apache 2 License - see the LICENSE file for details

Owner
Hyperledger Labs provides a space where work can easily be started without the creation of an official Hyperledger project.
null
Comments
  • Error while running Fungible Example

    Error while running Fungible Example

    Hi All, Thank in advance. Getting the below error while running the Fungible example

    ` cd $GOPATH/src/github.com/hyperledger-labs/fabric-token-sdk/samples/fabric/fungible

    go build -o fungible

    ./fungible network start --path ./testdata `

    panic: No future change is possible.  Bailing out early after 93.379s.
    Expected
        <int>: 1
    to match exit code:
        <int>: 0
    
    goroutine 1 [running]:
    github.com/hyperledger-labs/fabric-smart-client/integration.failMe({0xc000cd2080, 0x16}, {0xc0004b53a0, 0x5, 0x5})
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/integration.go:338 +0x2d
    github.com/onsi/gomega/internal.(*AsyncAssertion).match.func1({0x13fd22f, 0x30})
            /root/go/pkg/mod/github.com/onsi/[email protected]/internal/async_assertion.go:169 +0x31d
    github.com/onsi/gomega/internal.(*AsyncAssertion).match(0xc000c7b630, {0x16dcf90, 0xc00076dea8}, 0x1, {0x0, 0x0, 0x0})
            /root/go/pkg/mod/github.com/onsi/[email protected]/internal/async_assertion.go:179 +0x5e8
    github.com/onsi/gomega/internal.(*AsyncAssertion).Should(0xc000c7b630, {0x16dcf90, 0xc00076dea8}, {0x0, 0x0, 0x0})
            /root/go/pkg/mod/github.com/onsi/[email protected]/internal/async_assertion.go:92 +0x6b
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/network.InstallChaincode(0xc0001428c0, 0xc0000b49c0, {0xc0001115b0, 0x1, 0xcd003f})
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/network/deploy.go:79 +0xf3
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/network.PackageAndInstallChaincode(0x0, 0xc0000b49c0, {0xc0001115b0, 0x1, 0x1})
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/network/deploy.go:51 +0x2d2
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/network.(*Network).DeployChaincode(0xc0001428c0, 0xc0000b49c0)
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/network/network.go:313 +0x26a
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/network.(*Network).PostRun(0xc0001428c0, 0x0)
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/network/network.go:227 +0x345
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric.(*Platform).PostRun(0xc00019c298, 0x0)
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/fabric.go:169 +0x45
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo.(*NWO).Start(0xc0000344d0)
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/nwo.go:147 +0x69f
    github.com/hyperledger-labs/fabric-smart-client/integration.(*Infrastructure).Start(...)
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/integration.go:185
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/cmd/network.Start({0xc00035ac90, 0x3, 0x3})
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/cmd/network/cmd.go:170 +0x230
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/cmd/network.StartCmd.func1(0xc000233b80, {0xc000117b60, 0x2, 0x2})
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/cmd/network/cmd.go:129 +0x65
    github.com/spf13/cobra.(*Command).execute(0xc000233b80, {0xc000117b20, 0x2, 0x2})
            /root/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x60e
    github.com/spf13/cobra.(*Command).ExecuteC(0xc000388dc0)
            /root/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x3ad
    github.com/spf13/cobra.(*Command).Execute(...)
            /root/go/pkg/mod/github.com/spf13/[email protected]/command.go:895
    github.com/hyperledger-labs/fabric-smart-client/integration/nwo/cmd.(*Main).Execute(0xc00035a600)
            /root/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/cmd/main.go:56 +0x256
    main.main()
            /home/blockchain/go/gopath/src/github.com/hyperledger-labs/fabric-token-sdk/samples/fabric/fungible/fungible.go:36 +0x105
    
    
  • Support PKCS11

    Support PKCS11

    Currently, FTS code often directly uses the Go crypto package, e.g. create and use ecdsa keys in token/core/zkatdlog/crypto/ecdsa/ecdsa.go and token/core/identity/msp/x509/ecdsa.go etc.

    Instead, FTS should use the fabric BCCSP providers, including the BCCSP PKCS11 provider.

    Goal is to enable FTS to use HSMs.

    Similar issue for FSC: https://github.com/hyperledger-labs/fabric-smart-client/issues/281

  • unable to start Fabric network and the FSC network using ./nft network start --path ./testdata command

    unable to start Fabric network and the FSC network using ./nft network start --path ./testdata command

    Hi there am using Go version is "go version go1.16.15 linux/amd64" go build -o nft went successfull but trying to up and run FSC and fabric network getting below issue, Please help me to fix this issue.

    2022-06-23 20:39:27.793 IST [nwo.network] Start -> INFO 001 ____ _____ _ ____ _____ 2022-06-23 20:39:27.793 IST [nwo.network] Start -> INFO 002 / | | | / \ | _ \ | | 2022-06-23 20:39:27.793 IST [nwo.network] Start -> INFO 003 _ \ | | / _ \ | |) | | | 2022-06-23 20:39:27.793 IST [nwo.network] Start -> INFO 004 ) | | | / ___ \ | _ < | | 2022-06-23 20:39:27.793 IST [nwo.network] Start -> INFO 005 |__/ || // _\ || _\ |_| panic: Your test failed. Ginkgo panics to prevent subsequent assertions from running. Normally Ginkgo rescues this panic so you shouldn't see it.

    But, if you make an assertion in a goroutine, Ginkgo can't capture the panic. To circumvent this, you should call

    defer GinkgoRecover()
    

    at the top of the goroutine that caused this panic.

    goroutine 1 [running]: github.com/onsi/ginkgo.Fail(0xc0005a6040, 0x37, 0xc000c7f8d8, 0x1, 0x1) /home/masoolbabairfan/go/pkg/mod/github.com/onsi/[email protected]/ginkgo_dsl.go:291 +0xc8 github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/helpers.AssertImagesExist(0x25fd230, 0x1, 0x1) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/helpers/images.go:28 +0x38f github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric.NewPlatform(0x1ab1188, 0xc0005aa240, 0x1a7f6b8, 0xc0008b0200, 0x7f32870cd758, 0xc000684bc0, 0xc0003744d0) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/fabric.go:114 +0x57 github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric.platformFactory.New(...) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/fabric/fabric.go:106 github.com/hyperledger-labs/fabric-smart-client/integration.(*Infrastructure).initNWO(0xc0005975c0) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/integration.go:298 +0x690 github.com/hyperledger-labs/fabric-smart-client/integration.(*Infrastructure).Generate(0xc0005975c0) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/integration.go:166 +0x35 github.com/hyperledger-labs/fabric-smart-client/integration/nwo/cmd/network.Start(0xc00056da10, 0x0, 0x0) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/cmd/network/cmd.go:187 +0x2b1 github.com/hyperledger-labs/fabric-smart-client/integration/nwo/cmd/network.StartCmd.func1(0xc0003a7080, 0xc0003a9ee0, 0x0, 0x2, 0x0, 0x0) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/cmd/network/cmd.go:151 +0x8c github.com/spf13/cobra.(*Command).execute(0xc0003a7080, 0xc0003a9ec0, 0x2, 0x2, 0xc0003a7080, 0xc0003a9ec0) /home/masoolbabairfan/go/pkg/mod/github.com/spf13/[email protected]/command.go:850 +0x472 github.com/spf13/cobra.(*Command).ExecuteC(0xc0003a6000, 0x17a3571, 0xd, 0x0) /home/masoolbabairfan/go/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x375 github.com/spf13/cobra.(*Command).Execute(...) /home/masoolbabairfan/go/pkg/mod/github.com/spf13/[email protected]/command.go:895 github.com/hyperledger-labs/fabric-smart-client/integration/nwo/cmd.(*Main).Execute(0xc00056d9e0) /home/masoolbabairfan/go/pkg/mod/github.com/hyperledger-labs/[email protected]/integration/nwo/cmd/main.go:56 +0x2dd main.main() /src/github.com/hyperledger-labs/fabric-token-sdk/samples/nft/nft.go:42 +0x25d

  • Is there a clear version for the stack figure?

    Is there a clear version for the stack figure?

    The link is https://raw.githubusercontent.com/hyperledger-labs/fabric-token-sdk/main/docs/imgs/stack.png, which is difficult to read the words on it. Thanks!

  • use time.NewTimer instead of time.After

    use time.NewTimer instead of time.After

    Using time.After enqueues an entry in Go's runtime scheduler and doesn't garbage collect it even if the function the timer was fired from terminates. As a result, there can be a temporary high memory pressure and it degrades performance.

    Replaced all places where time.After was used except in places where we use it for timing periodical processes (hence, in those places, time.After can only fire when the previous one finishes).

    Signed-off-by: Yacov Manevich [email protected]

  • refactoring to make services backed agnostic

    refactoring to make services backed agnostic

    We now support both fabric and orion as backed to process the token transactions thanks to the token/services/network package that takes care of everything.

    To better reflect that some services are not backend agnostic, this issue proposes the following refactoring:

    • [x] rename token/services/ttxcc to token/services/ttx
    • [x] move token/services/tcc under token/services/network/fabric
    • [x] rename token/services/nftcc to token/serivces/nfttx
    • [x] move the content integration/token/tcc one level up, and remove tcc
  • Token SDK: check well-formedness of inputs to token operations.

    Token SDK: check well-formedness of inputs to token operations.

    Check that the token operations are called with valid arguments. Examples:

    • If an issuer calls issue with value "0" or type "", then token-sdk should return an error.
    • If a user calls transfer or redeem with value "0", then token-sdk should return an error.
  • ttxdb derivates: failed restart #402

    ttxdb derivates: failed restart #402

    This PR fixes the owner and auditor services. Before, these services were not able to recover from a shutdown of the node. Now, at bootstrap, the services first check if there are transactions whose status is still pending and for those a commit listener is added.

    Signed-off-by: Angelo De Caro [email protected]

  • ZKATDLOG: Improved VaultTokenCommitmentLoader

    ZKATDLOG: Improved VaultTokenCommitmentLoader

    The current loader fails if the commitment of a given token does not exists, but it might be that the corresponding transaction is still pending. This means that the commit pipeline hasn't had time to process the transaction yet.

    This PR improves the loader by adding the possibility to retry after some time.

    Signed-off-by: Angelo De Caro [email protected]

  • Generify the Token Request

    Generify the Token Request

    The goal of this PR is to allow drivers to decide on the format of the token request. This gives to the system the possibility to evolve with more freedom.

    Signed-off-by: Angelo De Caro [email protected]

  • auditor validate on total amount on tokens despite there are locked amounts

    auditor validate on total amount on tokens despite there are locked amounts

    when auditor validate that there is enough balance to validate a transaction, if Alice made htlc lock to Bob, Some of the amount of tokens Alice will be tokens until Bob claims it. however if Alice made a transfer transaction before bob claims it , the auditor will take the locked amount as available balance as well.

Quick add or delete ASN/AS-SET to your AS-SET through RIPE RESTful API

RIPE AS-SET updater Quick add or delete ASN/AS-SET to your AS-SET through RIPE RESTful API. Requirenments You need to add "auth:" attribute in mntner

Apr 19, 2022
Token-list - The community maintained Solana token registry

Please note: This repository is being rebuilt to accept the new volume of token

Feb 2, 2022
Assume-shell - A tool to create a shell with AWS environment credentials set

assume-shell This tool will request AWS credentials for a given profile/role and

Sep 29, 2022
The MinIO Admin Go Client SDK provides APIs to manage MinIO services

Golang Admin Client API Reference The MinIO Admin Golang Client SDK provides APIs to manage MinIO services. This quickstart guide will show you how to

Dec 30, 2022
A go sdk for baidu netdisk open platform 百度网盘开放平台 Go SDK

Pan Go Sdk 该代码库为百度网盘开放平台Go语言的SDK

Nov 22, 2022
Nextengine-sdk-go: the NextEngine SDK for the Go programming language

NextEngine SDK for Go nextengine-sdk-go is the NextEngine SDK for the Go programming language. Getting Started Install go get github.com/takaaki-s/nex

Dec 7, 2021
Commercetools-go-sdk is fork of original commercetools-go-sdk

commercetools-go-sdk The Commercetools Go SDK is automatically generated based on the official API specifications of Commercetools. It should therefor

Dec 13, 2021
Sdk-go - Go version of the Synapse SDK

synapsesdk-go Synapse Protocol's Go SDK. Currently in super duper alpha, do not

Jan 7, 2022
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go
Redash-go-sdk - An SDK for the programmatic management of Redash, in Go

Redash Go SDK An SDK for the programmatic management of Redash. The main compone

Dec 13, 2022
Is a microservice which provides payment token service for application users.

Tulip Is a microservice which provides payment token service for application users. Description A transactional-based token usually used for transacti

Feb 17, 2022
Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Mar 19, 2022
Metrics package helps to create ydb-go-sdk traces with monitoring internal state of driver

metrics metrics package helps to create ydb-go-sdk traces with monitoring internal state of driver Usage import ( "fmt" "sync/mutex" "time

Jan 7, 2023
A compute service that lets you run code without provisioning or managing servers

AWS Lambda for Go Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code on a high-availab

Oct 13, 2021
Prismplus - Prism+ lets you multicast your rtmp stream to multiple destinations
Prismplus - Prism+ lets you multicast your rtmp stream to multiple destinations

prism+ Use at your own risk! It has worked for us.. but very much alpha quality!

Nov 9, 2022
Go library for accessing trending repositories and developers at Github.
Go library for accessing trending repositories and developers at Github.

go-trending A package to retrieve trending repositories and developers from Github written in golang. This package were inspired by rochefort/git-tren

Dec 21, 2022
An unofficial package in Golang to help developers implement ZATCA (Fatoora) QR code easily.

Zatca SDK GO An unofficial package in Golang to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing ✅ The hash

Jan 1, 2023
NKN-ESI (or nESI) is an NKN based Energy Services Interface (ESI).

nkn-esi NKN-ESI (or nESI) is an NKN based Energy Services Interface (ESI). An ESI supports a distributed marketplace for energy services on the electr

Mar 18, 2022
A Facebook Graph API SDK For Go.

A Facebook Graph API SDK In Golang This is a Go package that fully supports the Facebook Graph API with file upload, batch request and marketing API.

Dec 12, 2022
A Golang SDK for Medium's OAuth2 API

Medium SDK for Go This repository contains the open source SDK for integrating Medium's OAuth2 API into your Go app. Install go get github.com/Medium/

Nov 28, 2022