operator/pallets/datahaven-native-transfer/README.md
A Substrate pallet that enables cross-chain transfers of DataHaven native tokens to and from Ethereum using the Snowbridge infrastructure.
This pallet facilitates the transfer of DataHaven (DH) native tokens to Ethereum, where they are represented as wrapped ERC20 tokens. It implements a lock-and-mint mechanism: tokens are locked on DataHaven when transferred to Ethereum, and unlocked when transferred back.
Fees are mandatory for all transfers and serve to:
The fee is:
When calculating fees, consider:
Example calculation:
Ethereum gas required: 100,000 gas
Gas price: 30 gwei
ETH cost: 0.003 ETH
DH/ETH rate: 1000 DH per ETH
Base fee: 3 DH
With 20% margin: 3.6 DH
transfer_to_ethereumTransfer DataHaven native tokens to an Ethereum address.
Parameters:
origin: The account initiating the transferrecipient: The Ethereum address (H160) to receive the tokensamount: The amount of tokens to transferfee: The fee to cover Ethereum gas costs and incentivize relayers (must be non-zero)pausePause all transfers. Only callable by PauseOrigin (typically governance).
unpauseResume transfers after pause. Only callable by PauseOrigin.
total_locked_balanceGet the total balance of tokens locked in the Ethereum sovereign account.
ethereum_sovereign_accountGet the account ID of the Ethereum sovereign account for monitoring purposes.
TokensLocked: Emitted when tokens are locked for transferTokensUnlocked: Emitted when tokens are unlocked from EthereumTokensTransferredToEthereum: Emitted on successful transfer to EthereumPaused: Emitted when the pallet is pausedUnpaused: Emitted when the pallet is unpausedInsufficientBalance: Account has insufficient balance for transferOverflow: Arithmetic overflow in calculationsSendMessageFailed: Failed to send message through SnowbridgeInvalidEthereumAddress: Provided Ethereum address is zeroInvalidAmount: Transfer amount is zeroTransfersDisabled: Transfers are pausedZeroFee: Fee cannot be zeroPreservation::Preserve to maintain existential deposits