package Ġcom . template Ċ Ċ import Ġcom . r 3 . cord a . lib . tokens . contracts . states . F ung ible Token Ċ import Ġcom . r 3 . cord a . lib . tokens . contracts . types . Iss ued TokenType Ċ import Ġcom . r 3 . cord a . lib . tokens . contracts . types . TokenType Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . flows . rpc . Issue Tokens Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . flows . rpc . Move F ung ible Tokens Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . types . Party And Amount Ċ import Ġcom . r 3 . cord a . lib . tokens . workflows . utilities . held Token Amount Criteria Ċ import Ġnet . cord a . core . contracts . Amount Ċ import Ġnet . cord a . core . identity . Abstract Party Ċ import Ġnet . cord a . core . identity . C ord a X 5 0 0 Name Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . node . services . Vault Ċ import Ġnet . cord a . core . utilities . get OrThrow Ċ import Ġnet . cord a . testing . core . single Identity Ċ import Ġnet . cord a . testing . driver . Driver Parameters Ċ import Ġnet . cord a . testing . driver . Node Handle Ċ import Ġnet . cord a . testing . driver . driver Ċ import Ġnet . cord a . testing . node . Test C ord app Ċ import Ġnet . cord a . testing . node . User Ċ import Ġorg . slf 4 j . LoggerFactory Ċ Ċ /** Ċ Ġ* ĠAllows Ġyou Ġto Ġrun Ġyour Ġnodes Ġthrough Ġan ĠIDE Ġ( as Ġopposed Ġto Ġusing Ġdeploy Nodes ). ĠDo Ġnot Ġuse Ġin Ġa Ġproduction Ċ Ġ* Ġenvironment . Ċ Ġ*/ Ċ val Ġlog Ġ= ĠLoggerFactory . getLogger (" Node Driver . main ") Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ ĊĊĠĠĠ Ġval Ġrpc Users Ġ= ĠlistOf ( User (" user 1 ", Ġ" test ", Ġpermissions Ġ= Ġset Of (" ALL "))) ĊĊĠĠĠ Ġdriver ( Driver Parameters ( start Nodes In Process Ġ= Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠwaitFor All Nodes To Finish Ġ= Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġc ord apps ForAll Nodes Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest C ord app . find C ord app (" com . template . flows "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest C ord app . find C ord app (" com . r 3 . cord a . lib . tokens . contracts "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest C ord app . find C ord app (" com . r 3 . cord a . lib . tokens . workflows "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTest C ord app . find C ord app (" com . r 3 . cord a . lib . tokens . selection "). with Config ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmap Of (" state Selection . in Memory . enabled " Ġto Ġ" true ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" state Selection . in Memory . indexing Str ategies " Ġto Ġ"[ \" EXTERNAL _ ID \"] ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" state Selection . in Memory . cache Size " Ġto Ġ" 1 0 2 4 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ))) Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġissuer Ġ= Ġstart Node ( provided Name Ġ= ĠC ord a X 5 0 0 Name (" Party A ", Ġ" L ondon ", Ġ" GB "), Ġrpc Users Ġ= Ġrpc Users ). get OrThrow () ĊĠĠĠĠĠĠĠ Ġval Ġother Ġ= Ġstart Node ( provided Name Ġ= ĠC ord a X 5 0 0 Name (" Party B ", Ġ" New ĠYork ", Ġ" US "), Ġrpc Users Ġ= Ġrpc Users ). get OrThrow () ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= Ġstart Node ( provided Name Ġ= ĠC ord a X 5 0 0 Name (" Observer ", Ġ" New ĠYork ", Ġ" US "), Ġrpc Users Ġ= Ġrpc Users ). get OrThrow () ĊĊĊĠĠĠĠĠĠĠ Ġval Ġissuer Party Ġ= Ġissuer . node Info . single Identity () ĊĠĠĠĠĠĠĠ Ġval Ġother Party Ġ= Ġother . node Info . single Identity () ĊĠĠĠĠĠĠĠ Ġval Ġobserver Party Ġ= Ġobserver . node Info . single Identity () Ċ Ċ // ĠĠĠĠĠĠĠ Ġval Ġflow Ġ= Ġparty A Handle . rpc . start Flow Dynamic ( Example Flow With Fixed Token :: class . java , ĠlistOf (" 1 0 0 ", Ġparty B Identity )). returnValue Ċ // ĠĠĠĠĠĠĠ Ġflow . to Comp letableFuture () ĊĊĊĠĠĠĠĠĠĠ Ġ// ĠISS U ER Ġ= Ġ 1 0 0 , ĠOTHER Ġ= Ġ 1 0 0 ĊĠĠĠĠĠĠĠ Ġval Ġcustom Token Ġ= ĠTokenType (" CUSTOM _ TOKEN ", Ġ 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġissued Type Ġ= ĠIss ued TokenType ( issuer Party , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġval Ġamount To Issue Ġ= ĠAmount ( 1 0 0 , Ġissued Type ) ĊĠĠĠĠĠĠĠ Ġval Ġtoken To Issue To Issuer Ġ= ĠF ung ible Token ( amount To Issue , Ġissuer Party ) ĊĠĠĠĠĠĠĠ Ġval Ġtoken To Issue To Other Ġ= ĠF ung ible Token ( amount To Issue , Ġother Party ) ĊĠĠĠĠĠĠĠ Ġissuer . rpc . start Flow Dynamic ( Issue Tokens :: class . java , ĠlistOf ( token To Issue To Issuer , Ġtoken To Issue To Other ), ĠlistOf ( observer )). returnValue . get OrThrow () ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( issuer , Ġcustom Token ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠISS U ER Ġ= Ġ 5 0 , ĠOTHER Ġ= Ġ 1 5 0 ĊĠĠĠĠĠĠĠ Ġvar Ġamount Ġ= ĠAmount ( 5 0 , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġvar Ġparty And Amount Ġ= ĠParty And Amount ( other Party , Ġamount ) ĊĠĠĠĠĠĠĠ Ġissuer . rpc . start Flow Dynamic ( Move F ung ible Tokens :: class . java , ĠlistOf ( party And Amount )). returnValue . get OrThrow () ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( issuer , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( other , Ġcustom Token ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠISS U ER Ġ= Ġ 1 7 5 , ĠOTHER Ġ= Ġ 2 5 ĊĠĠĠĠĠĠĠ Ġamount Ġ= ĠAmount ( 1 2 5 , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġparty And Amount Ġ= ĠParty And Amount ( issuer Party , Ġamount ) ĊĠĠĠĠĠĠĠ Ġother . rpc . start Flow Dynamic ( Move F ung ible Tokens :: class . java , ĠlistOf ( party And Amount )). returnValue . get OrThrow () ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( issuer , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( other , Ġcustom Token ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠISS U ER Ġ= Ġ 1 7 5 , ĠOTHER Ġ= Ġ- 1 0 0 ĊĠĠĠĠĠĠĠ Ġ// ĠException Ġ- Ġcom . r 3 . cord a . lib . tokens . selection . Ins ufficient Balance Exception : ĠIns ufficient Ġspend able Ġstates Ġidentified Ġfor Ġ 0 . 1 2 5 ĠTokenType ĊĠĠĠĠĠĠĠ Ġ/* amount Ġ= ĠAmount ( 1 2 5 , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġparty And Amount Ġ= ĠParty And Amount ( issuer Party , Ġamount ) ĊĠĠĠĠĠĠĠ Ġother . rpc . start Flow Dynamic ( Move F ung ible Tokens :: class . java , ĠlistOf ( party And Amount )). returnValue . get OrThrow () ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( other , Ġcustom Token ) */ ĊĊĠĠĠĠĠĠĠ Ġamount Ġ= ĠAmount ( 1 2 5 , Ġcustom Token ) ĊĠĠĠĠĠĠĠ Ġparty And Amount Ġ= ĠParty And Amount ( issuer Party , Ġamount ) ĊĠĠĠĠĠĠĠ Ġother . rpc . start Flow Dynamic ( Move F ung ible Tokens :: class . java , ĠlistOf ( party And Amount )). returnValue . get OrThrow () ĊĠĠĠĠĠĠĠ Ġquery By Party And Token ( other , Ġcustom Token ) ĊĊĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġquery By Party And Token ( node Handle : ĠNode Handle , Ġtoken Type : ĠTokenType ): ĠVault . Page < F ung ible Token > Ġ{ ĊĠĠĠ Ġval Ġquery Result Ġ= Ġnode Handle . rpc . vault Query By Criteria ( held Token Amount Criteria ( token Type , Ġnode Handle . node Info . single Identity ()), ĠF ung ible Token :: class . java ) ĊĠĠĠ Ġlog . info (" Query : Ġ$ query Result ") ĊĠĠĠ Ġreturn Ġquery Result Ċ }