Contracts
Santa's Rust NEAR Testnet escrow contract.
The Rust contract source is in packages/contracts/near/src/lib.rs. It implements NEP-141 ft_on_transfer escrow, an owner-managed token allowlist, sponsored claims, one-use claim nonces, and expiry refunds.
The verified escrow is gifts.santa-gifts.testnet, with token.santa-gifts.testnet as its allowlisted test token. Deployment requires an existing NEAR Testnet contract account and is performed explicitly with npm run near:contract:deploy:testnet.
Contract methods
new(owner_id, relayer_id, allowed_tokens)initializes a fresh account.ft_on_transfer(sender_id, amount, msg)accepts transfers only from allowlisted token contracts, with validated gift terms. Invalid transfers are returned to the FT contract for refund.get_gift(gift_id)andget_next_gift_id()are public views.get_config()reads the owner/relayer, andis_claim_nonce_used(nonce)lets the relayer reject replay before spending gas or token-registration deposits.claim_gift(gift_id, secret, recipient_id, nonce)is restricted to the configured relayer, checks the claim commitment and expiry, consumes a nonce, then transfers the FT.refund_gift(gift_id)returns an expired open gift to its sender.set_token_allowedandset_relayerare restricted to the owner.
External NEP-141 transfer outcomes are asynchronous. Private callbacks finalize Claimed / Refunded states only after the FT transfer succeeds.
Test with npm run near:contract:test and compile with npm run near:contract:build.