Read-only client for on-chain contract calls
Hook behavior options
A hook for registration on t402Client
import { createPublicClient, http } from "viem";
import { base } from "viem/chains";
import { erc8004IdentityCheck } from "@t402/erc8004";
const viemClient = createPublicClient({ chain: base, transport: http() });
const client = new t402Client()
.register("eip155:8453", evmScheme)
.onBeforePaymentCreation(erc8004IdentityCheck(viemClient));
const fetchWithPay = wrapFetchWithPayment(fetch, client);
Create a BeforePaymentCreationHook that verifies agent identity before signing a payment.
Works with
t402Client.onBeforePaymentCreation(), which means it automatically applies to@t402/fetchand@t402/axioswrappers.