Corda with Besu
We will demonstrate asset exchange of an AliceERC721 NFT in Besu network1 with 10 tokens on Corda_Network.
For Besu commands, run from weaver/weaver/samples/besu/besu-cli folder, and for Corda commands, run from samples/corda/corda-simple-application folder, in your clone of the Cacti repository. Here Alice with account 1 and Bob with account 2 in Besu network1 correspond to PartyA (CORDA_PORT=10006) and PartyB (CORDA_PORT=10009) in Corda_Network respectively. Following are the step-by-step asset exchange process:
- From corda client, generate secret-hash pair using following command (prints hash in base64):
- Run the following to verify the status of the tokens owned by
PartyAandPartyBin theCorda_NetworkandCorda_Network2: - Run the following in
besu-cli, to verify the status of the assets owned byAliceandBobin the Besu networks: -
Complete the asset exchange using following steps:
- Run the following to trigger
alicelockingAliceERC721token with id0forbobinnetwork1for 1 hourNote the./bin/besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --token_id=0 --asset_type=ERC721 --timeout=3600 --hash_base64=ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs=contract-idprinted as output in above command. The output line containingcontract-id(text in base64 afterLock contract ID:) would like this: - Run the following to verify
alice's lock, replacing<contract-id>with actualcontract-id: - Run the following to trigger
PartyBlocking50units of token typet1forPartyAinCorda_Networkfor 30 mins:Note theCORDA_PORT=10009 ./clients/build/install/clients/bin/clients lock-asset --fungible --hashBase64=ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= --timeout=1800 --recipient="O=PartyA,L=London,C=GB" --param=t1:50contract-iddisplayed after successful execution of the command, will be used in next steps. The output containingcontract-idwould like this:contract-idis the alphanumeric text (with underscore and hyphens) afterb=within parenthesis. Let's refer it<contract-id-2>for this demonstration. - Run the following to verify
PartyB's lock (can be verified by both parties): - Run the following to trigger
PartyA's claim for50units of token typet1locked byPartyBinCorda_Network:CORDA_PORT=10006 ./clients/build/install/clients/bin/clients claim-asset --secret=secrettext --contract-id=<contract-id-2>PartyBcan see its node's logs to get the revealed hash preimage, and use it to claim in the Besu network. - Run the following to trigger
bob's claim forAliceERC721NFT with id0locked byaliceinnetwork1:
The above steps complete a successful asset exchange between two Besu networks. In addition to the above commands, following commands can be run if specified timeout has expired and the locked asset remains unclaimed. - If
alicewants to unlock the asset, run the following to triggeralice's re-claim forAliceERC721NFT with id0locked innetwork1:- If./bin/besu-cli asset unlock --network=network1 --lock_contract_id=<contract-id> --sender_account=1 --token_id=0PartyBwants to unlock the token asset, run the following to trigger unlock fort1:50locked inCorda_Network:5. Run the following to verify the status of the tokens owned byCORDA_PORT=10009 ./clients/build/install/clients/bin/clients unlock-asset --contract-id=<contract-id>PartyAandPartyBin theCorda_NetworkandCorda_Network2: 6. Run the following inbesu-cli, to verify the status of the assets owned byAliceandBobin the Besu networks: - Run the following to trigger