Register the payment handler
Register the payment service worker once during app initialisation, before any payment flow. This enables the browser’s Payment Request API to discover HyperAuth as a payment method.registerPaymentHandler registers the service worker at /pay/sw.js with scope /pay/ and the payment method URL https://did.run/pay. Override any of these if your deployment differs:
registerPaymentHandler returns { success: false, error: 'Service workers not supported' } rather than throwing.
Submit a payment
submitPayment builds and signs an ERC-4337 UserOperation that transfers tokens to the recipient, submits it to the bundler, and returns the user operation hash and an explorer URL.
The vault must be unlocked to sign the payment. Signing happens inside the Dedicated Worker running enclave.wasm; the signed operation is then submitted directly to the Pimlico bundler endpoint.
label field is optional and for your own record-keeping only.
Supported chains
The explorer URL is automatically set based onchainId:
For any other chain ID, the URL defaults to etherscan.io.
Error handling
submitPayment throws a PluginCallError if signing fails (e.g. vault is locked) or if the bundler rejects the operation.
submitPayment does not wait for on-chain confirmation. To wait for the UserOp to be included in a block, use waitForReceipt with the returned userOpHash: