Skip to main content

How to bridge non-fungible tokens

With the non fungible token connector nft's can be bridged from NEAR to Calimero and back. In order to bridge some nft from NEAR testnet to Calimero, a single transaction needs to be called. Just lock the wanted token to the nft connector contract. Once the token is transferred, the bridge service will be notified about it and try to prove on the Calimero shard that the locking of tokens happened on NEAR. If proved, wrapped token is minted on Calimero shard.

caution

When locking NFTs on source side NFT Connector you MUST do it through nft_transfer_call. If you try to do it through nft_transfer tokens will be LOST.

Example of locking non fungible token on NEAR testnet with transaction on NEAR testnet:

near call nft-test.igi.testnet nft_transfer_call --args '{"receiver_id":"nft_connector.cali99.dev.calimero.testnet", "token_id":"0", "msg":""}' --accountId igi.testnet --depositYocto 1 --gas 300000000000000

If the users want to get the token back on the original chain (in this case NEAR testnet), they simply call withdraw on the bridged token on the other chain (in this case Calimero shard) which will essentially burn the token. The bridge service will be notified via emitted event that a burn happened and try to prove on the nft connector contract on NEAR that a burn happaned on Calimero shard. If proved, tokens are unlocked.

Example of withdrawing/burning the nft token on Calimero with transaction on NEAR testnet:

calimero cali99-calimero-testnet call nft-test_igi.nft_deployer.cali99.calimero.testnet withdraw --args '{"token_id":"0"}' --accountId igi.testnet --depositYocto 1 --gas 300000000000000

Helper cli

For Calimero side create Calimero alias (change dev to staging for staging and remove it for production):

alias calimero='function x() { near ${@:2} --nodeUrl https://api.dev.calimero.network/api/v1/shards/$1/neard-rpc --networkId $1;} ; x'

Other direction

If the NFT was originally minted on Calimero, all the above would still apply. The only thing that is different is that a lock transaction needs to be called on the Calimero side, and on NEAR side a withdraw transaction needs to be called when wanting to get the token back on Calimero.

Wrapped tokens naming

Wrapped/bridged NFT naming is performed in the same way as FT naming so for a detailed description look at the Fungible token documentation.