Teleport tokens

ERC 20 Token Teleport

The next step is an ERC20 token that can be teleported across the Rayls Private Network.

To build one, inherit the RaylsErc20Handler abstract contract in the token contract, as in the example below.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "@rayls/contracts/tokens/RaylsErc20Handler.sol";

contract TokenExample is RaylsErc20Handler {
    constructor(
        string memory _name,
        string memory _symbol,
        address _endpoint,
        address _raylsNodeEndpoint,
        address _userGovernance,
        address _owner
    )
        RaylsErc20Handler(
            _name,
            _symbol,
            _endpoint,
            _raylsNodeEndpoint,
            _userGovernance,
            _owner,
            false
        )
    {
        // your logic here
    }
}

Constructor parameters

ParameterDescription
_nameERC20 token name
_symbolERC20 token symbol
_endpointAddress of the endpoint contract in the Rayls Sovereign ledger, used to route messages to other institutions through the Private Network Hub
_raylsNodeEndpointAddress of the endpoint contract for the Rayls Public Chain, used when teleporting to and from the public chain
_userGovernanceAddress of the RBAC contract that manages user roles and permissions within the Rayls Sovereign ledger
_ownerAddress that will be granted the Owner role (mint, burn, token updates)

The final parameter (false) marks this as a standard token. Pass true only for custom handler implementations that override the default transfer behaviour.

Resource ID

Every token in the Rayls network is identified by a unique resourceId (bytes32), which you do not pass in the constructor.

After deploying the token, call registerToken on the TokenRegistryReplica system contract in the Rayls Sovereign ledger:

TokenRegistryReplica.registerToken(tokenAddress, SharedObjects.ErcStandard.ERC20, false)

Once the Private Network Operator approves the registration, the relayer calls receiveResourceId() on the contract automatically, after which the token can be teleported between Rayls Sovereign ledgers using the registered resourceId as the routing key.

See Resource for details on the resourceId concept.


Did this page help you?