true402
guide · LangChain

Add a rug-check to your LangChain agent

If your LangChain agent can buy Base tokens, it can get rugged. Wire in a true402 rug-check tool and it will simulate a real buy/sell before committing capital — proving sellability instead of trusting a static scan.

Install and wire the rug-check tools into a LangChain agent
npm i @true402.dev/langchain @langchain/core

import { createTrue402Tools } from '@true402.dev/langchain';

const tools = createTrue402Tools({ payerPrivateKey: process.env.PAYER_PRIVATE_KEY! });
// add `tools` to any LangChain agent (createReactAgent, AgentExecutor, ...)
//
// Six tools: true402_token_report (primary pre-trade gate), true402_token_safety,
// true402_address_safety, true402_deployer_check, true402_tx_preflight (inspect an
// UNSIGNED tx before signing) and true402_liquidity_history (removals already observed).
§01 · the setup

Install the tools

The @true402.dev/langchain package exposes true402's safety stalls as ready-made LangChain tools. Install it alongside @langchain/core:

  1. Add the package: npm i @true402.dev/langchain @langchain/core
  2. Set a PAYER_PRIVATE_KEY env var — a Base wallet the agent controls. In true402 the wallet is the identity: there is no account to create and no API key to manage.
  3. Fund it later if you need volume — most safety stalls include a small free daily trial (deployer-check is the exception, see §04), so you can wire everything up and test before spending anything.

Under the hood each tool call is an x402 request: USDC on Base, pay-per-call, settled from the payer key you pass in.

§02 · the wiring

Add the rug-check tool to your agent

One factory call returns an array of tools you can drop into any LangChain agent — createReactAgent, AgentExecutor, or your own graph. There is nothing else to register.

  1. Import the factory: import { createTrue402Tools } from '@true402.dev/langchain';
  2. Build the tools with your payer key: const tools = createTrue402Tools({ payerPrivateKey: process.env.PAYER_PRIVATE_KEY! });
  3. Pass tools to your agent constructor exactly like any other LangChain tool array.

The agent can now call the stalls itself. The factory returns six tools: true402_token_report (POST /v1/base/token-report, composite avoid/caution/ok verdict, ~$0.01), true402_token_safety (POST /v1/token-safety, structural score 0-100, ~$0.005), true402_address_safety (POST /v1/base/address-safety, ~$0.005), true402_deployer_check (POST /v1/base/deployer-check, ~$0.008), true402_tx_preflight (POST /v1/base/tx-preflight, ~$0.008) and true402_liquidity_history (POST /v1/base/liquidity-history, ~$0.005). All hang off the API base https://true402.dev/api.

The last two cover what a pre-buy verdict cannot. true402_tx_preflight inspects the unsigned transaction the agent is about to sign — it takes no private key and no signature, so it cannot broadcast or front-run it — and returns a simulation against current state, the decoded intent (an unlimited approval is judged on the spender), and the counterparty's removal history. Call it last, immediately before signing. true402_liquidity_history reads what has already happened to the token's liquidity: every observed removal with amount, block and transaction hash, plus the other tokens drained in the same transaction. A live simulation is blind to this — a pool drained last month simulates fine today if it was re-seeded. Every answer states the block range the archive covers, so none observed is never a claim of safety.

§03 · the pattern

The pre-trade gate: check the verdict before you buy

Don't let the model decide in prose whether a token is safe. Make the rug-check a hard gate in your trade path: the agent must obtain a verdict from token-report and abort on anything that isn't ok.

  1. Before any buy, call token-report with the token address.
  2. Read the composite verdict: avoid → refuse the trade; caution → require an explicit override or downsize; ok → proceed.
  3. For a cheaper first pass, gate on token-safety's 0-100 structural score, then escalate to token-report only for borderline tokens.

What makes the verdict trustworthy is that token-report runs a real on-chain buy/sell honeypot simulation via state-override eth_call — it actually proves the token can be sold, rather than pattern-matching source code. It also folds in liquidity, ownership/mint authority, and deployer reputation. A static scanner can be fooled by a token that looks clean but blocks sells; a simulated sell cannot.

§04 · paying

Free trial, then per-call over x402

There is no billing dashboard and no key to rotate. Payment is settled per call straight from the payer wallet:

  1. Free daily trial — most safety stalls grant a small number of free calls per day, enough to build and test the gate without spending: token-report, token-safety, address-safety, tx-preflight and liquidity-history. deployer-check is excluded — it depends on a keyed third-party explorer API, so it is paid from the first call.
  2. Per-call over x402 — beyond the trial, each call costs a few tenths of a cent in USDC on Base (~$0.005–$0.01 depending on the stall). The createTrue402Tools factory handles the 402 → pay → retry flow using PAYER_PRIVATE_KEY.
  3. No account, no API key — the wallet is the identity, so onboarding a new agent is just funding a key.

See per-stall pricing and payloads in the API docs.

§05 · try it now

Zero-setup smoke test

Before touching your agent code, sanity-check any Base token from the terminal — no install, no key, runs on the free trial:

  1. Run npx @true402.dev/rugcheck 0x<token> against a token you already hold or are watching.
  2. Or paste an address into the hosted checker at true402.dev/check to see the same verdict your agent will receive.

Once the output looks right, drop createTrue402Tools into your agent and make it the gate in front of every buy.

§ questions

Answered for machines.

How is this different from a static token scanner?

A static scanner reads the contract and guesses. The true402 token-report runs a real on-chain buy/sell honeypot simulation using state-override eth_call, so it proves the token can actually be sold. It also weighs liquidity, ownership and mint authority, and deployer reputation into one verdict.

Do I need an API key or account?

No. true402 uses x402 payments where the wallet is the identity. You pass a PAYER_PRIVATE_KEY to createTrue402Tools and each call settles in USDC on Base. There is no signup, no dashboard, and no API key to store or rotate — funding a Base wallet is the entire onboarding step.

What does a rug check cost per call?

Most safety stalls carry a small free daily trial, so you can build and test for free — token-report, token-safety, address-safety, tx-preflight and liquidity-history are all in it. deployer-check is deliberately not: it needs a keyed third-party explorer API, so it is paid from the very first call. Beyond the trial you pay per call in USDC on Base: token-report is about $0.01; token-safety, address-safety and liquidity-history about $0.005; deployer-check and tx-preflight about $0.008. The factory handles the 402 payment flow.

How do I use the verdict as a trade gate?

Call token-report before any buy and branch on its composite verdict. Treat avoid as a hard refusal, caution as requiring an override or a smaller position, and ok as clear to proceed. Making it a code-level gate — not a prompt suggestion — is what actually stops the agent buying a honeypot.

Can I try it without changing my agent code?

Yes. Run npx @true402.dev/rugcheck 0x<token> from the terminal for a zero-setup check, or paste an address into the hosted checker at true402.dev/check. Both return the same verdict your agent will get, so you can validate a token before wiring the tool into your LangChain flow.