Skip to content

v0.33.0

Choose a tag to compare

@ryanio ryanio released this 09 Nov 22:57
· 6 commits to main since this release

What's Changed

  • paidFetch and paidAuthenticatedFetch take an optional idempotencyKey. 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 requires allowedAssets to 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,
})
  • signEip3009Authorization and the exact and upto schemes accept an explicit nonce.

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