Skip to Content
Smart ContractsPaymentCollector

PaymentCollector

Chains: payment chains (Base is live; Ethereum / Optimism / Arbitrum / BNB planned) · Source: contracts/contracts/PaymentCollector.sol

One collector is deployed per payment chain. Buyers call it to purchase SETH — sending funds directly to a wallet does nothing (the plain receive() reverts with "use buy()"). The collector prices the payment in USD on-chain, computes the SETH owed, and emits the event the indexer fills against.

Buying

function buy(address sethRecipient) external payable; function buyWithToken(address token, uint256 amount, address sethRecipient) external;
  • buy — pay with the chain’s native coin. USD value = msg.value × latestNativeUsdPrice() / 1e18 (Chainlink native/USD, staleness checked).
  • buyWithToken — pay with an allowed stablecoin, valued at $1. Requires a prior approve(); uses transferFrom. USD value = amount × 1e8 / 10^tokenDecimals. Tolerates non-standard ERC-20s (e.g. USDT returning no data).

Both compute sethAmount = usdPaid × 1e18 / buyPriceUsd and emit:

event SethPurchased( address indexed buyer, address indexed sethRecipient, address token, // address(0) for native uint256 amountPaid, uint256 usdPaid, uint256 sethAmount, uint256 buyPriceUsd );

Quotes (view)

function nativeAmountForSeth(uint256 sethAmount) external view returns (uint256); // rounds up function tokenAmountForSeth(address token, uint256 sethAmount) external view returns (uint256); function latestNativeUsdPrice() public view returns (uint256);

Configuration (owner)

function setBuyPriceUsd(uint256 v) external onlyOwner; // BuyPriceChanged function setToken(address token, bool allowed, uint8 decimals) external; // TokenConfigured, onlyOwner function withdrawNative(address payable to, uint256 amount) external onlyOwner; function withdrawToken(address token, address to, uint256 amount) external onlyOwner; function changeOwner(address newOwner) external onlyOwner;

The buy price is a single USD value (8 decimals), the same for every buyer — there are no per-buyer tiers on the buy side. See Pricing & Tiers.

Views

owner() · version() · priceFeed() · maxPriceStaleSeconds() · buyPriceUsd() · tokenConfig(token){allowed, decimals} · totalUsdPaid() · totalSethSold().

Initialization

function initialize( address owner_, address nativeUsdFeed_, // Chainlink native/USD, must report 8 decimals uint256 buyPriceUsd_, uint256 maxPriceStaleSeconds_, address[] tokens_, uint8[] tokenDecimals_ ) external;

Events

SethPurchased · BuyPriceChanged · TokenConfigured · NativeWithdrawn · TokenWithdrawn · OwnerChanged.

Last updated on