mppx/client library to handle the payment flow automatically.
Prerequisites
- A Crossmint EVM wallet with USDC. See the Wallets quickstart.
- The agent must be authorized as a signer on the wallet. See Authorize the Agent.
Install dependencies
Pay an MPP endpoint
mpp-payment.tsx
How the code works
1
Create a wallet client from the Crossmint wallet
The
EVMWallet.from(wallet) call wraps the Crossmint wallet into an EVM-compatible interface. A custom EIP-1193 request handler is created that delegates eth_sendTransaction calls to the Crossmint wallet, which sends transactions using the agent’s delegated permissions.2
Build a viem wallet client
A viem
walletClient is created with the custom transport, targeting the Tempo devnet chain. This client bridges the Crossmint wallet to standard EVM tooling.3
Initialize the MPPX client with Tempo
Mppx.create initializes the MPP client with the tempo payment method in push mode. The getClient callback provides the wallet client for signing and sending payment transactions.4
Fetch the MPP endpoint
mppx.fetch works like a standard fetch call but automatically handles MPP payment negotiation. If the endpoint requires payment, the client pays via Tempo and retries the request.
