Asset Transfer
This document lists sample ways in which you can exercise the asset-transfer interoperation protocol on the test network launched earlier.
Once the networks, relays, and drivers have been launched, and the ledgers bootstrapped, you can trigger the following interoperation flows corresponding to distinct asset-sharing combinations other combinations of DLTs will be supported soon):
1. Fabric with Fabric
One Fabric network transfers either a bond or some tokens owned by Alice to Bob in the other network
Assuming that the simpleassettransfer chaincode has been deployed in both networks, run the following steps by navigating to the samples/fabric/fabric-cli folder (the Go CLI doesn't support asset transfer yet).
Transfer or recover a bond (non-fungible) asset
- Verify that
aliceowns bonds with idsa03anda04as follows:You should see a JSON structure corresponding to the bond being logged on the console in each case../bin/fabric-cli chaincode query --user=alice mychannel simpleassettransfer ReadAsset '["bond01","a03"]' --local-network=network1
./bin/fabric-cli chaincode query --user=alice mychannel simpleassettransfer ReadAsset '["bond01","a04"]' --local-network=network1 - Get
aliceinnetwork1to pledge bonda03tobobinnetwork2as follows (with a 1 hour timeout):You should see a message containing the unique ID of this pledge on the console as./bin/fabric-cli asset transfer pledge --source-network=network1 --dest-network=network2 --recipient=bob --expiry-secs=3600 --type=bond --ref=a03 --data-file=src/data/assetsForTransfer.jsonAsset pledged with ID <pledge-id>(<pledge-id>is a hexadecimal string). - Get
bobinnetwork2to claim this bond asset as follows:./bin/fabric-cli asset transfer claim --source-network=network1 --dest-network=network2 --user=bob --owner=alice --type='bond.fabric' --pledge-id=<pledge-id> --param=bond01:a03 - Verify that
aliceinnetwork1does not own this asset as follows:You should see an error message like./bin/fabric-cli chaincode query --user=alice mychannel simpleassettransfer ReadAsset '["bond01","a03"]' --local-network=network1Error: the asset a03 does not exist. - Verify that
bobinnetwork2now owns this asset as follows:./bin/fabric-cli chaincode query --user=bob mychannel simpleassettransfer ReadAsset '["bond01","a03"]' --local-network=network2 - Now get
aliceinnetwork1to pledge bonda04tobobinnetwork2as follows (with a 1 minute timeout):Wait for a minute as follows:./bin/fabric-cli asset transfer pledge --source-network=network1 --dest-network=network2 --recipient=bob --expiry-secs=60 --type=bond --ref=a04 --data-file=src/data/assetsForTransfer.jsonYou should see a message containing the unique ID of this pledge on the console assleep 60Asset pledged with ID <pledge-id>(<pledge-id>is a hexadecimal string). - Now get
bobinnetwork2to claim this bond asset as follows:This should fail as the pledge has already expired../bin/fabric-cli asset transfer claim --source-network=network1 --dest-network=network2 --user=bob --owner=alice --type='bond.fabric' --pledge-id=<pledge-id> --param=bond01:a04 - Now get
aliceinnetwork1to reclaim the asset as follows:./bin/fabric-cli asset transfer reclaim --source-network=network1 --user=alice --type='bond.fabric' --pledge-id=<pledge-id> --param=bond01:a04 - Verify that
aliceinnetwork1owns this asset as follows:./bin/fabric-cli chaincode query --user=alice mychannel simpleassettransfer ReadAsset '["bond01","a04"]' --local-network=network1 - Verify that
bobinnetwork2does not own this asset as follows:You should see an error message like./bin/fabric-cli chaincode query --user=bob mychannel simpleassettransfer ReadAsset '["bond01","a04"]' --local-network=network2Error: the asset a04 does not exist.
Transfer or recover token (fungible) assets
- Verify that
aliceinnetwork1owns10000tokens as follows:./scripts/getTokenBalance.sh network1 alice - Verify that
bobinnetwork2owns no tokens as follows:You should see an error message like./scripts/getTokenBalance.sh network2 bobError: owner does not have a wallet. - Get
aliceinnetwork1to pledge 50 tokens tobobinnetwork2as follows (with a 1 hour timeout):You should see a message containing the unique ID of this pledge on the console as./bin/fabric-cli asset transfer pledge --source-network=network1 --dest-network=network2 --recipient=bob --expiry-secs=3600 --type=token --units=50 --owner=alice --data-file=src/data/tokensForTransfer.jsonAsset pledged with ID <pledge-id>(<pledge-id>is a hexadecimal string). - Get
bobinnetwork2to claim these tokens as follows (replace<pledge-id>with the above hexadecimal value):./bin/fabric-cli asset transfer claim --source-network=network1 --dest-network=network2 --user=bob --owner=alice --type='token.fabric' --pledge-id=<pledge-id> --param=token1:50 - Verify that
aliceinnetwork1owns9950tokens (after losing50) as follows:./scripts/getTokenBalance.sh network1 alice - Verify that
bobinnetwork2now owns50tokens as follows:./scripts/getTokenBalance.sh network2 bob - Now get
aliceinnetwork1to pledge 100 tokens tobobinnetwork2as follows (with a 1 minute timeout):Wait for a minute as follows:./bin/fabric-cli asset transfer pledge --source-network=network1 --dest-network=network2 --recipient=bob --expiry-secs=60 --type=token --units=100 --owner=alice --data-file=src/data/tokensForTransfer.jsonYou should see a message containing the unique ID of this pledge on the console assleep 60Asset pledged with ID <pledge-id>(<pledge-id>is a hexadecimal string). - Now get
bobinnetwork2to claim these tokens as follows (replace<pledge-id>with the above hexadecimal value):This should fail as the pledge has already expired../bin/fabric-cli asset transfer claim --source-network=network1 --dest-network=network2 --user=bob --owner=alice --type='token.fabric' --pledge-id=<pledge-id> --param=token1:100 - Now get
aliceinnetwork1to reclaim these tokens as follows:./bin/fabric-cli asset transfer reclaim --source-network=network1 --user=alice --type='token.fabric' --pledge-id=<pledge-id> --param=token1:100 - Verify that
aliceinnetwork1still owns9950tokens (after losing50) as follows:./scripts/getTokenBalance.sh network1 alice - Verify that
bobinnetwork2still owns only50tokens as follows:./scripts/getTokenBalance.sh network2 bob
2. Corda with Corda
One Corda network transfers either a bond or some tokens owned by the party PartyA (CORDA_PORT=10006) to the party PartyA (CORDA_PORT=30006) in the other network.
Transfer or recover token (fungible) assets
Assume that the CorDapp cordaSimpleApplication has been deployed in both networks.
- Navigate to the
samples/corda/corda-simple-applicationfolder in your clone of the Weaver repository. - Add
5tokens of typet1toPartyAinCorda_Network:(check token balance forNETWORK_NAME='Corda_Network' CORDA_PORT=10006 ./clients/build/install/clients/bin/clients issue-asset-state 5 t1PartyAby running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type t1) - Let
PartyApledge these tokens inCorda_Networkto be transferred toPartyAofCorda_Network2(pledge burns the tokens in the source/exporting network):Note theNETWORK_NAME='Corda_Network' CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer pledge-asset --fungible --timeout="3600" --import-network-id='Corda_Network2' --recipient='O=PartyA, L=London, C=GB' --param='t1:5'pledge-iddisplayed after successful execution of the command, which will be used in next steps. Let's denote it<pledge-id>which is a hexadecimal string (pledge details can be cross checked using the commandsCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer is-asset-pledged -pid <pledge-id>andCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer get-pledge-state -pid <pledge-id>). - Check the token asset balance for
PartyAinCorda_Networkby running the below command, and the output should not include the assett1:5issued earlier.CORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type t1 - Let
PartyAclaim inCorda_Network2the tokens which are pledged in the Corda networkCorda_Networkby replacing<pledge-id>with the above hexadecimal value (claim issues the tokens in the destination/importing network):(theNETWORK_NAME='Corda_Network2' CORDA_PORT=30006 ./clients/build/install/clients/bin/clients transfer claim-remote-asset --pledge-id='<pledge-id>' --locker='O=PartyA, L=London, C=GB' --transfer-category='token.corda' --export-network-id='Corda_Network' --param='t1:5' --import-relay-address='localhost:9082'linear-id, which is displayed after successful execution of the above command, can be used to check the newly issued tokens forPartyAinCorda_Network2by runningCORDA_PORT=30006 ./clients/build/install/clients/bin/clients get-state-using-linear-id <linear-id>; or simply check the token balance forPartyAby running the commandCORDA_PORT=30006 ./clients/build/install/clients/bin/clients get-asset-states-by-type t1which should output5tokens of typet1)
The above steps complete a successful asset transfer from the Corda network Corda_Network to the Corda network Corda_Network2. In addition to the above commands, following is an extra option.
- Let
PartyAinCorda_Networktry re-claim the tokent1:5asset, which will succeed only if the asset was not claimed byPartyAinCorda_Network2and the pledge has expired:NETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer reclaim-pledged-asset --pledge-id=<pledge-id> --export-relay-address='localhost:9081' --transfer-category='token.corda' --import-network-id='Corda_Network2' --param='t1:5'
Transfer or recover bond (non-fungible) assets
Assume that the CorDapp cordaSimpleApplication has been deployed in both networks.
- Navigate to the
samples/corda/corda-simple-applicationfolder in your clone of the Weaver repository. - Add a bond asset with id
a10and typebond01toPartyAinCorda_Network:(check token balance forNETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond issue-asset 'a10' 'bond01'PartyAby running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01') - Let
PartyApledge these tokens inCorda_Networkto be transferred toPartyAofCorda_Network2(pledge burns the tokens in the source/exporting network):Note theNETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer pledge-asset --timeout="3600" --import-network-id='Corda_Network2' --recipient='O=PartyA, L=London, C=GB' --param='bond01:a10'pledge-iddisplayed after successful execution of the command, which will be used in next steps. Let's denote it<pledge-id>which is a hexadecimal string (pledge details can be cross checked using the commandsCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer is-asset-pledged -pid <pledge-id>andCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer get-pledge-state -pid <pledge-id>). - Check the bond asset balance for
PartyAinCorda_Networkby running the below command, and the output should not include the assetbond01:a10issued earlier.CORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01'` - Let
PartyAinCorda_Network2claim the bond asset which is pledged in the Corda networkCorda_Networkby replacing<pledge-id>with the above hexadecimal value (claim issues the bond asset in the destination/importing network):(theNETWORK_NAME=Corda_Network2 CORDA_PORT=30006 ./clients/build/install/clients/bin/clients transfer claim-remote-asset --pledge-id='<pledge-id>' --locker='O=PartyA, L=London, C=GB' --transfer-category='bond.corda' --export-network-id='Corda_Network' --param='bond01:a10' --import-relay-address='localhost:9082'linear-id, which is displayed after successful execution of the above command, can be used to check the newly issued bond asset forPartyAinCorda_Network2by runningCORDA_PORT=30006 ./clients/build/install/clients/bin/clients bond get-asset-by-linear-id <linear-id>; or simply check the bond asset balance forPartyAby running the commandCORDA_PORT=30006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01'which should output asset with ida10and typebond01)
The above steps complete a successful asset transfer from the Corda network Corda_Network to the Corda network Corda_Network2. In addition to the above commands, following is an extra option.
- Let
PartyAinCorda_Networktry re-claim the bond assetbond01:a10, which will succeed only if the asset was not claimed byPartyAand the pledge has expired:NETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer reclaim-pledged-asset --pledge-id=<pledge-id> --export-relay-address='localhost:9081' --transfer-category='bond.corda' --import-network-id='Corda_Network2' --param='bond01:a10'
3. Fabric with Corda
A Fabric network transfers some tokens owned by Alice to PartyA (CORDA_PORT=10006) in a Corda network.
Transfer or recover token (fungible) assets
Assuming that the simpleassettransfer chaincode has been deployed in Fabric network network1, run the following steps related to Fabric by navigating to the samples/fabric/fabric-cli folder (the Go CLI doesn't support asset transfer yet).
Similarly, assuming that the CorDapp cordaSimpleApplication has been deployed in the Corda network Corda_Network, run the following steps related to Corda by navigating to the samples/corda/corda-simple-application folder.
Verify that
aliceinnetwork1owns10000tokens as follows:./scripts/getTokenBalance.sh network1 aliceGet
aliceinnetwork1to pledge 50 tokens toPartyAinCorda_Networkas follows (with a 1 hour timeout):./bin/fabric-cli asset transfer pledge --source-network='network1' --dest-network='Corda_Network' --recipient='O=PartyA, L=London, C=GB' --expiry-secs=3600 --type='token' --units=50 --owner=alice --data-file=src/data/tokensForTransfer.jsonYou should see a message containing the unique ID of this pledge on the console as
Asset pledged with ID <pledge-id>(<pledge-id>is a hexadecimal string).Verify that
aliceinnetwork1owns9950tokens (after losing50) as follows:./scripts/getTokenBalance.sh network1 aliceLet
PartyAclaim inCorda_Networkthe tokens which are pledged in the Fabric networknetwork1by replacing<pledge-id>with the above hexadecimal value (claim issues the tokens in the destination/importing network):NETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer claim-remote-asset --pledge-id='<pledge-id>' --locker='alice' --transfer-category='token.fabric' --export-network-id='network1' --param='token1:50' --import-relay-address='localhost:9081'(the
linear-id, which is displayed after successful execution of the above command, can be used to check the newly issued tokens forPartyAinCorda_Networkby runningCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-state-using-linear-id <linear-id>; or simply check the token balance forPartyAby running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1which should output50tokens of typetoken1)
The above steps complete a successful asset transfer from the Fabric network network1 to the Corda network Corda_Network. Below demostrates re-claim of the tokens pledged in the Fabric network after the pledge expiry.
Now get
aliceinnetwork1to pledge 100 tokens toPartyAinCorda_Networkas follows (with a 1 minute timeout):./bin/fabric-cli asset transfer pledge --source-network='network1' --dest-network='Corda_Network' --recipient='O=PartyA, L=London, C=GB' --expiry-secs=60 --type=token --units=100 --owner=alice --data-file=src/data/tokensForTransfer.jsonYou should see a message containing the unique ID of this pledge on the console as
Asset pledged with ID <pledge-id>(<pledge-id>is a hexadecimal string).Wait for a minute as follows:
sleep 60Let
PartyAinCorda_Networkclaim the tokens which are pledged in the Fabric networknetwork1by replacing<pledge-id>with the above hexadecimal value (claim issues the tokens in the destination/importing network):NETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer claim-remote-asset --pledge-id='<pledge-id>' --locker='alice' --transfer-category='token.fabric' --export-network-id='network1' --param='token1:100' --import-relay-address='localhost:9080'This should fail as the pledge has already expired.
(check the token balance for
PartyAby running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1which should still show50tokens of typetoken1but not150)Now get
aliceinnetwork1to reclaim these tokens as follows:./bin/fabric-cli asset transfer reclaim --source-network='network1' --user='alice' --type='token.corda' --pledge-id=<pledge-id> --param=token1:100Verify that
aliceinnetwork1still owns9950tokens (after losing50) as follows:./scripts/getTokenBalance.sh network1 alice
4. Corda with Fabric
A Corda network transfers some tokens owned by PartyA (CORDA_PORT=10006) to Alice in a Fabric network.
Transfer or recover token (fungible) assets
Assuming that the CorDapp cordaSimpleApplication has been deployed in the Corda network Corda_Network, run the following steps related to Corda by navigating to the samples/corda/corda-simple-application folder.
Similarly, assume that the simpleassettransfer chaincode has been deployed in Fabric network network1, run the following steps related to Fabric by navigating to the samples/fabric/fabric-cli folder (the Go CLI doesn't support asset transfer yet).
- Add
5tokens of typetoken1toPartyAinCorda_Network:(check token balance forCORDA_PORT=10006 ./clients/build/install/clients/bin/clients issue-asset-state 5 token1PartyAby running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1) - Let
PartyApledge (with a 1 hour timeout) these tokens inCorda_Networkto be transferred toAliceof Fabric networknetwork1(pledge burns the tokens in the source/exporting network):Note theCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer pledge-asset --fungible --timeout="3600" --import-network-id='network1' --recipient='alice' --param='token1:5'pledge-iddisplayed after successful execution of the command, which will be used in next steps. Let's denote it<pledge-id>which is a hexadecimal string (pledge details can be cross checked using the commandsCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer is-asset-pledged -pid <pledge-id>andCORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer get-pledge-state -pid <pledge-id>). - Check the token asset balance for
PartyAinCorda_Networkby running the below command, and the output should not include the assettoken1:5issued earlier.CORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1` - Verify that
aliceinnetwork1owns10000tokens as follows:./scripts/getTokenBalance.sh network1 alice - Get
aliceinnetworkto claim these tokens as follows (replace<pledge-id>with the above hexadecimal value):./bin/fabric-cli asset transfer claim --source-network='Corda_Network' --dest-network=network1 --user='alice' --owner='O=PartyA, L=London, C=GB' --type='token.corda' --pledge-id=<pledge-id> --param=token1:5 - Verify that
aliceinnetworknow owns1050tokens as follows:./scripts/getTokenBalance.sh network1 alice
The above steps complete a successful asset transfer from the Corda network Corda_Network to the Fabric network network1. In addition to the above commands, following is an extra option.
- Let
PartyAinCorda_Networktry re-claim the tokentoken1:5asset, which will succeed only if the asset was not claimed byalicein Fabric network and the pledge has expired (replace<pledge-id>with the above hexadecimal value):NETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients transfer reclaim-pledged-asset --pledge-id=<pledge-id> --export-relay-address='localhost:9081' --transfer-category='token.fabric' --import-network-id='network1' --param='token1:5'