RaylsEnygmaHandler
RaylsEnygmaHandler is the abstract base contract for Enygma tokens in the Rayls Sovereign ledger. 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 you are 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 | Rayls Sovereign endpoint |
_owner | Address granted the Owner role (mint, burn, setSwapValidityTime) |
_decimals | Token decimals, to a maximum of 18 |
_isCustom | false for standard Enygma, true for custom implementations |
Cross-chain transfers
Enygma supports multi-destination transfers in a single call, and 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)This transfers _value[i] to _to[i] on chain _toChainId[i], and each leg can optionally trigger a contract call through _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)This behaves in the same way as crossTransfer, except that it deducts from _from, which 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)This is a convenience wrapper for a single-destination transfer with an optional callable. Use bytes32(0) or 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), which you can use to track the state of that transfer:
// 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)The ReferenceIdStatus values are NOSTATUS, SENT, RECEIVED, DEPOSITED, WITHDRAW_ASKED and WITHDRAW_RECEIVED.
DvP (Delivery vs. Payment)
Enygma is the payment leg of cross-chain DvP swaps, so the NFT seller's handler initiates the swap and Enygma handles the payment side.
Deposit into DvP
This burns the caller's tokens and locks them for the swap:
function depositToDvp(uint256 amount) public virtual returns (bytes32)Zero deposits are allowed, for example when an NFT is gifted with no payment required.
Initiate swap — ERC721
function swapWithDvpForERC721(
uint256 _nftId,
bytes32 _nftResourceId,
uint256 _enygmaAmount,
uint256 _destChainId,
bytes32 _sharedId,
uint64 _validityTime
) public virtualInitiate swap — ERC1155
function swapWithDvpForERC1155(
uint256 _nftId,
uint256 _nftAmountOrOne,
bytes32 _nftResourceId,
uint256 _enygmaAmount,
uint256 _destChainId,
bytes32 _sharedId,
uint64 _validityTime
) public virtualWithdraw from DvP
Once the swap has completed, the NFT seller calls this function to receive their Enygma:
function callWithdrawFromDvp(uint256 amount) public virtual returns (bytes32)The relayer processes the withdrawal and then 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
function cancelERC1155Swap(bytes32 _sharedId, uint256 _toChainId, uint256 _nftId, uint256 _nftAmountOrOne, bytes32 _nftResourceId, uint256 _enygmaAmount) public virtualMint 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 5 days ago
