Repository navigation
v0.33.0
What's Changed
paidFetchandpaidAuthenticatedFetchtake an optionalidempotencyKey. The nonzero payment is signed with an EIP-3009 nonce derived from the key (idempotencyNonce(key), also exported), and USDC settles a given nonce at most once per payer, so retrying a purchase after a lost response or a crash cannot charge twice. A key requiresallowedAssetsto be exactly one USDC contract, and the payment must be for that USDC's network. A zero-value predicate-gate authorization keeps a random nonce. Without a key, nothing changes.
import { paidFetch, USDC_BASE_ADDRESS } from "@opensea/tool-sdk"
declare const signer: Parameters<typeof paidFetch>[1]["signer"]
declare const orderId: string
const res = await paidFetch("https://tool.example.com/api", {
method: "POST",
body: JSON.stringify({ query: "hello" }),
signer,
allowedAssets: [USDC_BASE_ADDRESS],
idempotencyKey: orderId,
})signEip3009Authorizationand the exact and upto schemes accept an explicitnonce.
Community Contributions
- Buyer-side idempotency for retried payments, thanks @cv-scvd for the report and reference design (tool-sdk#35)
Full Changelog: v0.32.2...v0.33.0