Read the bytecode
Paste any mainnet account. BitLens fetches the deployed WASM and reads its host imports, exported methods and token standards: can it send NEAR, add keys, redeploy itself, call other contracts?
Security scanner for NEAR smart contracts
BitLens reads a contract's deployed WASM, tells you what it can do, then attacks the real bytecode in a local NEAR runtime and reports which defences held and which broke. No source code needed.
Read-only: BitLens only makes RPC view_code / view_access_key_list queries and never sends a transaction. Attacks run in a local simulator.
admin_drain: the attacker walked away with +67.8015 NEAR.set_owner was rejected: only the owner can call this.Paste any mainnet account. BitLens fetches the deployed WASM and reads its host imports, exported methods and token standards: can it send NEAR, add keys, redeploy itself, call other contracts?
The real bytecode runs in a local NEAR runtime (near-contract-sim) with an owner, a victim and an attacker: unauthorised admin calls, added keys, same-block double withdraws, failed-transfer refunds, callback out-of-gas, stale yield timeouts.
Each defence comes back HELD, BROKEN or INCONCLUSIVE, with the receipt trail and who gained or lost NEAR, and you can replay the attack as an animation. If BitLens couldn't drive the contract, it says so instead of guessing.
Type an attack in plain English. An LLM (NEAR AI Cloud, with OpenRouter as fallback) translates it into a scenario JSON for this contract. It never writes code. The JSON is validated (real methods only, fixed sim accounts, checks that must hold) and you can review or edit it before it runs on the same engine as the built-in attacks.
Try it in the app"the attacker calls admin_drain and keeps the money"
{ "steps": [ { "op": "call", "as": "attacker",
"method": "admin_drain", "attack": true } ],
"checks": [
{ "check": "net_at_most", "account": "attacker", "near": "0" },
{ "check": "unchanged", "what": "state" } ] }
For AI agents
Before signing, the agent hands BitLens the transaction it is about to send. BitLens attacks the contract in a local simulator and answers allow, confirm or block, with the attack that proves it. BitLens never signs: the agent's wallet signs only on allow. MCP server over stdio (official SDK); every tool is read-only and validates its input.
check_transactionCall it right before signing: allow / confirm / block, with the proof and a replay link.
scan_contractCapability risk card from the bytecode. Instant.
list_attacksThe attack scenarios that apply, with their scenario JSON.
run_attacksRuns them in the local sim: status, explanation, receipts, NEAR deltas.
assess_contractScan + all attacks → safe / caution / dangerous with reasons.
run_custom_attackYour agent's own idea, in plain English or as scenario JSON.
claude mcp add bitlens -- "$PWD/node_modules/.bin/tsx" "$PWD/mcp/server.ts"
{
"mcpServers": {
"bitlens": {
"command": "/ABSOLUTE/PATH/TO/bitlens/node_modules/.bin/tsx",
"args": ["/ABSOLUTE/PATH/TO/bitlens/mcp/server.ts"]
}
}
}
Run it from a clone of the repo after npm install and npm run build:runner. Plain-English attacks need NEAR_AI_API_KEY or OPEN_ROUTER_KEY.
admin_drain moved +67.8015 NEAR to the attackeradmin_drain and take the whole vault (+67.8 NEAR in simulation), and two same-block withdraw calls both pay out. Your 20 NEAR would be at risk from both bugs.Condensed from a real agent run (headless Claude Code, only BitLens's tools allowed).
Try a live mainnet contract (wrap.near, token.sweat, aurora) or one of the four demo contracts.