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
PartyA
andPartyB
in theCorda_Network
andCorda_Network2
: - Run the following in
besu-cli
, to verify the status of the assets owned byAlice
andBob
in the Besu networks: -
Complete the asset exchange using following steps:
- Run the following to trigger
alice
lockingAliceERC721
token with id0
forbob
innetwork1
for 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-id
printed 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
PartyB
locking50
units of token typet1
forPartyA
inCorda_Network
for 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:50
contract-id
displayed after successful execution of the command, will be used in next steps. The output containingcontract-id
would like this:contract-id
is 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 for50
units of token typet1
locked byPartyB
inCorda_Network
:CORDA_PORT=10006 ./clients/build/install/clients/bin/clients claim-asset --secret=secrettext --contract-id=<contract-id-2>
PartyB
can 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 forAliceERC721
NFT with id0
locked byalice
innetwork1
:
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
alice
wants to unlock the asset, run the following to triggeralice
's re-claim forAliceERC721
NFT with id0
locked innetwork1
:- If./bin/besu-cli asset unlock --network=network1 --lock_contract_id=<contract-id> --sender_account=1 --token_id=0
PartyB
wants to unlock the token asset, run the following to trigger unlock fort1:50
locked 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>
PartyA
andPartyB
in theCorda_Network
andCorda_Network2
: 6. Run the following inbesu-cli
, to verify the status of the assets owned byAlice
andBob
in the Besu networks: - Run the following to trigger