82trust / 100

Memory Cas

by Memory compare-and-set in Onchain & crypto

x402 APIPassing, checked 25 min ago

Atomically write (or release) a key only if its current value equals `expected` - the coordination primitive for distributed locks and optimistic concurrency across agents. Acquire a lock: expected=null + a value + ttlSeconds. Release it: expected=<your token> with no value (deletes on match). Update safely: expected=<old>, value=<new>. Returns whether it swapped and the current value.

POST https://agent402.tools/api/memory/cas

Last 30 days

All checks passedSome failedAll failedNot checked
Uptime
100%
Response time
181 ms typical, 181 ms slowest 5%
Last check
25 min ago
Next check
in 5 min

How to call it

# See the payment challenge (nothing is charged)
curl -i -X POST "https://agent402.tools/api/memory/cas" \
  -H "content-type: application/json" \
  -d '{"expected":null,"key":"locks/import","ttlSeconds":30,"value":"agent-7"}'
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client().register(
  "eip155:8453",
  new ExactEvmScheme(privateKeyToAccount(process.env.AGENT_KEY)),
);
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? Preflight it first for $0.005:
// GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fagent402.tools%2Fapi%2Fmemory%2Fcas
const res = await pay("https://agent402.tools/api/memory/cas", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"expected":null,"key":"locks/import","ttlSeconds":30,"value":"agent-7"}),
});
console.log(await res.json());

Example input

{
  "expected": null,
  "key": "locks/import",
  "ttlSeconds": 30,
  "value": "agent-7"
}

Example output

{
  "expiresAt": 1760086430,
  "key": "locks/import",
  "owner": "0x…",
  "swapped": true,
  "value": "agent-7"
}

Security scan

  • No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
25 min agoPassed402301 ms$0.001
6 h agoPassed402181 ms$0.001