我使用Corda令牌SDK和Corda帐户。 (Corda_version = 4.1,tokens_version = 1.0和accounts_version = 1.0-rc04)
我刚刚构建了一个简单的场景:
流程_1。 PartyA节点创建帐户“ lisa”
start CreateAccount name: "lisa"
Flow_2。 PartA节点向自身发行令牌
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
MyEvolvableToken myEvolvableToken = new MyEvolvableToken(...);
TransactionState<MyEvolvableToken> transactionState = new TransactionState<>(myEvolvableToken, notary);
subFlow(new CreateEvolvableTokens(myEvolvableToken));
・
・
・
//issue token to self
FungibleToken fungibleToken = new FungibleToken(amount, partya,TransactionUtilitiesKt.getAttachmentIdForGenericParam(tokenPointer))
return subFlow(new IssueTokens(ImmutableList.of(fungibleToken)));
Flow_3。 PartA节点将令牌移至“ lisa”
//Get Token from db
MyEvolvableToken token = stateAndRef.getState().getData();
TokenPointer tokenPointer = token.toPointer(token.getClass());
//Get Account from db
stateAndRefAccount = subFlow(new AccountInfoByName("lisa")).get(0);
AccountInfo lisaAccount = stateAndRefAccount.getState().getData();
//fresh account publicKey
PublicKey key = getServiceHub().getKeyManagementService().freshKey(lisaAccount.getIdentifier().getId());
AnonymousParty lisaParty = new AnonyMousParty(key);
//specify amount token to transfer
Amount<TokenPointer> amount = new Amount(10,tokenPointer);
PartyAndAmount partyAndAmount = new PartyAndAmount(lisaParty,amount);
return subFlow(new MoveFungibleTokens(partyAndAmount));
但是,当我启动Flow_3时出现错误。
AnonymousParty无效??
如何将令牌从节点转移到帐户?
java.lang.IllegalArgumentException: Called flow with anonymous party that node doesn't know about.Make sure that RequestConfidentialIdentity flow is called before.
.
.
at com.r3.corda.lib.tokens.workflows.flows.rpc.MoveFungibleTokens.call(MoveTokens.kt:22)
・
・
答案 0 :(得分:0)
请参阅有关帐户+令牌集成的最新示例:https://github.com/corda/samples-java/tree/master/Accounts/worldcupticketbooking
要回答有关如何从节点到帐户发行令牌的问题,您可以将令牌直接发行到帐户的匿名方
例如:
//mention the current holder which is now going to be the dealer account
NonFungibleToken nonFungibleToken = new NonFungibleToken(issuedTokenType, dealerAccount, new UniqueIdentifier(),TransactionUtilitiesKt.getAttachmentIdForGenericParam(tokenPointer));
//call built in flow to issue non fungible tokens
SignedTransaction stx = subFlow(new IssueTokens(Arrays.asList(nonFungibleToken)));
dealerAccount
是一个匿名方。