To swap tokens from one chain to another, a user calls the function depositTokens().
function depositTokens(
address receiver, // address of token receiver on destination chain
address token, // token that user send (if token address < 32, then send native coin)
uint256 value, // tokens value
uint256 toChainId // destination chain Id where will be claimed tokens
)
external
payable
notFrozen
This function is the same as in v1. The function depositTokens()
without receiver
parameter was removed.
Move tokens through the bridge and call the contract with 'data' parameters on the destination chain
function bridgeToContract(
address receiver, // address of token receiver on destination chain
address token, // token that user send (if token address < 32, then send native coin)
uint256 value, // tokens value
uint256 toChainId, // destination chain Id where will be claimed tokens
address toContract, // this contract will be called on destination chain
bytes memory data // this data will be passed to contract call (ABI encoded parameters)
) external payable notFrozen
This function is the same as in v1.
Claim tokens from the bridge.
function claim(
address originalToken, // original token
uint256 originalChainID, // original chain ID
bytes32 txId, // deposit transaction hash on fromChain
address to, // user address
uint256 value, // value of tokens
uint256 fromChainId, // chain ID where user deposited
bytes[] memory sig // authority signatures
) external
Difference from v1 is in the first two parameters:
originalToken
- is an address of original token (not wrapped by bridge) that we want to use.originalChainID
- chain ID where original token contract deployed.
For example, if we want to work with the SOY
token that is exist on Callisto chain, then we should use SOY
token contract address and Callisto chain ID, independent of chain where we call this function.
Claim tokens from the bridge and call the contract with 'data' parameters
function claimToContract(
address originalToken, // original token
uint256 originalChainID, // original chain ID
bytes32 txId, // deposit transaction hash on fromChain
address to, // receiver address
uint256 value, // value of tokens
uint256 fromChainId, // chain ID where user deposited
address toContract, // this contract will be called on destination chain
bytes memory data, // this data will be passed to contract call (ABI encoded parameters)
bytes[] memory sig // authority signatures
) external
Difference from v1 is in the first two parameters:
originalToken
- is an address of original token (not wrapped by bridge) that we want to use.originalChainID
- chain ID where original token contract deployed.
For example, if we want to work with the SOY
token that is exist on Callisto chain, then we should use SOY
token contract address and Callisto chain ID, independent of chain where we call this function.
Allow anybody to add new token (original) to the bridge.
function addToken(
address token // token contract address to add to the bridge
) external
Allow to create bridge between original token, that was added by function addToken() and new created wrapped token on the current chain.
function addWrappedToken(
address token, // original token address
uint256 chainID, // original token chain ID
uint256 decimals, // original token decimals
string calldata name, // original token name
string calldata symbol, // original token symbol
bytes[] memory sig // authority signatures
) external
For example: let's there is DAI token on ETH chain and we wants to create bridge to BSC and Callisto.
- On Ethereum chain we call function
addToken(address_of_DAI_token)
; - On BSC and Callisto chain we call function
addWrappedToken()
with parameters according token on Ethereum chain (token address, chain Id, decimals, name, symbol).
-
Callisto testnet bridge: 0xE1AF7a91EBC36E66D89a6201680dC5242796b246
-
BSC testnet bridge: 0x9a1fc8c0369d49f3040bf49c1490e7006657ea56
-
ABI (implementation): 0xeb626A390d13a3EB43a996D1FD9BCd9D69F7aAfB
To swap tokens from one chain to another, a user calls the function depositTokens().
function depositTokens(
address token, // token that user send (if token address < 32, then send native coin)
uint256 value, // tokens value
uint256 toChainId // destination chain Id where will be claimed tokens
)
external
payable
notFrozen
The event Deposit(address token, address sender, uint256 value, uint256 toChainId, address toToken) will be emitted, where:
address token
- token address (if address < 32, then it's native coin).address sender
- the wallet address who sends tokens (only the same address may receive tokens on another chain).uint256 value
- amount of tokens.uint256 toChainId
- chain ID where a user can claim tokens/address toToken
- token address on the destination chain that user will claim.
To get authority signature a user has to call Authority server function authorize(txId, fromChainId), where:
txId
- deposit transaction ID (hash)fromChainId
- chain ID where deposited.
it returns JSON, where:
-
if all good:
isSuccess
- true,signature
- authority signature,token
- token to receive,value
- tokens amount,to
- receiver (user's) address,chainId
- chain ID where to claim token,bridge
- address of bridge on destination network.
-
in case of error:
isSuccess
- false,message
- error description
Use those values to claim tokens on destination chain, the user calls the function claimMultiSig()
function claimMultiSig(
address token, // token to receive
bytes32 txId, // deposit transaction hash on fromChain
address to, // user address
uint256 value, // value of tokens
uint256 fromChainId, // chain ID where user deposited
bytes[] calldata sig // authority signatures
)
To created wrapped token the owner
has to get nonce
from function calculateNonce() then using this nonce
calls the function createWrappedToken()
function createWrappedToken(
address fromToken, // foreign token address
uint256 fromChainId, // foreign chain ID where token deployed
string memory name, // wrapped token name
string memory symbol, // wrapped token symbol
uint8 decimals, // wrapped token decimals (should be the same as in original token)
uint256 nonce // nonce to create wrapped token address begin with 0xCC....
)
external
onlyOwner
On native token's chain the owner
calls function createPair(address toToken, address fromToken, uint256 fromChainId), where:
toToken
- address of token contract on native chain.fromToken
- address of wrapped token on foreign chain.fromChainId
- foreign chain ID.
- Only
owner
can set/remove authority address, using function setAuthority(). - Only
owner
can set threshold (numbers of authority required to approve swap), using function setThreshold(). - The
owner
or anyauthority
can freeze the Bridge contract in case of anomaly detection (anomaly detection module is not implemented). - Only
owner
can unfreeze contract.
Import authority.js
module in server app using:
const auth = require("./authority.js");
Call function auth.authorize(txId, fromChainId)
, where:
txId
- transaction hash,fromChainId
- chain ID where transaction was sent.
returns JSON string, where:
-
if all good:
isSuccess
- true,signature
- authority signature,token
- token to receive,value
- tokens amount,to
- receiver (user's) address,chainId
- chain ID where to claim token,bridge
- address of bridge on destination network.
-
in case of error:
isSuccess
- false,message
- error description
Use signature
, token
, value
, to
to call function claimMultiSig it the bridge
contract on destination network
auth.authorize(txId, fromChainId)
.then(resp => {
response.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});
response.end(JSON.stringify(resp));
})
.catch(err => {
response.writeHead(404, {'Content-Type': 'text/html'});
response.end(err.toString());
})
Each authority script has own private key that stored in environment (.env
).
To get transaction events the script use public RPC. There is a risk of compromising a public site and providing malicious data.
Therefore, I highly recommend to use local node instead of public RPC or, at least, use different public RPC for different authority script.
Bridge contract address on all chains 0x9a1fc8C0369D49f3040bF49c1490E7006657ea56
- CLO bridge
- BSC bridge (toToken - native token)
- ETH bridge (toToken - native token)
- ETC bridge (toToken - native token)
- BTTC bridge (toToken - native token)
- Polygon bridge
- Owners Multisig 0x6A56D0f7498C9f2AEb9Bb6892Ade5b2E0A50379F
- Founders Multisig 0x447c143620A4555c8aEb1596fb013ea84e7DbC03
- https://bridge01.callisto.network/claim?tx=0x2dc54873cd96d25ccc000f90e71bc0239b1c7437e54ab90ed2b73c8e2e589260&chain=820
- 0x91a93225332fa3e0e888d6dce9ea26ed3fc59bc8
- https://srs27mbzuopehskfhvkdrdjwqi0qpjxk.lambda-url.us-west-2.on.aws/auth?tx=0x8dd267b036cdb3d3cabdf344f6ac599c0d9f4ed513024aac83c0a663673bed29&chain=56
- https://bridge01.callisto.network/auth?tx=0x8dd267b036cdb3d3cabdf344f6ac599c0d9f4ed513024aac83c0a663673bed29&chain=56
- https://nrc6gwlqvajn4umvmcqurtni240usuqm.lambda-url.us-east-2.on.aws/auth?tx=0x8dd267b036cdb3d3cabdf344f6ac599c0d9f4ed513024aac83c0a663673bed29&chain=56
Bridge 0xE1AF7a91EBC36E66D89a6201680dC5242796b246
Bridge implementation 0x6bae44aa40df48204337Df2ED580a0FC2642dE1B
Token implementation 0xa89f3920D5F4B333d783C9cac33E13A26C78bc2b
Bridge 0x3777c0b1CBFC65743149D5559db0bC199B7C647c
Bridge implementation 0xe0553dcf6e9dc1e8097420b8dac26afe3e57a0c3
Token implementation 0x57a40032d14755B9e481584C51b8eF59e93120bE
wrapped CLO token 0xCCEA50dDA26F141Fcc41Ad7e94755936d8C57e28
Bridge 0x9b5e4b10b405cd5cd4b056a1b57c1c653379db3c
Bridge implementation 0x6664fd73ed95cf608b5e461a6ce89212f989edca
Token implementation 0x06c0d53112b522c2caa0b150dc431386ceec0cf0
wrapped CLO token 0xcc48d2250b55b82696978184e75811f1c0ef383f
Bridge 0x9a1fc8C0369D49f3040bF49c1490E7006657ea56
wrapped CLO token ccCLO
0xCcbf1C9E8b4f2cDF3Bfba1098b8f56f97d219D53
Bridge 0x9a1fc8C0369D49f3040bF49c1490E7006657ea56
wrapped CLO token ccCLO
0xCcbf1C9E8b4f2cDF3Bfba1098b8f56f97d219D53
Bridge 0x9a1fc8C0369D49f3040bF49c1490E7006657ea56
wrapped CLO token ccCLO
0xCcbf1C9E8b4f2cDF3Bfba1098b8f56f97d219D53
Bridge 0x9a1fc8C0369D49f3040bF49c1490E7006657ea56
wrapped BNB token ccBNB
0xcCDe29903E621Ca12DF33BB0aD9D1ADD7261Ace9
wrapped ETH token ccETH
0xcC208c32Cc6919af5d8026dAB7A3eC7A57CD1796
wrapped ETC token ccETC
0xCCc766f97629a4E14b3af8C91EC54f0b5664A69F
wrapped BNB token ccBNB
0xCC78D0A86B0c0a3b32DEBd773Ec815130F9527CF
wrapped ETH token ccETH
0xcC00860947035a26Ffe24EcB1301ffAd3a89f910