Commit to an offer
Committing to an offer transfers the buyer's price into escrow, mints a voucher (rNFT) to the buyer's wallet, and creates an exchangeId. The exchange starts in the COMMITTED state.
For ERC-20 offers, the buyer must first approve the Diamond to spend the token — or use one of the token-auth meta-tx variants to combine approval and commit in one signed envelope.
ERC-20 commit (two steps)
SDK
// 1. Approve the token (skip if you've already approved >= amount).
// First arg is the ERC-20 token address, not the offerId.
await (await sdk.approveExchangeToken(exchangeTokenAddress, /* amount */ "1000000")).wait()
// 2. Commit. Signature is commitToOffer(offerId, overrides?); the buyer is the signer.
const tx = await sdk.commitToOffer(offerId)
const receipt = await tx.wait()
const exchangeId = sdk.getCommittedExchangeIdFromLogs(receipt.logs)Native-token commit (one step)
If the offer's exchangeToken is address(0), no approval — attach msg.value:
const tx = await sdk.commitToOffer(offerId, { value: offer.price })Gas-less commit (meta-tx)
Use a meta-transaction to have someone else pay gas:
const signedMetaTx = await sdk.metaTx.signMetaTxCommitToOffer({
buyer: wallet.address,
offerId,
})
await sdk.metaTx.relayMetaTransaction(signedMetaTx)For the token-auth meta-tx flow (single-signature approve + commit), see Recipes → Gas-less commit and Recipes → ERC-20 approve + commit.
Atomic commit-and-redeem
If you want to commit and redeem in one transaction (typical for digital goods), see Atomic commit-and-redeem.
Common gotchas
- Approve > price. Approve more than
offer.priceto allow for multiple commits without re-approving each time. - Don't commit to a
validUntilDate-expired offer. The tx will revert withOfferHasExpired. - Token-gated offers require holding the gating token at commit time. If you don't, the tx reverts with
CannotCommit. - Indexing lag after commit. Wait for
waitForGraphNodeIndexing(receipt.blockNumber)before readinggetExchanges.