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
alice
owns bonds with idsa03
anda04
as 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
alice
innetwork1
to pledge bonda03
tobob
innetwork2
as 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.json
Asset pledged with ID <pledge-id>
(<pledge-id>
is a hexadecimal string). - Get
bob
innetwork2
to 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
alice
innetwork1
does 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=network1
Error: the asset a03 does not exist
. - Verify that
bob
innetwork2
now owns this asset as follows:./bin/fabric-cli chaincode query --user=bob mychannel simpleassettransfer ReadAsset '["bond01","a03"]' --local-network=network2
- Now get
alice
innetwork1
to pledge bonda04
tobob
innetwork2
as 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.json
You should see a message containing the unique ID of this pledge on the console assleep 60
Asset pledged with ID <pledge-id>
(<pledge-id>
is a hexadecimal string). - Now get
bob
innetwork2
to 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
alice
innetwork1
to 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
alice
innetwork1
owns this asset as follows:./bin/fabric-cli chaincode query --user=alice mychannel simpleassettransfer ReadAsset '["bond01","a04"]' --local-network=network1
- Verify that
bob
innetwork2
does 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=network2
Error: the asset a04 does not exist
.
Transfer or recover token (fungible) assets
- Verify that
alice
innetwork1
owns10000
tokens as follows:./scripts/getTokenBalance.sh network1 alice
- Verify that
bob
innetwork2
owns no tokens as follows:You should see an error message like./scripts/getTokenBalance.sh network2 bob
Error: owner does not have a wallet
. - Get
alice
innetwork1
to pledge 50 tokens tobob
innetwork2
as 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.json
Asset pledged with ID <pledge-id>
(<pledge-id>
is a hexadecimal string). - Get
bob
innetwork2
to 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
alice
innetwork1
owns9950
tokens (after losing50
) as follows:./scripts/getTokenBalance.sh network1 alice
- Verify that
bob
innetwork2
now owns50
tokens as follows:./scripts/getTokenBalance.sh network2 bob
- Now get
alice
innetwork1
to pledge 100 tokens tobob
innetwork2
as 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.json
You should see a message containing the unique ID of this pledge on the console assleep 60
Asset pledged with ID <pledge-id>
(<pledge-id>
is a hexadecimal string). - Now get
bob
innetwork2
to 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
alice
innetwork1
to 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
alice
innetwork1
still owns9950
tokens (after losing50
) as follows:./scripts/getTokenBalance.sh network1 alice
- Verify that
bob
innetwork2
still owns only50
tokens 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-application
folder in your clone of the Weaver repository. - Add
5
tokens of typet1
toPartyA
inCorda_Network
:(check token balance forNETWORK_NAME='Corda_Network' CORDA_PORT=10006 ./clients/build/install/clients/bin/clients issue-asset-state 5 t1
PartyA
by running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type t1
) - Let
PartyA
pledge these tokens inCorda_Network
to be transferred toPartyA
ofCorda_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-id
displayed 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
PartyA
inCorda_Network
by running the below command, and the output should not include the assett1:5
issued earlier.CORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type t1
- Let
PartyA
claim inCorda_Network2
the tokens which are pledged in the Corda networkCorda_Network
by 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 forPartyA
inCorda_Network2
by runningCORDA_PORT=30006 ./clients/build/install/clients/bin/clients get-state-using-linear-id <linear-id>
; or simply check the token balance forPartyA
by running the commandCORDA_PORT=30006 ./clients/build/install/clients/bin/clients get-asset-states-by-type t1
which should output5
tokens 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
PartyA
inCorda_Network
try re-claim the tokent1:5
asset, which will succeed only if the asset was not claimed byPartyA
inCorda_Network2
and 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-application
folder in your clone of the Weaver repository. - Add a bond asset with id
a10
and typebond01
toPartyA
inCorda_Network
:(check token balance forNETWORK_NAME=Corda_Network CORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond issue-asset 'a10' 'bond01'
PartyA
by running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01'
) - Let
PartyA
pledge these tokens inCorda_Network
to be transferred toPartyA
ofCorda_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-id
displayed 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
PartyA
inCorda_Network
by running the below command, and the output should not include the assetbond01:a10
issued earlier.CORDA_PORT=10006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01'`
- Let
PartyA
inCorda_Network2
claim the bond asset which is pledged in the Corda networkCorda_Network
by 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 forPartyA
inCorda_Network2
by runningCORDA_PORT=30006 ./clients/build/install/clients/bin/clients bond get-asset-by-linear-id <linear-id>
; or simply check the bond asset balance forPartyA
by running the commandCORDA_PORT=30006 ./clients/build/install/clients/bin/clients bond get-assets-by-type 'bond01'
which should output asset with ida10
and 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
PartyA
inCorda_Network
try re-claim the bond assetbond01:a10
, which will succeed only if the asset was not claimed byPartyA
and 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
alice
innetwork1
owns10000
tokens as follows:./scripts/getTokenBalance.sh network1 alice
Get
alice
innetwork1
to pledge 50 tokens toPartyA
inCorda_Network
as 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.json
You 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
alice
innetwork1
owns9950
tokens (after losing50
) as follows:./scripts/getTokenBalance.sh network1 alice
Let
PartyA
claim inCorda_Network
the tokens which are pledged in the Fabric networknetwork1
by 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 forPartyA
inCorda_Network
by runningCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-state-using-linear-id <linear-id>
; or simply check the token balance forPartyA
by running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1
which should output50
tokens 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
alice
innetwork1
to pledge 100 tokens toPartyA
inCorda_Network
as 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.json
You 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 60
Let
PartyA
inCorda_Network
claim the tokens which are pledged in the Fabric networknetwork1
by 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
PartyA
by running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1
which should still show50
tokens of typetoken1
but not150
)Now get
alice
innetwork1
to 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:100
Verify that
alice
innetwork1
still owns9950
tokens (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
5
tokens of typetoken1
toPartyA
inCorda_Network
:(check token balance forCORDA_PORT=10006 ./clients/build/install/clients/bin/clients issue-asset-state 5 token1
PartyA
by running the commandCORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1
) - Let
PartyA
pledge (with a 1 hour timeout) these tokens inCorda_Network
to be transferred toAlice
of 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-id
displayed 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
PartyA
inCorda_Network
by running the below command, and the output should not include the assettoken1:5
issued earlier.CORDA_PORT=10006 ./clients/build/install/clients/bin/clients get-asset-states-by-type token1`
- Verify that
alice
innetwork1
owns10000
tokens as follows:./scripts/getTokenBalance.sh network1 alice
- Get
alice
innetwork
to 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
alice
innetwork
now owns1050
tokens 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
PartyA
inCorda_Network
try re-claim the tokentoken1:5
asset, which will succeed only if the asset was not claimed byalice
in 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'