Create a Custom Token

You can extend the base implementation of the UTS Token or UTS Connector to meet your specific requirements. To implement your custom token, you’ll need to follow a few basic guidelines.

1

Install Entangle Package

Start by installing the Entangle Labs UTS Contract package using NPM.

npm i @entangle-labs/uts-contracts
2

Import Dependencies

Next, you'll need to import the UTS Base smart contract dependency. The UTS Base contract is the core component in the creation of a UTS Token or UTS Connector. To implement any token or connector, you’ll need to inherit from the UTS Base smart contract. Simply put, it acts as a wrapper around the cross-chain communication logic.

To learn more, check out our examples, which include code with detailed technical documentation.

import "@entangle-labs/uts-contracts/contracts/ERC20/UTSBase";
3

Inheritance and Virtual Functions

Inherit from UTS Base contract. All necessary functions are virtual, allowing you to override them with your own logic if necessary.

  • The __UTSBase_init function MUST be called before using other functions of the UTSBase contract.

  • The _authorizeCall function MUST be overridden to include access restriction to the setRouter and setChainConfig functions.

  • The _mintTo function MUST be overridden to implement mint/transfer underlying tokens to receiver to address by _router.

  • The _burnFrom function MUST be overridden to implement burn/transferFrom underlying tokens from spender/from address for bridging.

4

Deployment

Once you've finished editing the logic in your implementation, you can proceed with deployment. If you don't have precomputed contract addresses, you can leave initial settings, such as chain Ids and chain configs, empty.

5

Configuration

Without configuring these settings in your Token/Connector contracts, your bridge will not function properly. Therefore, you must apply these configurations on both sides of your cluster.

If you didn’t provide chain configurations during deployment, you can add them afterward by calling setChainConfig.

/**
 * @notice Sets the destination chains settings.
 * @param allowedChainIds chains Ids available for bridging in both directions.
 * @param chainConfigs array of {ChainConfig} settings for provided {allowedChainIds}, containing:
 *        peerAddress: connected {UTSToken} or {UTSConnector} contract address on the destination chain
 *        minGasLimit: the amount of gas required to execute {redeem} function on the destination chain
 *        decimals: connected {peerAddress} decimals on the destination chain
 *        paused: flag indicating whether current contract is paused for sending/receiving messages from the connected {peerAddress}
 *
 * @return success call result.
 */
function setChainConfig(
    uint256[] calldata allowedChainIds,
    ChainConfig[] calldata chainConfigs
) external virtual returns(bool success)
6

Finishing

That's it! You've successfully created a custom token, and your cluster is now set up and ready to go. For additional important information, please refer to the section below. We also provide clear examples of custom tokens to guide you further.

Additional Important Information and Notes

Ensure Connector is Funded for Proper Functioning

Connector's chain. Without funds, the Connector contract won't be able to unlock tokens. You can fill it by using the bridge from the Connector's chain, which will lock funds on that chain, or you can directly transfer the underlying token to the Connector's address. See how to transfer liquidity to the Connector.

Maintain Adequate Token Balances in Your Connectors

If you have multiple Connectors in your cluster, you must ensure their balances always contain enough underlying tokens to facilitate the redemption of funds.

Automate Token Minting and Burning for Connector Liquidity

You can implement advanced logic to allow your Connector to mint and burn tokens, eliminating the need to manage liquidity on the Connectors.

Last updated

Was this helpful?