cBridge APIs for Sui
The Sui platform seeks to provide a flexible network that you can leverage to shape the web3 landscape, which is derived from the core Move programming language. If you want to learn more about Sui, please refer to the official document here https://docs.sui.io/learn. Here is the guideline on how to integrate the Sui chain and support the Sui asserts bridge via cBridge from the front-end perspective.
Environments
TypeScript SDK: https://github.com/MystenLabs/sui/tree/main/sdk/typescript
Mainnet
Explorer: https://explorer.sui.io/
Public RPC: https://fullnode.mainnet.sui.io:443
State:
bridge_state
0x638553f133a7f8ea32144b7c540bb911ec9d8839977334ad805a3b229fb01e24
peg_bridge_state
0x835006a934bb8ce4b21fb4ce641d5a933677024bc1b88219023dabcbbc8f55b9
vault_state
0x9bb92383797509d1e6d22b9de1437080d38ae5b3b8562bf4234175ae56e30a6a
delayed_transfer_state
0x4ba21830c4f493c73d6560aa17484568e7341dbcd8836ee39822a09894531aa6
volume_control_state
0x668fc25c9e15e3c1d7d40bed2027103f56c62d983ee870469ad9aa8ad83420e2
Testnet
Explorer: https://explorer.sui.io/
Public RPC: https://fullnode.testnet.sui.io:443
bridge_state
0x20f19ee09c0eccd68c7a01c9c1066cdd79ad24710ba8fab5c71d03cd3990d145
peg_bridge_state
0x0353fc2b9be71f0ce7749905297e7dc4945dbd36a2f8d17f329fd238ab841305
vault_state
0xeef5a6527c48a94d6e0e9ad46202ca2ddfafec01957218f209dc3d711efecdee
delayed_transfer_state
0x34e4218169de9993c6c24b9be18436197ec61db81709bdb156aa3c6e309fab8d
volume_control_state
0x1b1578ae3134dd6d527c24dcebae5fe97f6b1b00ec7d95f5a9900f808881fe60
Bridges
In most scenarios Sui is the pegged chain, the token is bridged from the other chains like Ethereum. All support tokens you can get from the JSON path “pegged_pair_configs” at this link:https://cbridge-prod2.celer.app/v1/getTransferConfigsForAll(testnet: https://cbridge-v2-test.celer.network/v1/getTransferConfigsForAll)
For example, consider a bridge pair {fromChain: Ethereum Mainnet, toChain: Sui Mainnet, Token: USDC}
. Ethereum Mainnet serves as the original chain, while Sui Mainnet acts as the pegged chain. To bridge USDC from Ethereum Mainnet to Sui, you need to interact with the Ethereum Mainnet Vault contract to deposit the USDC. Once the deposit on the source chain is received and verified by the SGN (State Guardian Network), the USDC will be minted on the destination chain shortly after. If you wish to bridge the USDC back to Ethereum from Sui, you can call the burn method on Sui to burn the USDC tokens on-chain. This process ensures a similar level of safety when withdrawing the tokens back to Ethereum.
Get tokens balance
Get SUI (gas token) balance
For other tokens
Note that Sui stores the token information in split objects. Therefore, it is necessary to merge all the split objects into a single base object to ensure a sufficient balance for later bridging.
Quote the bridging fees
Use the cBridge quote API to get the estimated received amount and fees,
Refer to this doc:
https://cbridge-docs.celer.network/developer/api-reference/gateway-estimateamt
Sui Token burn
Used for burning a token on Sui when Sui is a pegged chain.
Example code:
Note that as opposed to the
mergeCoin
method, before the transaction happened, you must split the coin into different objects first.
Nonce
: uniq for the transaction, you can also use the timestamp as the nonce.
mintTcId
: get the mintTcId from this code
Query bridge status from SGN
cBridge allows tracking the status of the bridge at each stage. You can retrieve this information using the getTransferStatus API. For more details, please refer to the documentation at: https://cbridge-docs.celer.network/developer/api-reference/gateway-gettransferstatus.
The transferId
is designed to generate a unique identifier for tracking the states. However, it's important to note that the rules for Sui differ from those of other chains.
You can get the sourceTokenAddress,peggedBurnContractAddress
from the getTransferConfigsForAll
Bridging Limits
Get token burn minimum/maximum amount.
The token the user burn shouldn’t exceed the total supply, the method of getting the total supply.
Last updated