首页 > 解决方案 > Corda 中的 Cash State 与 Fungible 代币

问题描述

Cash State和Fungible Token都可用于在 Corda 中表示货币。两者都可以发行、转让(移动)和赎回(退出)。

在分类账上表示货币的更合适的类型是什么?使用这两种类型有什么优点和缺点吗?

标签: kotlinblockchaincorda

解决方案


我们已经在 (slack.corda.net) 上讨论过这个问题,您已经发现的简短回答是,可替代代币是代表货币等可替代资产的更好工具。

我们在 youtube 上有一个关于令牌 SDK 的训练营:https ://www.youtube.com/watch?v=IAViczRAEyU

以下是我们查看的有关 CorDapp 概念的一些文档,您将看到令牌是推荐的方法:https ://docs.corda.net/docs/corda-enterprise/4.7/cordapp-advanced-concepts.html #the-demo-finance-cordapp

您还可以在 GitHub 上找到一些清晰的开发人员示例:https ://github.com/corda/samples-java/tree/master/Tokens

大部分的困难将是修改你的状态并且只是改变你的流程来处理令牌:

            // Preparing the token type of the paying fiat currency
            Currency currency = Currency.getInstance(stockState.getCurrency());
            TokenType dividendTokenType = new TokenType(currency.getCurrencyCode(), currency.getDefaultFractionDigits());

            // Calculate the actual dividend paying to the shareholder
            BigDecimal yield = stockState.getDividend().multiply(BigDecimal.valueOf(claimNoticication.getAmount().getQuantity()));
            BigDecimal dividend = yield.multiply(stockState.getPrice()).multiply(BigDecimal.valueOf(Math.pow(10.0, currency.getDefaultFractionDigits())));

            // Create the dividend state
            Amount<TokenType> dividendAmount = new Amount(dividend.longValue(), dividendTokenType);

来源:https ://github.com/corda/samples-java/blob/master/Tokens/stockpaydividend/workflows/src/main/java/net/corda/samples/stockpaydividend/flows/ClaimDividendReceivable.java#L127


推荐阅读