Besu with Besu
We divide this page into two sections, if you used default configuration in ledger initialization step, then go to section AliceERC721 with BobERC20, otherwise if you used hybrid tokens in network
, then go to section AliceERC1155 with BobERC20
Notes |
---|
The hash used in following steps can be replaced by any valid SHA256 hash. |
AliceERC721 with BobERC20¶
One Besu network transfers an non-fungible AliceERC721
token with id 0
from Alice to Bob in exchange for a transfer of 10 BobERC20
tokens from Bob to Alice in the other network. We will use account 1
for Alice and account 2
for Bob in both networks.
Run the following steps:
- Navigate to the
weaver/samples/besu/besu-cli
folder in your clone of the Cacti repository. - Run the following to verify the status of the assets owned by
alice
andbob
in the two networks: - Generate Secret-Hash Pair using following command (prints hash in base64):
- Run the following to trigger
alice
lockingAliceERC721
token with id0
forbob
innetwork1
for 1 hourValue set to./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=
hash_base64
argument corresponds to what was generated in Step 3. Note thecontract-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
bob
locking10
units ofBobERC20
tokens foralice
innetwork2
for 30 mins:Note the./bin/besu-cli asset lock --network=network2 --sender_account=2 --recipient_account=1 --amount=10 --timeout=1800 --hash_base64=ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs=
contract-id
again for this lock printed as output in above command. Let's refer it<contract-id-2>
for this demonstration. - Run the following to verify
bob
's lock: - Run the following to trigger
alice
's claim for10
units ofBobERC20
tokens locked bybob
innetwork2
: - 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
bob
wants to unlock the token asset, run the following to triggerbob
's re-claim for10 BobERC20
tokens locked innetwork2
:
AliceERC1155 with BobERC20¶
One Besu network transfers an non-fungible 5 AliceERC1155
tokens with id 0
from Alice to Bob in exchange for a transfer of 50 BobERC20
tokens from Bob to Alice in the other network. We will use account 1
for Alice and account 2
for Bob in both networks.
Run the following steps:
- Navigate to the
weaver/samples/besu/besu-cli
folder in your clone of the Cacti repository. - Run the following to verify the status of the assets owned by
alice
andbob
in the two networks: - Generate Secret-Hash Pair using following command (prints hash in base64):
- Run the following to trigger
alice
locking5 AliceERC1155
token with id0
forbob
innetwork1
for 1 hourValue set to./bin/besu-cli asset lock --network=network1 --sender_account=1 --recipient_account=2 --amount=5 --token_id=0 --asset_type=ERC1155 --timeout=3600 --hash_base64=ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs=
hash_base64
argument corresponds to what was generated in Step 3. Note thecontract-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
bob
locking50
units ofBobERC20
tokens foralice
innetwork2
:Note the./bin/besu-cli asset lock --network=network2 --sender_account=2 --recipient_account=1 --amount=50 --timeout=3600 --hash_base64=ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs=
contract-id
again for this lock printed as output in above command. Let's refer it<contract-id-2>
for this demonstration. - Run the following to verify
bob
's lock: - Run the following to trigger
alice
's claim for50
units ofBobERC20
tokens locked bybob
innetwork2
: - Run the following to trigger
bob
's claim for5 AliceERC1155
tokens 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 for5 AliceERC1155
tokens with id0
locked innetwork1
: -
If
bob
wants to unlock the token asset, run the following to triggerbob
's re-claim for50 BobERC20
tokens locked innetwork2
:
Run the following to verify the status of the assets owned by alice
and bob
in the two networks: