You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,15 @@
1
1
# @opensea/tool-sdk
2
2
3
+
## 0.14.1
4
+
5
+
### Patch Changes
6
+
7
+
- 776788d: Fix usage reporting to attribute the real caller, and make reporting a service-side-only responsibility.
8
+
9
+
- x402 usage reports now use the on-chain payer as `caller_address` (after any gate-verified caller), instead of a placeholder address.
10
+
- EIP-3009 usage reports now forward the caller's original signed authorization, stashed by `predicateGate` on `ctx.callerAuthorization` and surfaced via `InvocationEvent.callerAuthorization`. The server no longer re-signs as itself.
11
+
- Removed `walletClient`, `operatorAddress`, and `tokenAddress` from `Eip3009UsageReporterConfig`. Reporting is authenticated by `apiKey`, and there is no caller self-reporting or signing path. `signZeroValueAuthorization` remains exported for building `Authorization: EIP-3009` request headers.
Copy file name to clipboardExpand all lines: README.md
+22-18Lines changed: 22 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -841,7 +841,7 @@ See [docs/predicate-gating-guide.md](docs/predicate-gating-guide.md) for the ful
841
841
842
842
## Usage Reporting
843
843
844
-
Report tool invocations to OpenSea's analytics endpoint (`POST /api/v2/tools/usage`) using EIP-3009 zero-value authorizations for caller verification.
844
+
Report tool invocations to OpenSea's analytics endpoint (`POST /api/v2/tools/usage`). For each call the SDK reports the **verified caller**: the on-chain **payer** for paid x402 calls, or the caller's **own EIP-3009 authorization**for calls authenticated by `predicateGate`. A tool server never signs on the caller's behalf.
toolOnchainId: 42, // ERC-8257: tool ID in registry
871
+
toolOnchainId: 42, // ERC-8257: tool ID in the registry
873
872
apiKey: process.env.OPENSEA_API_KEY!,
874
873
},
875
874
})
876
875
```
877
876
878
-
That's it — the handler fires the reporter as a fire-and-forget async call at the very end of the lifecycle, after the response is built. It never blocks or fails the tool call. Free calls send a signed EIP-3009 authorization; paid x402 calls send the settlement tx hash.
877
+
> **Reporting is the service's job, never the caller's.** The `apiKey` authenticates *you* (the operator) as the reporter. The caller is identified by data they already supplied (the x402 payer, or the EIP-3009 authorization `predicateGate` verified), so no caller wallet, signing, or `walletClient` is involved.
878
+
879
+
That's it: the handler fires the reporter as a fire-and-forget async call at the very end of the lifecycle, after the response is built. It never blocks or fails the tool call.
879
880
880
881
### How it works
881
882
882
-
The caller's wallet signs a zero-value EIP-3009 `TransferWithAuthorization` message (USDC domain, `value = 0`) proving address ownership. The SDK sends this signature plus the ERC-8257 composite key to the endpoint. No tokens are transferred — this is purely for identity verification and analytics.
883
+
-**Paid (x402) calls** report `verification_type: "x402_settlement"` with the on-chain payer address and the settlement transaction hash. The backend verifies the settlement directly, so no signature is needed.
884
+
-**EIP-3009-authenticated calls** (e.g. behind `predicateGate`) report `verification_type: "eip3009_authorization"` by **forwarding the caller's original zero-value `TransferWithAuthorization`** (USDC domain, `value = 0`). The caller already signed it to authenticate; the SDK passes that exact signature through, so the reported identity is the real caller, not the server. No tokens are transferred.
883
885
884
886
### Configuration reference
885
887
886
888
| Field | Required | Description |
887
889
|-------|----------|-------------|
888
-
|`walletClient`| Yes | Caller's viem `WalletClient` with attached account |
889
-
|`chainId`| Yes | Chain ID for the EIP-712 USDC domain (1, 8453, 137, 42161, 10, 43114) |
890
-
|`operatorAddress`| Yes | Tool operator address (used as `to` in the authorization) |
890
+
|`chainId`| Yes | Chain ID for the EIP-712 USDC domain / x402 `chain_id` fallback (1, 8453, 137, 42161, 10, 43114) |
891
891
|`toolChainId`| Yes | ERC-8257 composite key: chain of registration |
|`toolOnchainId`| Yes | ERC-8257 composite key: numeric tool ID |
894
-
|`apiKey`| Yes | OpenSea API key ([get one here](https://docs.opensea.io/reference/api-keys)) |
894
+
|`apiKey`| Yes | OpenSea API key ([get one here](https://docs.opensea.io/reference/api-keys)). Authenticates the tool service as the reporter|
895
895
|`aggregatorUrl`| No | Override endpoint URL (default: `https://api.opensea.io/api/v2/tools/usage`) |
896
-
|`tokenAddress`| No | Override USDC address (default: canonical address for `chainId`) |
897
896
|`timeoutMs`| No | Request timeout in ms (default: 5000) |
898
897
899
898
### Standalone Reporters
900
899
901
-
If you need to report usage outside the handler flow (e.g. from a client or a custom pipeline), use the standalone reporter functions directly:
900
+
If you report usage outside the handler flow (a custom pipeline or a separate reporting service), use the standalone reporter functions directly.
902
901
903
902
#### EIP-3009 Reporter
904
903
904
+
Forwards a caller's already-collected EIP-3009 authorization. Pass an `InvocationEvent` whose `callerAuthorization` holds the authorization your auth layer verified:
Copy file name to clipboardExpand all lines: skill/SKILL.md
+18-21Lines changed: 18 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -377,45 +377,42 @@ All CLI commands accept `--wallet-provider privy|turnkey|fireblocks|private-key`
377
377
378
378
## 7. Usage Tracking
379
379
380
-
Tool-sdk supports usage tracking via the `onInvocation` callback on `createToolHandler`. This fires after every successful invocation (post-settle, pre-response) with an `InvocationEvent` containing caller identity, payment status, and timing.
380
+
Tool-sdk reports usage to OpenSea's analytics endpoint (`POST /api/v2/tools/usage`) for each successful call. It reports the **verified caller**: the on-chain payer for paid x402 calls, or the caller's own EIP-3009 authorization for `predicateGate`-authenticated calls. A tool server never signs on the caller's behalf.
381
381
382
-
### createEip3009UsageReporter (recommended)
382
+
### usageReporting (recommended)
383
383
384
-
`createEip3009UsageReporter` is the recommended `onInvocation` implementation. It reports tool usage via EIP-3009 zero-value `TransferWithAuthorization` signatures:
384
+
Pass `usageReporting` to `createToolHandler` and it fires the reporter as a fire-and-forget call at the very end of the lifecycle (after the response is built). No `walletClient` is needed server-side:
385
385
386
-
-**Free / gated calls**: signs a zero-value authorization proving the operator controls the wallet, and POSTs with `verification_type: "eip3009_authorization"`.
387
-
-**Paid x402 calls**: POSTs with `verification_type: "x402_settlement"` and the settlement tx hash — no additional signature needed.
386
+
-**Paid x402 calls** → `verification_type: "x402_settlement"` with the payer address and settlement tx hash. The backend verifies the tx directly.
387
+
-**EIP-3009-authenticated calls** (behind `predicateGate`) → `verification_type: "eip3009_authorization"`, **forwarding the caller's original signed authorization**. The caller already signed it to authenticate, so the reported identity is the real caller.
Reporting is always the service's responsibility (authenticated by `apiKey`), never the caller's; there is no caller self-reporting path. To report from a custom pipeline instead of the handler, use the standalone `createEip3009UsageReporter` / `createX402UsageReporter` (see the tool-sdk README "Usage Reporting" section).
412
+
416
413
### onInvocation callback
417
414
418
-
You can also provide a custom `onInvocation` callback for bespoke analytics:
415
+
You can also provide a custom `onInvocation` callback for bespoke analytics. It fires after the handler succeeds and settles, before the response is returned, with an `InvocationEvent` containing caller identity, payment status, and timing:
0 commit comments