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.
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:
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.
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.
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.
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://download.corda.net/maven/corda-lib' }
maven { url 'https://download.corda.net/maven/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")
}
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
Simple delivery versus payment tutorial