# Toolrail: one x402 request from Node.js

Use Node.js 22 or later. Download `x402-buyer.mjs` into an empty local folder.

## Inspect without paying

```sh
node x402-buyer.mjs
```

This requests a public quote for converting 50 UF to CLP. It does not sign or
send a payment. The example checks x402 v2, Base mainnet, native USDC, Toolrail's
recipient and a maximum of 0.005 USDC per request.

## Make one paid request

```sh
npm init -y
npm install @x402/fetch@2.26.0 @x402/evm@2.26.0 viem
```

Provide `TOOLRAIL_PRIVATE_KEY` through your local environment or secret manager.
Use a dedicated wallet funded with USDC on Base. Do not put the key in source
code or share it in a chat. Setting `TOOLRAIL_PAY=1` authorizes this script to
sign one payment, up to 0.005 USDC, for the fixed URL in the example.

PowerShell, after configuring the key locally:

```powershell
$env:TOOLRAIL_PAY = '1'
node x402-buyer.mjs
Remove-Item Env:TOOLRAIL_PAY
```

The SDK obtains a quote, signs the authorization and retries with
`PAYMENT-SIGNATURE`. The script does not follow redirects or run a retry loop.
To try Toolrail without a wallet, use https://toolrail.dev/probar or connect the
free MCP at https://toolrail.dev/mcp (30 tool calls per client per UTC day).
