Alkahest User Skill
What is Alkahest?
Alkahest is an EAS-based (Ethereum Attestation Service) escrow protocol for trustless exchanges on EVM chains. It enables:
- - Token escrow with programmable release conditions (ERC20, ERC721, ERC1155, native tokens, bundles)
- Arbiter-based validation — release conditions are defined by arbiter contracts that check fulfillment
- Composable demands — combine multiple conditions with AND/OR logic
- Oracle arbitration — off-chain validation with on-chain decision submission
- Commit-reveal — frontrunning protection for self-contained fulfillment data
Supported chains: Base Sepolia, Sepolia, Filecoin Calibration, Ethereum mainnet.
Roles
| Role | Description |
|---|
| Buyer | Creates escrow with assets + demand (what they want in return) |
| Seller |
Fulfills the demand to collect escrowed assets |
|
Oracle | Validates fulfillment and submits on-chain decisions (for TrustedOracleArbiter) |
CLI Setup
Install globally via npm install -g alkahest-cli, then run commands with:
CODEBLOCK0
Authentication
Provide a wallet via one of (in priority order):
| Method | Flag / Env Var |
|---|
| Private key flag | INLINECODE1 |
| Mnemonic flag |
--mnemonic "word1 word2 ..." |
| Ledger USB |
--ledger [--ledger-path <path>] |
| Private key env |
ALKAHEST_PRIVATE_KEY=0x... |
| Mnemonic env |
ALKAHEST_MNEMONIC="word1 word2 ..." |
| Compat env |
PRIVATE_KEY=0x... |
Global Flags
CODEBLOCK1
Output Format
JSON by default (ideal for programmatic/agent use). All BigInts are serialized as strings.
CODEBLOCK2
Use --human for labeled, indented output.
Buyer Workflow: Create Escrow
1. Encode the demand
First, encode the demand data that specifies your release condition:
CODEBLOCK3
2. Create the escrow
Use the --arbiter address and the encoded --demand hex from step 1:
CODEBLOCK4
Returns { "success": true, "data": { "hash": "0x...", "uid": "0x...", ... } }. Save the uid — this is the escrow UID.
3. Wait for fulfillment
CODEBLOCK5
4. Reclaim expired escrow (if unfulfilled)
CODEBLOCK6
5. Get escrow details
CODEBLOCK7
Seller Workflow: Fulfill Escrow
Using StringObligation (off-chain validated work)
CODEBLOCK8
Using barter (token-for-token swap)
CODEBLOCK9
Supported barter pairs: erc20/erc20, erc20/erc721, erc20/erc1155. Use --permit for gasless approval.
Oracle Workflow: Arbitrate
CODEBLOCK10
For auto-arbitration (listening for requests and auto-deciding), use the TypeScript SDK directly — see references/typescript-sdk.md.
Commit-Reveal Workflow
Use commit-reveal when fulfillment data is self-contained (e.g., a string answer) to prevent frontrunning.
CODEBLOCK11
Encoding Demands
The arbiter encode-demand command encodes demand data for any arbiter type:
CODEBLOCK12
Available --type values: trusted-oracle, intrinsics2, all, any, recipient, attester, schema, uid, ref-uid, revocable, time-after, time-before, time-equal, expiration-time-after, expiration-time-before, expiration-time-equal.
Decoding demands
CODEBLOCK13
Confirmation Arbiters
For manual buyer-side approval of fulfillments:
CODEBLOCK14
Types: exclusive-revocable, exclusive-unrevocable, nonexclusive-revocable, nonexclusive-unrevocable.
Payments
CODEBLOCK15
Attestations
CODEBLOCK16
Decode types: erc20-escrow, erc20-payment, erc721-escrow, erc721-payment, erc1155-escrow, erc1155-payment, string, commit-reveal.
Configuration
CODEBLOCK17
Escrow Types
| Type | Flag | Key options |
|---|
| ERC20 | INLINECODE47 | INLINECODE48 , INLINECODE49 |
| ERC721 |
--erc721 |
--token,
--token-id |
| ERC1155 |
--erc1155 |
--token,
--token-id,
--amount |
| Native Token |
--native |
--amount |
| Token Bundle |
--bundle | (SDK only for create) |
All escrow types share the same workflow: create -> wait -> collect (or reclaim if expired).
Additional Resources
- - See
references/typescript-sdk.md for TypeScript SDK usage (complex workflows, auto-arbitration, bundle escrows) - See
references/contracts.md for all contract addresses and obligation data schemas - See
references/arbiters.md for all arbiter types and demand encoding patterns
Alkahest 用户技能
什么是 Alkahest?
Alkahest 是一个基于 EAS(以太坊认证服务)的托管协议,用于在 EVM 链上实现无需信任的交易。它支持:
- - 代币托管,具有可编程释放条件(ERC20、ERC721、ERC1155、原生代币、捆绑包)
- 基于仲裁者的验证——释放条件由检查履行情况的仲裁者合约定义
- 可组合需求——使用 AND/OR 逻辑组合多个条件
- 预言机仲裁——链下验证与链上决策提交
- 承诺-揭示——为自包含履行数据提供抢跑保护
支持的链:Base Sepolia、Sepolia、Filecoin Calibration、以太坊主网。
角色
| 角色 | 描述 |
|---|
| 买家 | 使用资产 + 需求(他们想要什么作为回报)创建托管 |
| 卖家 |
履行需求以领取托管资产 |
|
预言机 | 验证履行并提交链上决策(用于 TrustedOracleArbiter) |
CLI 设置
通过 npm install -g alkahest-cli 全局安装,然后使用以下命令运行:
bash
alkahest [全局标志] <命令> <子命令> [选项]
身份验证
通过以下方式之一提供钱包(按优先级顺序):
| 方法 | 标志 / 环境变量 |
|---|
| 私钥标志 | --private-key 0x... |
| 助记词标志 |
--mnemonic word1 word2 ... |
| Ledger USB | --ledger [--ledger-path <路径>] |
| 私钥环境变量 | ALKAHEST
PRIVATEKEY=0x... |
| 助记词环境变量 | ALKAHEST_MNEMONIC=word1 word2 ... |
| 兼容环境变量 | PRIVATE_KEY=0x... |
全局标志
--chain <名称> base-sepolia(默认)| sepolia | filecoin-calibration | ethereum
--rpc-url <网址> 自定义 RPC URL(覆盖链默认值)
--human 人类可读输出(默认:JSON)
输出格式
默认为 JSON(适合编程/代理使用)。所有 BigInt 序列化为字符串。
json
{ success: true, data: { hash: 0x..., uid: 0x... } }
{ success: false, error: { code: ESCROWCREATEFAILED, message: ... } }
使用 --human 获取带标签的缩进输出。
买家工作流:创建托管
1. 编码需求
首先,编码指定释放条件的需求数据:
bash
可信预言机需求——预言机必须批准履行
alkahest arbiter encode-demand \
--type trusted-oracle \
--oracle 0xORACLE_ADDRESS \
--data 0x
返回:{ success: true, data: { encoded: 0x... } }
2. 创建托管
使用步骤 1 中的 --arbiter 地址和编码的 --demand 十六进制数据:
bash
ERC20 托管,自动批准
alkahest --private-key 0xKEY escrow create \
--erc20 \
--token 0xTOKEN_ADDRESS \
--amount 1000000000000000000 \
--arbiter 0xARBITER_ADDRESS \
--demand 0xENCODED_DEMAND \
--expiration 1735689600 \
--approve
ERC721 托管
alkahest --private-key 0xKEY escrow create \
--erc721 \
--token 0xNFT_ADDRESS \
--token-id 42 \
--amount 0 \
--arbiter 0xARBITER_ADDRESS \
--demand 0xENCODED_DEMAND \
--expiration 1735689600 \
--approve
原生代币(ETH)托管——无需批准
alkahest --private-key 0xKEY escrow create \
--native \
--token 0x0000000000000000000000000000000000000000 \
--amount 500000000000000000 \
--arbiter 0xARBITER_ADDRESS \
--demand 0xENCODED_DEMAND \
--expiration 1735689600
返回 { success: true, data: { hash: 0x..., uid: 0x..., ... } }。保存 uid——这是托管 UID。
3. 等待履行
bash
alkahest --private-key 0xKEY escrow wait \
--erc20 --uid 0xESCROW_UID
阻塞直到履行。返回:{ payment, fulfillment, fulfiller }
4. 收回过期托管(如果未履行)
bash
alkahest --private-key 0xKEY escrow reclaim \
--erc20 --uid 0xESCROW_UID
5. 获取托管详情
bash
alkahest --private-key 0xKEY escrow get \
--erc20 --uid 0xESCROW_UID
卖家工作流:履行托管
使用 StringObligation(链下验证的工作)
bash
1. 创建引用托管的履行
alkahest --private-key 0xKEY string create \
--item 这是我完成的交付物 \
--ref-uid 0xESCROW_UID
返回:{ uid: 0xFULFILLMENT_UID, ... }
2. 如果托管使用 TrustedOracleArbiter,预言机进行仲裁
alkahest --private-key 0xORACLE_KEY arbiter arbitrate \
--obligation 0xFULFILLMENT_UID \
--demand 0xDEMAND_HEX \
--decision true
3. 领取托管
alkahest --private-key 0xSELLER_KEY escrow collect \
--erc20 \
--escrow-uid 0xESCROW_UID \
--fulfillment-uid 0xFULFILLMENT_UID
使用易货(代币对代币交换)
bash
创建易货报价:出价 ERC20 换取 ERC20
alkahest --private-key 0xKEY barter create \
--bid-type erc20 --ask-type erc20 \
--bid-token 0xBID_TOKEN --bid-amount 1000000000000000000 \
--ask-token 0xASK_TOKEN --ask-amount 2000000000000000000 \
--expiration 1735689600
对手方履行易货
alkahest --private-key 0xCOUNTERPARTY_KEY barter fulfill \
--uid 0xBARTER_UID \
--bid-type erc20 --ask-type erc20
支持的易货对:erc20/erc20、erc20/erc721、erc20/erc1155。使用 --permit 进行无 Gas 批准。
预言机工作流:仲裁
bash
批准履行
alkahest --private-key 0xORACLE_KEY arbiter arbitrate \
--obligation 0xFULFILLMENT_UID \
--demand 0xDEMAND_HEX \
--decision true
拒绝履行
alkahest --private-key 0xORACLE_KEY arbiter arbitrate \
--obligation 0xFULFILLMENT_UID \
--demand 0xDEMAND_HEX \
--decision false
对于自动仲裁(监听请求并自动决策),直接使用 TypeScript SDK——请参阅 references/typescript-sdk.md。
承诺-揭示工作流
当履行数据是自包含的(例如,字符串答案)时,使用承诺-揭示以防止抢跑。
bash
1. 计算承诺哈希
alkahest --private-key 0xKEY commit-reveal compute-commitment \
--ref-uid 0xESCROW_UID \
--claimer 0xSELLER_ADDRESS \
--payload 0xPAYLOAD_HEX \
--salt 0xSALT_HEX \
--schema 0xSCHEMA_UID
返回:{ commitment: 0x... }
2. 承诺(以 ETH 形式发送保证金)
alkahest --private-key 0xKEY commit-reveal commit \
--commitment 0xCOMMITMENT_HASH
3. 等待至少 1 个区块,然后揭示
alkahest --private-key 0xKEY commit