Create and verify a proof
x402-avm-js creates proofs but does not verify them; verify on the server with ai-economy-sdk. On LocalNet, read the genesis hash from algod instead of using a preset. In algosdk v3 it is a Uint8Array, so encode it: algosdk.bytesToBase64((await algod.getTransactionParams().do()).genesisHash!).
PaymentGate verifies identity on every tool call with verify_identity: it checks X-Identity-Txn first, against the gate’s network, and falls back to the legacy headers. In your own server:
The two formats
sign_identity(private_key) signs the message x402-identity:<address>:<timestamp> with Ed25519 (algosdk’s sign_bytes) and returns the three headers. It emits a DeprecationWarning: use sign_identity_txn(), which binds the proof to one network. Servers keep accepting the legacy headers, and paid_mcp_session still sends them.
The identity transaction
make_identity_txn (Python) and buildIdentityTxn(address, genesisHashB64, ts?) (JavaScript) build:
The caller signs it, msgpack-encodes the signed transaction, base64-encodes the bytes and sends them as
X-Identity-Txn.
verify_identity_txn(header_value, expected_genesis_hash_b64, max_skew=120) returns the address, or None if any check fails:
- The header decodes to a signed transaction with a plain Ed25519 signature: no multisig, no logic signature, no rekeyed (authorized) signer.
- Type
pay, sender equals receiver, amount 0, fee 0, no close-to, no rekey-to. - The genesis hash equals the expected one.
- The validity window is at most 1,000 rounds.
- The note is
x402-identity:<sender>:<integer timestamp>and the timestamp is withinmax_skewseconds of the server’s clock. - The signature verifies against the sender’s public key.
verify_identity checks the address, the 120-second skew and the signature.
Examples
Python: sign a proof for the current LocalNet, verify it, and show that a different genesis hash is rejected.localnet/identity.py
localnet/identity.mjs
verify_identity_txn.
Next
- Pricing and passes: what servers do with the address.
- Identity reference