For developers
One call to stop paying from a sleeping wallet.
Wrap the fetch your agent already makes. When a server answers 402, the SDK checks your spending policy, settles from the buffer and retries with the payment attached. Published on npm and PyPI under the MIT license.
TypeScript
npm install @unslept/sdk viemPython
pip install "unslept[web3]"MCP
npx -y @unslept/mcpLive Try a real paid endpoint
The demo endpoint asks for 0.01 USDG on mainnet and answers with live protocol stats once the payment settles.
GET https://www.unslept.xyz/api/demo/x402How x402 works with Unsleptimport { Unslept } from "@unslept/sdk";
import { privateKeyToAccount } from "viem/accounts";
const unslept = new Unslept({
agentAccount: process.env.UNSLEPT_AGENT_ACCOUNT,
signer: privateKeyToAccount(process.env.UNSLEPT_SIGNER_KEY),
network: "robinhood-chain",
});
// A drop-in fetch. On 402 it checks the policy, settles, and retries.
const res = await unslept.fetch("https://api.example.com/data", undefined, {
maxAmount: 50_000n, // 0.05 USDG, never more for this call
});import os
from eth_account import Account
from unslept import Unslept
from unslept.web3_chain import EthAccountSigner
unslept = Unslept(
agent_account=os.environ["UNSLEPT_AGENT_ACCOUNT"],
signer=EthAccountSigner(Account.from_key(os.environ["UNSLEPT_SIGNER_KEY"])),
network="robinhood-chain",
)
res = unslept.fetch("https://api.example.com/data")
print(res.status, res.text()){
"mcpServers": {
"unslept": {
"command": "npx",
"args": ["-y", "@unslept/mcp"],
"env": {
"UNSLEPT_AGENT_ACCOUNT": "<your agent account address>",
"UNSLEPT_SIGNER_KEY": "<agent signer key, from your secret store>",
"UNSLEPT_NETWORK": "robinhood-chain"
}
}
}
}Guides
Everything you need, in the docs.
QuickstartFrom an empty wallet to a first paid request, in five steps.ReadTypeScript agentConfiguration, error handling and low-balance alerts.ReadLangChain and CrewAIA ready-made tool that pays within the agent's policy.ReadMCP serverLet any MCP client pay x402 requests from its own account.ReadAccept x402 paymentsVerify unslept-direct payments in your own API.ReadSDK referenceEvery method, option and error code.Read
Put idle agent money to work.
Create an agent account in a few minutes, or supply the liquidity that settles payments.