mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## DataHaven Native Transfer Precompile Implements EVM precompile at address `0x00000000000000000000000000000007F5` (2073) to expose `pallet-datahaven-native-transfer` functionality to the EVM layer. ### Features - **Transfer to Ethereum**: Locks native tokens and sends them via Snowbridge to Ethereum addresses - **Pause/Unpause**: Admin controls to halt/resume transfers - **View Functions**: Query paused state, total locked balance, and sovereign account address ### Implementation - Precompile using `#[precompile_utils::precompile]` macro with proper gas accounting - 15+ test cases covering success/failure scenarios - Solidity interface with NatSpec documentation for contract integration Enables seamless cross-chain transfers of DataHaven native tokens to Ethereum L1. --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
49 lines
2.4 KiB
Solidity
49 lines
2.4 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0-only
|
|
pragma solidity >=0.8.3;
|
|
|
|
/// @dev The DataHavenNativeTransfer precompile address.
|
|
address constant DATAHAVEN_NATIVE_TRANSFER_ADDRESS = 0x0000000000000000000000000000000000000819;
|
|
|
|
/// @dev The DataHavenNativeTransfer precompile instance.
|
|
DataHavenNativeTransfer constant DATAHAVEN_NATIVE_TRANSFER_CONTRACT =
|
|
DataHavenNativeTransfer(DATAHAVEN_NATIVE_TRANSFER_ADDRESS);
|
|
|
|
/// @author The DataHaven Team
|
|
/// @title DataHaven Native Transfer Interface
|
|
/// @notice Interface for transferring DataHaven native tokens to/from Ethereum via Snowbridge
|
|
/// @custom:address 0x0000000000000000000000000000000000000819
|
|
interface DataHavenNativeTransfer {
|
|
/// @notice Emitted when tokens are locked for transfer to Ethereum
|
|
/// @param account The account that locked tokens
|
|
/// @param amount The amount of tokens locked
|
|
event TokensLocked(address indexed account, uint256 amount);
|
|
|
|
/// @notice Emitted when tokens are transferred to Ethereum
|
|
/// @param from The account initiating the transfer
|
|
/// @param to The Ethereum address receiving the tokens
|
|
/// @param amount The amount of tokens transferred
|
|
event TokensTransferredToEthereum(address indexed from, address indexed to, uint256 amount);
|
|
|
|
/// @notice Transfer DataHaven native tokens to Ethereum
|
|
/// @dev Locks tokens in the sovereign account and sends message through Snowbridge
|
|
/// @param recipient Ethereum address to receive the tokens
|
|
/// @param amount Amount of tokens to transfer (in smallest unit)
|
|
/// @param fee Fee to incentivize relayers (in smallest unit)
|
|
/// @custom:selector 0a3727e3
|
|
function transferToEthereum(address recipient, uint256 amount, uint256 fee) external;
|
|
|
|
/// @notice Check if the pallet is currently paused
|
|
/// @return paused True if paused, false otherwise
|
|
/// @custom:selector b187bd26
|
|
function isPaused() external view returns (bool paused);
|
|
|
|
/// @notice Get total amount of tokens locked in Ethereum sovereign account
|
|
/// @return balance Total locked balance
|
|
/// @custom:selector 05480e10
|
|
function totalLockedBalance() external view returns (uint256 balance);
|
|
|
|
/// @notice Get the Ethereum sovereign account address
|
|
/// @return account The sovereign account address (as H160)
|
|
/// @custom:selector 71f9ae03
|
|
function ethereumSovereignAccount() external view returns (address account);
|
|
}
|