Skip to content
Open app

Contract interface

AI-generated

EthXmrIntentSwap is the immutable native-ETH escrow contract. This reference describes v0.5.

Value Representation
ETH principal/bond uint256 wei; 1 ETH = 10^18 wei
XMR minimum/bid uint64 piconero; 1 XMR = 10^12 piconero; maximum 18,446,744.073709551615 XMR
Difficulty Positive uint128 integer
Minimum height Positive uint64 block height
Timestamps/window Unix seconds / whole seconds; window is uint32
Bond rate Basis points; 10,000 = 100%
constructor(
address sp1Verifier,
bytes32 programVKey,
uint32 bondBps,
uint32 auctionSeconds,
uint32 minSettlementWindowSeconds,
uint32 maxSettlementWindowSeconds
)

The verifier must have code; the program key and bond/auction/window values must be nonzero, with minimum window no greater than maximum. The constructor does not cap bond basis points at 10,000.

function createIntent(
bytes calldata recipientAddress,
uint64 minXmrAmount,
uint64 minPaymentHeight,
uint128 randomxDifficulty,
uint32 settlementWindowSeconds
) external payable returns (bytes32 swapId);
function placeBid(bytes32 swapId, uint64 bidXmrAmount) external payable;
function settle(
bytes32 swapId,
bytes32 txid,
bytes32 outputKey,
bytes calldata proof
) external;
function expire(bytes32 swapId) external;
Action ETH value Authorization and result
createIntent Positive principal Caller becomes user; stores immutable intent terms.
placeBid Exactly floor(principal × BOND_BPS / 10,000) Any caller before close, strictly higher amount; replaces winner.
settle Zero Any caller within the settlement interval with valid proof; pays stored winner.
expire Zero Any caller after the applicable expiry boundary; pays stored user.

All actions are nonreentrant and use checked arithmetic. Bids do not extend the auction.

getSwap(bytes32 swapId) returns the following LiveSwap tuple, or reverts with SwapNotFound:

Field Type Meaning
user address Original caller and refund recipient
recipientAddress bytes Exact 95-byte recipient
ethPrincipal uint256 Native ETH principal in wei
bestSolver address Current winner; zero before the first bid
bestXmrAmount uint64 Winning piconero; minimum minus one before bidding
minPaymentHeight uint64 Minimum height checked in the miner transaction
randomxDifficulty uint128 Fixed work threshold
auctionEndTimestamp uint256 First timestamp at which bidding is closed
deadlineTimestamp uint256 First timestamp at which winning-bid settlement is too late

Terminal rows are deleted; use events to distinguish settlement from expiry.

swapId = keccak256(abi.encode(block.chainid, address(this), ++intentCounter));
nullifier = keccak256(abi.encode(recipientAddress, outputKey));

usedTxid consumes a payment transaction across all recipients in one deployment. usedOutputKey consumes the recipient/output hash, not the raw output key. Both use successful settlement only; reverted settlement and expiry consume neither. Standard ABI encoding is required, not abi.encodePacked.

Monero txids/output keys are raw 32-byte values, displayed as hex. An Ethereum transaction hash and a swap ID identify different objects. Replay markers do not span deployments.

Getter Return type Meaning
SP1_VERIFIER() address Immutable gateway
PROGRAM_VKEY() bytes32 Immutable guest key
BOND_BPS() uint32 Immutable bond basis points
AUCTION_SECONDS() uint32 Immutable auction duration
MIN_SETTLEMENT_WINDOW_SECONDS() uint32 Inclusive minimum window
MAX_SETTLEMENT_WINDOW_SECONDS() uint32 Inclusive maximum window
SP1_VERIFIER_SELECTOR() bytes4 0x4388a21c
BID_REFUND_GAS() uint256 10,000 gas passed to displaced-bidder refunds
MIN_GAS_BEFORE_REFUND() uint256 100,000 pre-refund gas threshold
intentCounter() uint256 Number used in generating unique swap IDs
usedTxid(bytes32) bool Whether that transaction ID has settled
usedOutputKey(bytes32) bool Whether that recipient/output nullifier hash has settled

There is no owner, upgrade, pause, cancellation, withdrawal, or rescue interface. See the lifecycle for transfer failures and exact timing.