token-sdk | token SDK exists to make it easy for CorDapp developers | Cryptocurrency library
kandi X-RAY | token-sdk Summary
kandi X-RAY | token-sdk Summary
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.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of token-sdk
token-sdk Key Features
token-sdk Examples and Code Snippets
Community Discussions
Trending Discussions on token-sdk
QUESTION
Both Cash State and Fungible Token can be used to represent money in Corda. Both can be issued , transferred(move) and redeemed (exit).
What is a more appropriate type to use for representing money on ledger? Are there any pros , cons to useing either type ?
...ANSWER
Answered 2021-Feb-03 at 14:14We've talked on (slack.corda.net) on this issue and the short answer you've already found is that fungible tokens are a better tool for representing fungible assets like currencies.
We have a bootcamp on the tokens SDK on youtube here: https://www.youtube.com/watch?v=IAViczRAEyU
Here are some docs that we looked at on CorDapp concepts where you'll see that tokens are the recommended way to go: https://docs.corda.net/docs/corda-enterprise/4.7/cordapp-advanced-concepts.html#the-demo-finance-cordapp
You can also find some clear developer samples on GitHub here: https://github.com/corda/samples-java/tree/master/Tokens
Most of the difficulty is going to be modifying your state and just changing your flows a bit to deal with the tokens:
QUESTION
Corda Token SDK https://github.com/corda/token-sdk. By default, the fungible token can be issued many times, to many accounts. I do not know to limit that fungible token is issued once and sent to a specific account (after that token will not be issued any more) Does anyone have an idea?
...ANSWER
Answered 2020-Jan-02 at 15:30To implement that, you'd have to do the following:
- Create your own
EvolvableTokenType
. - Your evolvable token type will have 2 custom attributes (that can be changed over time, thus why we chose evolvable over fixed token type):
issued
of typeboolean
issueAccount
of typeAbstractParty
- Create a contract that validates your evolvable token type (it should extend
EvolvableTokenContract
):- Implement
additionalCreateChecks
: You can keep it empty. - Implement
additionalUpdateChecks
: Here you can validate that you can only update the value ofissued
totrue
, you cannot update it tofalse
(this will allow issuing more of your token type which we don't want).
- Implement
- Create a flow that creates your evolvable token type, it sets the
issueAccount
to the value that you pass as input parameter and setsissued
tofalse
. - Now you can create your evolvable token token type and use it to issue tokens of that type.
- Create a flow that issues tokens of your token type:
- It will fetch the latest version of your evolvable token type.
- If the value of
issued
istrue
, throw aFlowException
that this token has already been issued and you cannot issue it again. - Use the returned state to get the
issueAccount
value. - Call the
IssueToken
flow to issue your token type toissueAccount
. Of course you need to generate a new key for the account usingRequestKeyForAccount
and wrap the returnedPublicKey
in an instance ofAnonymousParty
. - Now the most important part (your requirement): Call
UpdateEvolvableToken
flow to update your evolvable token type and setissued
totrue
. This way if someone calls your issue tokens flow again, it will throw an exception because your token type has beenissued
.
The Kotlin template (token
branch) has a high level example of EvolvableTokenType
:
- Type: https://github.com/corda/cordapp-template-kotlin/blob/token-template/contracts/src/main/kotlin/com/template/states/ExampleEvolvableTokenType.kt
- Contract: https://github.com/corda/cordapp-template-kotlin/blob/token-template/contracts/src/main/kotlin/com/template/ExampleEvolvableTokenTypeContract.kt
- Flow (it has 2 flows, create token type and issue it): https://github.com/corda/cordapp-template-kotlin/blob/token-template/workflows/src/main/kotlin/com/template/flows/ExampleFlowWithEvolvableToken.kt
Also the Tokens SDK has an example that uses EvolvableTokenType
where the House
token has an attribute that can change (valuation
):
https://github.com/corda/token-sdk/blob/master/docs/DvPTutorial.md#define-your-states-and-contracts
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install token-sdk
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page