GithubHelp home page GithubHelp logo

token-sdk's Introduction

Corda

Corda Token SDK

!!! REMEMBER: THIS PROJECT IS OPEN SOURCE - THAT MEANS YOU CAN SUBMIT PULL REQUESTS TO ADD THE FUNCTIONALITY YOU NEED IF IT IS NOT CURRENTLY AVAILABLE. !!!

What is the token SDK?

The token SDK is a set of libraries which provide CorDapp developers functionality to:

  • create and manage the reference data which define tokens
  • Issue, move and redeem amounts of some token
  • Perform operations on tokens such as querying and selecting tokens for spending

The token SDK is intended to replace the "finance module" in the core Corda repository.

For more details behind the token SDK's design, see here.

Why did you create the token SDK?

The finance module didn't meet the requirements of the increasing amount of token projects undertaken on Corda:

  • There was little documentation on how to use the finance module
  • The finance module did not define any standards for using tokens
  • There were only two state types defined: Cash and Obligation. Defining new types resulted in significant code duplication.
  • Coin selection required database specific implementations and didn't parallelise well.
  • Etc.

How to use the SDK?

Installing the token SDK binaries

The token SDK is in a pre-release state, so currently, there are no binaries available. To use the SDK one must built it from source and publish binaries to your local maven repository like so:

git clone http://github.com/corda/token-sdk
cd token-sdk
./gradlew clean install

The most up-to-date version of the token SDK will be on the master branch. The first release version will be 0.1.

Building your CorDapp

With the binaries installed to your local maven repository, you can add the token SDK as a dependency to your CorDapp. Add the following lines to the build.gradle files for your CorDapp. In your contract build.gradle, add:

cordaCompile "com.r3.tokens-sdk:contract:1.0-SNAPSHOT"

In your workflow build.gradle add:

cordaCompile "com.r3.tokens-sdk:workflow:1.0-SNAPSHOT"

For FiatCurrency and DigitalCurrency definitions add:

cordaCompile "com.r3.tokens-sdk:money:1.0-SNAPSHOT"

If you want to use the deployNodes task, you will need to add the following dependencies to your root build.gradle file:

cordapp "com.r3.tokens-sdk:contract:1.0-SNAPSHOT"
cordapp "com.r3.tokens-sdk:workflow:1.0-SNAPSHOT"
cordapp "com.r3.tokens-sdk:money:1.0-SNAPSHOT"

These should also be added to the deployNodes task with the following syntax:

cordapp("com.r3.tokens-sdk:contract:1.0-SNAPSHOT")
cordapp("com.r3.tokens-sdk:workflow:1.0-SNAPSHOT")
cordapp("com.r3.tokens-sdk:money:1.0-SNAPSHOT")

See the kotlin token-template for an example.

Alternatively, you can use the following bootstrapped token SDK template:

git clone http://github.com/corda/cordapp-template-kotlin
cd cordapp-template-kotlin
git checkout token-template

Don't build your CorDapp inside the token-sdk repository, instead use the supplied template, above.

When building transactions

When building your flows, you need to make sure that you add the token SDK contract JAR to your transaction builders (and the money JAR if you require the money definitions). If you don't then you will likely encounter NoClassDefFound errors. This is because at this point in time there is no support for handling CorDapp dependencies in Corda 4.

The solution is to manually add the contract JAR and the money JAR (if you need it), to your transaction builders. This can be done with the following code:

val builder = TransactionBuilder()
val contractJarHash = SecureHash.parse("frewfrgregregre")
builder.addAttachment(contractJarHash)

When support is added for handling CorDapp dependencies in Corda, then you will not need the above lines of code.

What is a token?

In the majority of cases, the token SDK treats tokens as agreements between owners and issuers. As such, tokens either represent:

  • Depository receipts (or asset backed tokens) which are claims held by the owner against the issuer to redeem an amount of some underlying thing/asset/security. In this case, the value exists off-ledger. However, the ledger remains authoritative regarding the question of which party has a valid claim over said off-ledger value.
  • Ledger native assets which are issued directly on to the ledger by parties participating on the ledger. In this case, we can say that the token represents the

Ledger native crypto-currencies are the exceptional case where tokens do not represent agreements. This is because the miners which mint units of the crypto-currency are pseudo-anonymous and therefore cannot be identified. Clearly, it is impossible to enter into a legal agreement with an unknown party, therefore it is reaonsable to say that ledger native crypto-currencies are not agreements when represented on Corda.

Do not be confused when a token is used to represent an amount of some existing crypto-currecny on Corda; such a token would be classed as a depository receipt because the underlying value exists off-ledger. Indeed, the only case where a token would not be an agreement on a Corda ledger would be where the crypto-currency is issued directly onto a Corda ledger.

token-sdk's People

Contributors

clintonio avatar illoyd avatar kasiastreich avatar adagys avatar mikehearn avatar chrisr3 avatar roastario avatar shamsasari avatar exfalso avatar willhr3 avatar agoldvarg avatar alex-koller-r3 avatar davidleeuk avatar m4ksio avatar jxilt avatar rick-r3 avatar r3domfox avatar caismanai avatar andr3ej avatar anthonykeenan avatar cxyzhang0 avatar cburlinchon avatar szymonsztuka avatar tb-pq avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.