Teleport tokens
ERC 20 Token Teleport
Now, let's create our first ERC20 token with the ability to be teleported across the Private Network.
To do it, we will inherit the RaylsErc20Handler abstract contract in our token example.
// 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
| Parameter | Description |
|---|---|
_name | ERC20 token name |
_symbol | ERC20 token symbol |
_endpoint | Address of the Privacy Node endpoint contract — used to route messages to other Privacy Nodes via the Private Network Hub |
_raylsNodeEndpoint | Address of the Privacy Node endpoint contract for the Rayls Public Chain — used when teleporting to/from the public chain |
_userGovernance | Address of the RBAC contract that manages user roles and permissions within the Privacy Node |
_owner | Address that will be granted the Owner role (mint, burn, token updates) |
The last parameter (false) marks this as a standard token. Pass true only for custom handler implementations that override the default transfer behavior.
Resource ID
Every token in the Rayls network is identified by a unique resourceId (bytes32). You do not pass this in the constructor.
After deploying your token, call registerToken on the Privacy Node's TokenRegistryReplica system contract:
TokenRegistryReplica.registerToken(tokenAddress, ErcStandard.ERC20, false)Once the Private Hub operator approves the registration, the relayer calls receiveResourceId() on your contract automatically. After that, your token can be teleported across Privacy Nodes using the registered resourceId as the routing key.
See Resource for details on the resourceId concept.
Updated 17 days ago
