Smart Contract Reference

The on-chain surface of sBTC Pay. Function signatures, events, and where to find them on the explorer.

sBTC Pay's entire protocol logic lives in a single Clarity contract. This page lists the public-facing functions, the events they emit, and where to read the full source.

Deployed addresses

  • Mainnet: SPR54P37AA27XHMMTCDEW4YZFPFJX69162JR5CT4.sbtc-pay
  • Testnet: STR54P37AA27XHMMTCDEW4YZFPFJX69160WQESWR.payment-v6

Both deployments come from the same Clarity source. You can inspect source and transaction history on the Hiro Explorer.

Public functions

Merchant management

clarity
(register-merchant (name (string-ascii 64)))
(update-merchant
  (new-name (optional (string-ascii 64)))
  (new-description (optional (string-ascii 280)))
  (new-webhook-url (optional (string-ascii 256)))
  (new-logo-url (optional (string-ascii 256))))
(deactivate-merchant)
(reactivate-merchant)

Invoices

clarity
(create-invoice
  (amount uint)
  (memo (string-ascii 280))
  (reference-id (optional (string-ascii 64)))
  (expires-in-blocks uint)
  (allow-partial bool)
  (allow-overpay bool)
  (token-type uint))
(update-invoice
  (invoice-id uint)
  (new-amount (optional uint))
  (new-memo (optional (string-ascii 280)))
  (new-expires-in-blocks (optional uint)))
(cancel-invoice (invoice-id uint))
(pay-invoice (invoice-id uint) (amount uint))

Subscriptions

clarity
(create-subscription
  (merchant principal)
  (name (string-ascii 64))
  (amount uint)
  (interval-blocks uint)
  (token-type uint))
(process-subscription-payment (subscription-id uint))
(pause-subscription (subscription-id uint))
(resume-subscription (subscription-id uint))
(cancel-subscription (subscription-id uint))

Refunds

clarity
(process-refund
  (invoice-id uint)
  (amount uint)
  (reason (string-ascii 280)))

Read-only (no fee)

clarity
(get-merchant (principal principal))
(get-invoice (invoice-id uint))
(get-subscription (subscription-id uint))
(get-refund (refund-id uint))
(get-fee-rate)

Events

Every state-changing function emits a print event with a (tuple ...) payload. The webhook subscribes to these and indexes them into Postgres. The event's first field is always event, which identifies the type.

  • merchant-registered
  • merchant-updated
  • merchant-deactivated / merchant-reactivated
  • invoice-created
  • invoice-updated
  • invoice-cancelled
  • invoice-expired
  • payment-received
  • direct-payment
  • refund-processed
  • subscription-created
  • subscription-payment
  • subscription-paused / subscription-resumed
  • subscription-cancelled

Token types

Contract calls that move tokens accept a token-type uint:

  • u0 — sBTC
  • u1 — STX

Error codes

See the Error Codes page for the full catalog with plain-English explanations.

Reading source

The full Clarity source is in the open-source repository under contracts/payment-v6.clar. It's under 1,500 lines — readable in an hour. If you're evaluating for an audit or integration, reading the source is the most direct way to verify behavior.

Verifying deployed bytecode

The Hiro Explorer shows the deployed source verbatim — what you read there is exactly what runs on-chain. No hidden bytecode or proxies. You can also use clarinet check locally to verify the source compiles.