Fabric with Fabric
One Fabric network transfers a bond from Alice to Bob in exchange for a transfer of tokens from Bob to Alice in the other network Ensure that one of the following chaincodes have been deployed in both networks:
simpleasset
simpleassetandinterop
simpleassettransfer
Run the following steps:
Notes |
---|
The hash used in following steps can be replaced by any valid SHA256 hash. |
- Navigate to the
weaver/samples/fabric/fabric-cli
(for the Node.js version) or theweaver/samples/fabric/go-cli
(for the Golang version) 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: - Complete the asset exchange in either of the two different ways:
- Using a single command:
- Run the following to trigger exchange of bond
bond01:a03
owned byalice
innetwork1
with100
units of tokenstoken1
owned bybob
innetwork2
: - To verify that
bob
now owns a bond in exchange foralice
owning some tokens, run the following:
- Run the following to trigger exchange of bond
-
Using step-by-step commands:
- Generate Secret-Hash Pair using following command (prints hash in base64):
- Run the following to trigger
alice
lockingbond01:a03
forbob
innetwork1
- Run the following to verify
alice
's lock: - Run the following to trigger
bob
locking100
units oftoken1
foralice
innetwork2
:Note the./bin/fabric-cli asset exchange lock --fungible --timeout-duration=1800 --locker=bob --recipient=alice --hashBase64=ivHErp1x4bJDKuRo6L5bApO/DdoyD/dG0mAZrzLZEIs= --target-network=network2 --param=token1:100
contract-id
printed as output in above command. The output line containingcontract-id
(text in base64 afterContract Id:
) would like this: - Run the following to verify
bob
's lock: - Run the following to trigger
alice
's claim for100
units oftoken1
locked bybob
innetwork2
: - Run the following to trigger
bob
's claim forbond01:a03
locked byalice
innetwork1
:
The above steps complete a successful asset exchange between two Fabric 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 bond asset, run the following to triggeralice
's re-claim forbond01:a03
locked innetwork1
: - If
bob
wants to unlock the token asset, run the following to triggerbob
's re-claim fortoken1:100
locked innetwork2
:
- Using a single command: