You use the Tokens SDK
Improve your project with the Tokens SDK
Exercise summary
In your project, from the previous module, you created a fungible token, ostensibly to be used as an air-mile by the world's airlines. Now, oops, you are going to make use of the Tokens SDK and focus your efforts only on what you have to do on our own. So go ahead and do the following:
- Find the proper way to express your air-mile token type.
- Get rid of your
TokenState
and useFungibleToken
instead. - Get rid of your
TokenContract
and use the available contract instead. - Update your contract unit tests so that they become learning tests about the token contract.
- Modify your
IssueFlow
to use one of the Tokens SDK issue flows. - Modify your
MoveFlow
to use one of the Tokens SDK move flows. - Modify your
RedeemFlow
to use one of the Tokens SDK redeem flows. - Adjust your flow tests to confirm your flows work.
Additional help
Achieving these modest aims might not be as easy as the list above suggests. Moreover, if you want your flows to still take the same input types like List<StateAndRef<TokenState>>
(you should), or whichever is applicable in the new stage, then you need to dig a bit. For example, it will be beneficial to clone the Tokens SDK repo and load it as a project into a separate IntelliJ window. Here is what we mean by digging a bit.
- is a high-level
@InitiatingFlow
that sub-flows the inlined, non-initiating,IssueTokensFlow
. - has the automatic responder
IssueTokensHandler
, which itself sub-flowsIssueTokensFlowHandler
.
- is a high-level
- is a high-level
@InitiatingFlow
that sub-flows the inlinedMoveFungibleTokensFlow
, which itself extendsAbstractMoveTokensFlow
. - has the automatic responder
MoveFungibleTokensHandler
, which itself sub-flowsMoveTokensFlowHandler
.
- is a high-level
Interestingly
MoveTokensFlow
:- also inherits from
AbstractMoveTokensFlow
- and takes inputs as
List<StateAndRef<AbstractToken>>
. Yeah!
- also inherits from
- is a high-level
@InitiatingFlow
that sub-flows the inlinedRedeemFungibleTokensFlow
, which itself extendsAbstractRedeemTokensFlow
. - has the automatic responder
RedeemFungibleTokensHandler
, which itself sub-flowsRedeemTokensFlowHandler
.
- is a high-level
Interestingly
RedeemTokensFlow
:- also inherits from
AbstractRedeemTokensFlow
- and takes inputs as
List<StateAndRef<AbstractToken>>
. Boom.
- also inherits from
Conclusion
Use those to review your higher-level flows. See if you can adapt them and their tests to use the SDK.
In the next chapter, we will disclose a modified example project using the SDK. No peeking.
Get 3 months access to the authors and experts who created this training.
- Expert instructors will review your code and help you to refine it.
- One-on-one support and mentoring from expert instructors.
- Collaboration with fellow students in a dedicated Training Slack channel.