RaylsEnygmaHandler
RaylsEnygmaHandler is the abstract base contract for Enygma tokens on a Rayls Privacy Node. Enygma is the Rayls settlement currency — an ERC20 token with cross-chain transfer and DvP (Delivery vs. Payment) capabilities.
Inheritance: RaylsApp, ERC20, Initializable, ReentrancyGuard, RaylsAccessManaged
Note: Enygma tokens are deployed and managed by the Rayls network operator. You extend this contract only when building a custom Enygma implementation. For standard usage, interact with the deployed Enygma contract directly.
Constructor
constructor(
string memory _name,
string memory _symbol,
address _endpoint,
address _owner,
uint8 _decimals,
bool _isCustom
)| Parameter | Description |
|---|---|
_name | Token name |
_symbol | Token symbol |
_endpoint | Privacy Node endpoint |
_owner | Address granted the Owner role (mint, burn, setSwapValidityTime) |
_decimals | Token decimals (max 18) |
_isCustom | false for standard Enygma, true for custom implementations |
Cross-chain transfers
Enygma supports multi-destination transfers in a single call. Each transfer leg can trigger an optional smart contract call on the destination chain.
crossTransfer — multi-destination batch
crossTransfer — multi-destination batchfunction crossTransfer(
address[] memory _to,
uint256[] memory _value,
uint256[] memory _toChainId,
SharedObjects.EnygmaCrossTransferCallable[][] memory _callables
) public virtual returns (bytes32)Transfers _value[i] to _to[i] on chain _toChainId[i]. Each leg can optionally trigger a contract call via _callables[i].
crossTransferFrom — third-party batch
crossTransferFrom — third-party batchfunction crossTransferFrom(
address _from,
address[] memory _to,
uint256[] memory _value,
uint256[] memory _toChainId,
SharedObjects.EnygmaCrossTransferCallable[][] memory _callables
) public virtual returns (bytes32)Same as crossTransfer but deducts from _from (requires prior approval).
linearCrossTransfer — single destination (simplified)
linearCrossTransfer — single destination (simplified)function linearCrossTransfer(
address _to,
uint256 _value,
uint256 _toChainId,
bytes32 _callableResourceId,
address _callableContractAddress,
bytes calldata _callablePayload
) public virtual returns (bytes32)Convenience wrapper for a single-destination transfer with an optional callable. Use bytes32(0) / address(0) for the unused routing field.
linearCrossTransferFrom — third-party single destination
linearCrossTransferFrom — third-party single destinationfunction linearCrossTransferFrom(
address _from,
address _to,
uint256 _value,
uint256 _toChainId,
bytes32 _callableResourceId,
address _callableContractAddress,
bytes calldata _callablePayload
) public virtual returns (bytes32)Transfer status tracking
Every transfer returns a referenceId (bytes32). Use it to track the transfer state:
// Returns status as uint256
function referenceIdStatusUint(bytes32 _referenceID) public view virtual returns (uint256)
// Returns status as enum
function referenceIdStatus(bytes32 _referenceID) public view virtual returns (ReferenceIdStatus)ReferenceIdStatus values: NOSTATUS, SENT, RECEIVED, DEPOSITED, WITHDRAW_ASKED, WITHDRAW_RECEIVED.
DvP (Delivery vs. Payment)
Enygma is the payment leg of cross-chain DvP swaps. The NFT seller's handler initiates the swap; Enygma handles the payment side.
Deposit into DvP
Burns the caller's tokens and locks them for the swap:
function depositToDvp(uint256 amount) public virtual returns (bytes32)Zero deposits are allowed (e.g., gifting an NFT with no payment required).
Initiate swap — ERC721
function swapWithDvpForERC721(
uint256 _nftId,
bytes32 _nftResourceId,
uint256 _enygmaAmount,
uint256 _destChainId,
bytes32 _sharedId,
SharedObjects.DvpProgramability calldata _msg,
uint64 _validityTime
) public virtual nonReentrantInitiate swap — ERC1155
function swapWithDvpForERC1155(
uint256 _nftId,
uint256 _nftValue,
bytes32 _nftResourceId,
uint256 _enygmaAmount,
uint256 _destChainId,
bytes32 _sharedId,
SharedObjects.DvpProgramability calldata _msg,
uint64 _validityTime
) public virtual nonReentrantWithdraw from DvP
After the swap completes, the NFT seller calls this to receive their Enygma:
function callWithdrawFromDvp(uint256 amount) public virtual returns (bytes32)The relayer processes the withdrawal and calls receiveWithdrawFromDvp to mint the Enygma to the recipient.
Cancel swap
function cancelERC721Swap(bytes32 _sharedId, uint256 _toChainId, uint256 _nftId, bytes32 _nftResourceId, uint256 _enygmaAmount) public virtual nonReentrant
function cancelERC1155Swap(bytes32 _sharedId, uint256 _toChainId, uint256 _nftId, uint256 _nftValue, bytes32 _nftResourceId, uint256 _enygmaAmount) public virtual nonReentrantMint and burn
// Owner role only
function mint(address _to, uint256 _value) public virtual restricted
// Owner role only
function burn(address from, uint256 value) public virtual restrictedSwap validity time
// Owner role only
function setSwapValidityTime(uint64 _validityTime) public virtual restrictedAccess control summary
| Role | Functions |
|---|---|
| Owner | mint, burn, setSwapValidityTime |
| RELAYER | crossRevertMint, crossMint, crossTransferRevertBatch, supplyUpdateRevert, receiveWithdrawFromDvp, dvpSwapCompleted, notifySenderWithPNCommunicator, notifySenderAndReceiverWithPNCommunicator |
| MESSAGE_EXECUTOR | receiveResourceId, crossTransferCheck |
| Any address | crossTransfer, crossTransferFrom, linearCrossTransfer, linearCrossTransferFrom, depositToDvp, callWithdrawFromDvp, swapWithDvpForERC721, swapWithDvpForERC1155, cancelERC721Swap, cancelERC1155Swap |
Updated about 2 hours ago
