@blockhash/mancer-sdk

中文文档
0.1.0发布于 2026/10/31MITTypeScriptES Module

Mancer's API for a bot with a wallet: sign in, swap, orders, sends, Books and account events, every build checked before it is signed

原始使用文档
文档目录7 节
  1. Install
  2. A swap
  3. The floor is yours
  4. What is checked
  5. Docs
  6. Source
  7. License

@blockhash/mancer-sdk

Mancer's API for a bot with a wallet, in TypeScript on viem. Mancer is the dex aggregator and order layer of Robinhood Chain. The SDK signs in with the bot's own account, swaps, places and cancels orders, sends, acts on Books and hears the account's events. It asks Mancer for every act as steps ready to sign, and checks each step against what you asked for before your account signs it. Your account signs on your machine, or in the wallet client you hand in. The SDK never logs, sends or stores a private key.

Install

npm install @blockhash/mancer-sdk viem

It needs Node 22 or newer, and runs in a browser as well.

A swap

import { privateKeyToAccount } from 'viem/accounts'
import { ETH, Mancer } from '@blockhash/mancer-sdk'

const USDG = '0x5fc5360d0400a0fd4f2af552add042d716f1d168'
const mancer = new Mancer({ account: privateKeyToAccount(process.env.BOT_PRIVATE_KEY as `0x${string}`) })

const swap = await mancer.swap({
  tokenIn: ETH,
  tokenOut: USDG,
  amountIn: 1_000_000_000_000_000n,
  // the floor: what the deepest Uniswap pool of WETH and USDG pays on your node, less 1%
  reference: mancer.poolReference(),
  maxSlippageBps: 100,
})
console.log(`received ${swap.executed?.amountOut} USDG units`)

swap() signs in where it needs to, builds the swap with your wallet as its recipient, checks it, and sends its approval and then the swap. buildSwap() does the same and sends nothing.

The floor is yours

The floor is the least a swap may deliver, and the chain holds it. Within the floor, a wrong or hostile quote can still route the swap through a pool that pays the floor and no more. So each swap names exactly one floor rule, or it is refused before anything is asked:

NameThe floor
minOutYour own number, in raw units of the output.
reference with maxSlippageBpsYour function's answer for the order, less maxSlippageBps.
trustQuote: trueMancer's quote, less slippageBps. A wrong quote is then a wrong floor.

poolReference() prices WETH against USDG from Uniswap's QuoterV2 on your own RPC. For any other pair, pass a function of your own.

What is checked

The SDK checks every step before a signature: the chain, the wallet, the approval, the router call's tokens, amount, recipient, floor, deadline and fee, and every leg against the contracts of Mancer's own routing. A check that fails throws a MancerCheckError naming the first field that is not what you asked for, and nothing is signed or sent after it.

Docs

The full guide is at docs.mancer.xyz/agents/sdk: orders, sends, Books, events, errors, keys and every route of the API.

Source

The source is at github.com/blockhash-xyz/mancer-sdk, with the MCP server and an example bot.

License

MIT, © Blockhash.

版本与发布记录

@blockhash/mancer-sdk 共发布 2 个版本,首次发布于 2026/10/31;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.0latest2026/10/313 天前
0.0.0-stage2026/10/313 天前

关于 @blockhash/mancer-sdk 的常见问题

@blockhash/mancer-sdk 是什么?

Mancer的带有钱包的机器人API:登录,交换,订单,发送,书籍和帐户事件,在签名之前检查每个构建

如何安装 @blockhash/mancer-sdk?

在项目目录运行 npm install @blockhash/mancer-sdk,或使用 pnpm add / yarn add / bun add。

@blockhash/mancer-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blockhash/mancer-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blockhash/mancer-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@blockhash/mancer-sdk 可以商用吗?

@blockhash/mancer-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@blockhash/mancer-sdk 还在维护吗?

最新版本 0.1.0 发布于 2026/10/31(3 天前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。