This package provides an implementation of cross-chain channels for the Kadena blockchain. Cross-chain allowing for the transfer of fungible tokens between chains. A channel is defined by a source chain ID, a target chain ID, a list of target accounts, and optionally some additional data for distinguishing different channels for the same source and target parameters.
Each channel has unique send and redeem addresses that are derived from the channel properties via a random oracle. Funds that are sent to the send address are burned on the source chain. Funds can be redeemed from the channel on the target chain by providing a proof that witnesses that enough funds has been burned and the channel is sufficiently funded. The proof ensures that the account which receives the redeemed funds is included in the list of target accounts for the channel.
The package provides APIs and CLI tools for defining cross-chain channel, deriving the channel addresses and generating Merkle proofs for redeeming funds from the channel.
pnpm install
pnpm buildCreate cross-chain channel addresses:
pnpm --silent run create-xchan \
--source-chain-id <source-chain-id> \
--target-chain-id <target-chain-id> \
--target-accounts <target-account[,target-account,...]>Create Merkle proof for redeeming from a cross-chain channel:
pnpm --silent run create-proof \
--xchan <xcain-channel> \
--target-account <target-account> \$ pnpm --silent create-xchan --source-chain-id 20 --target-chain-id 21 --target-accounts 0x000000
{
"targetChainId": 21,
"targetAccounts": [
"0x000000"
],
"sourceChainId": 20,
"nonce": "0x",
"sendAddress": "0xa5289b88eA991814Ae5ef4801F233f8E6fdEc78e",
"redeemAddress": "0xc97Dea26221A5457feA749c3B138621E7bbcF1D6"
}PROOF=$(pnpm --silent create-xchan --source-chain-id 20 --target-chain-id 21 --target-accounts 0x000000 | jq -c)
$ pnpm --silent create-proof --xchan "$PROOF" --target-account 0x000000
{
"root": "0x627332a08b9dc6f191ad0f088d7637b875175ca98836a80ffa39225144385291",
"rootTimestamp": 1754961641,
"rootHeight": 286
"proof": "a36a786368616e50726f6f66a56776657273696f6e006b746172676574436861696e156b706f6c696379496e6465780366706f6c6963794700000000000000656e6f64657381582002e0319397f0e63f071323b75265d1f1214a39f1ca0a392eaf24dec2e7b971766c6163636f756e7450726f6f66a1656e6f646573825901b4f901b180a08b321759927f151e63796f4209ce4edb43a9ae6abec452c8380cd679600c2765a0e5bddfa69d4654686c0d3695f8b6b7ba11151c06d4c39100685c0ad225fb3090a0c4e30567f0c6a6ab6b2fef891b9eb17f8d05971a8ea20b78f0a1870ff9b3313ca0e9625d90e637cf5e1a7763e5c68a470f49ba84ae37df47ccbcafeb56fabf7b40a09b143e90dc772f18b07535e1ab562eaa91139b9e1bf2ee8837a8aab09fd6c29da0bf8a1bbef8c30afd1858dfebf65e4d305c430ab62d96dc2d20571e2d36e25796a0c8c7f52c7a55e97bcce29930d4d2a08e75ba07754d30b8b29abe64225a84f9f680a02842b7bdf8d78e85cb1719c6a9957bdafd3a1dba575f998216a19083c0dd4e28a042bc1252ea988c66b86889e984145c0b9f89548e5c17dbbe6a77d5c6a38b30d3a0dc3d759aac5f4b5da46a3bbb4b1f8d0e770f7aec8b95220fa3d2f79f1e30b54480a07fa4d6d8ece2eddbd92b32ab81832edb4944ce19bd233ca2d1b9501da6d9af02a0f19fc2573dd5f8886ccbf648574f1f4202e6ead47f3f401ca5bb6be6d8351059a039db73ad4bf012c48971b0291a73b8af525d96e54ad52470da720bebd513353e805893f891a0915a5ec9b2537aa4ea2b40f505268bb98492e3d389d1cc1c2ac4163393bc7d3e80808080a0475d5d9f6efe86382589ada799da2bb0832b8a5ae83915abf9400edd224f0336a00f920cdb61cd575978f888461f340cf7549964eca23f5de5b54e748565d2f457a0899bd6b2f891319656831992d770f1ced168af211cf3539638bb034fdc4368d38080808080808080806e7374617465526f6f7450726f6f66a26574726163651a00bbf883656e6f64657398185820086a0ac52c24cb346752e719e24f7df7880b6c13fac3d9bb9b086465a22698555820940bea07f944e97614fe55dbe516ad742ffe68efb4067fc51d92f0dec902ac2358200f77c9f9734efa801048ede1fdc55b366aaa18bbce8dffc323d7b15ee655b4de5820cb49a65cd0885938a6c88f4b09416c6f3670578a1b9b3e992db0eae7d0664ca35820c3132c4e2fbe2474d8f1cb4397802dac0240b6de0599ff6cc7f1df4787aee2115820d99935e02042fa44b7a71a500dac3bdbe328be8109ea2dfe3307ce01131540765820729d3d0b33437303b24e4807e5fbafdfe73482536f0a921f41bc158080767f8558202e100b8bb869ad360ed1ec8e2ec81ce203c28841a5f0895f3c87eb880207d02658207bef777a8ab378d29c30d7d0f70416376fffe73fb8895f9ea178c8af0f99b96358201b116007b21f6b280237e0e4ead25d0da7a9a93607c40b7c8ef270853670e84c5820c9b787aba7c78dfc6bf40997611b4483e5c3ccf19c894f1b228bd078dfc63df45820cf5d9e273bf33a6624c86f0d648f7e7c12be2fa05558d6353d432473e4b60e8b5820df2458c961bc703ce585d7514a168258ca61b6619b85d58f700793a30ea573da5820b24ae811384f4e42a37a5c0aab72d7c1a54bb76ac67325651c942e1388581ba4582014847941f4758edaab7fa18da135979965763a045db4fa81bf2d140e6dec8db65820dd1bb889b6f02d0c22c71371d2816e361bb277af498d8406e567dcb13d4a250c5820766b6ebaf4b27fa7270ed0e9d97f1fb414999e6cf41df47d3f9b19ca34b456af5820940ca070f09140137db1f740333fac56fd4153818b9a48d91e690594e8ce14cb5820dea1f0c85e8d1e2f7651635fe595326c2405c51d2add60a42837a240c2eb8502582043b5342eb8109d964479284634753f3bfa89fd58a28af289394566abb38b7d5e5820766b6ebaf4b27fa7270ed0e9d97f1fb414999e6cf41df47d3f9b19ca34b456af58206254cf5f6a966037a3641c6791f2706a51dcc089a6c709691641611ba9565059582065f3d0a6da0b4cd626b590261381fe4a8da56402ee9bf9b5abd01b4b00abb8f658204f6eac675df79b443e0ad5a1b8bc77d043eb98f8b840464cfd9419f3903f84a8",
}