GithubHelp home page GithubHelp logo

token-sdk's Introduction

Corda

Corda Token SDK

Reminder

This project is open source under an Apache 2.0 licence. That means you can submit PRs to fix bugs and add new features if they are not currently available.

What is the token SDK?

The token SDK exists to make it easy for CorDapp developers to create CorDapps which use tokens. Functionality is provided to create token types, then issue, move and redeem tokens of a particular type.

The tokens SDK comprises three CorDapp JARs:

  1. Contracts which contains the base types, states and contracts
  2. Workflows which contains flows for issuing, moving and redeeming tokens as well as utilities for the above operations.
  3. Money which contains token type definitions for various currencies
  4. Selection that contains both database and in memory token selection of fungible tokens

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

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

How to use the SDK?

Using the tokens template.

By far the easiest way to get started with the token-sdk is to use the tokens-template which is a branch on the kotlin version of the "CorDapp template". You can obtain it with the following commands:

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

Once you have cloned the repository, you should open it with IntelliJ. This will give you a template repo with the token SDK dependencies already included and some example code which should illustrate you how to use token SDK. You can deployNodes to create three nodes:

./gradlew clean deployNodes
./build/nodes/runnodes

You can issue some currency tokens from PartyA to PartyB from Party A's shell with the following command:

start ExampleFlowWithFixedToken currency: GBP, amount: 100, recipient: PartyB

See the token template code here for more information.

Build Tokens SDK against Corda release branch

Often, in order to use the latest token-sdk master you will need to build against a specific Corda release branch until the required changes make it into a Corda release. At the time of writing tokens 1.1-SNAPSHOT requires Corda 4.3-SNAPSHOT. You can build this branch with the following commands:

git clone https://github.com/corda/corda
git fetch
git checkout origin release/os/4.3

Then run a ./gradlew clean install from the root directory.

Adding token SDK dependencies to an existing CorDapp

First, add a variable for the tokens release group and the version you wish to use and set the corda version that should've been installed locally::

buildscript {
    ext {
        tokens_release_version = '1.1'
        tokens_release_group = 'com.r3.corda.lib.tokens'
    }
}

Second, you must add the tokens development artifactory repository to the list of repositories for your project:

repositories {
    maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib' }
    maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib-dev' }
}

Now, you can add the token-sdk dependencies to the dependencies block in each module of your CorDapp. For contract modules add:

cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version"

In your workflow build.gradle add:

cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version"

and add selection module:

cordaCompile "$tokens_release_group:tokens-selection:$tokens_release_version"

For FiatCurrency and DigitalCurrency definitions add:

cordaCompile "$tokens_release_group:tokens-money:$tokens_release_version"

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

cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version"
cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version"
cordapp "$tokens_release_group:tokens-money:$tokens_release_version"
cordapp "$tokens_release_group:tokens-selection:$tokens_release_version"

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

nodeDefaults {
    projectCordapp {
        deploy = false
    }
    cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version")
    cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version")
    cordapp("$tokens_release_group:tokens-money:$tokens_release_version")
    cordapp("$tokens_release_group:tokens-selection:$tokens_release_version")
}

Installing the token SDK binaries

If you wish to build the token-sdk from source then do the following to publish binaries to your local maven repository:

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

Where to go next?

Introduction to token SDK

Most common tasks

Simple delivery versus payment tutorial

Other useful links

Token SDK Design

Experimental in memory token selection

Changelog

Contributing

Contributors

Roadmap

token-sdk's People

Contributors

adagys avatar afurgal avatar agoldvarg avatar alex-koller-r3 avatar andr3ej avatar anthonykeenan avatar arhamill avatar caismanai avatar chrisr3 avatar clintonio avatar davidleeuk avatar dhrudevalia avatar dwray avatar exfalso avatar fenryka avatar illoyd avatar ischasny avatar kasiastreich avatar kchalkias avatar m4ksio avatar mikehearn avatar nimmaj avatar philippkueng avatar r3domfox avatar rajvjn avatar rick-r3 avatar roastario avatar rogersanick avatar shamsasari avatar willhr3 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.