返回顶部
a

alkahest-developerAlkahest开发工具

Help developers write code that interacts with Alkahest escrow contracts using the TypeScript, Rust, or Python SDK

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
188
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

alkahest-developer

Alkahest 开发者技能

使用时机

当开发者需要编写与 Alkahest 托管合约交互的代码时使用此技能。涵盖范围包括:

  • - 将 Alkahest 集成到应用程序中
  • 编写创建托管、履行义务或进行仲裁的机器人/代理
  • 构建自定义仲裁器或义务合约
  • 理解 SDK 模式和 API

SDK 概览

SDK语言包名基础库
TypeScriptTypeScript/JavaScript@alkahest/ts-sdkviem
Rust
Rust | alkahest-rs | alloy | | Python | Python | alkahest-py | 基于 Rust SDK 的 PyO3 封装 |

客户端设置

TypeScript

typescript
import { createWalletClient, http } from viem;
import { privateKeyToAccount } from viem/accounts;
import { baseSepolia } from viem/chains;
import { makeClient } from @alkahest/ts-sdk;

const walletClient = createWalletClient({
account: privateKeyToAccount(0x私钥),
chain: baseSepolia,
transport: http(https://rpc-url),
});

// 包含所有扩展的完整客户端
const client = makeClient(walletClient);

// 自定义地址(可选)
const client = makeClient(walletClient, customAddresses);

// 用于自定义扩展模式的最小化客户端
const minimal = makeMinimalClient(walletClient);
const extended = minimal.extend((base) => ({
custom: makeErc20Client(base.viemClient, pickErc20Addresses(base.contractAddresses)),
}));

Rust

rust
use alkahest_rs::AlkahestClient;

// 包含所有扩展的完整客户端(默认 Base Sepolia)
let client = AlkahestClient::withbaseextensions(
0x私钥,
https://rpc-url,
None, // 使用 Base Sepolia 地址
).await?;

// 自定义地址
use alkahestrs::{DefaultExtensionConfig, ETHEREUMSEPOLIA_ADDRESSES};
let client = AlkahestClient::withbaseextensions(
0x私钥,
https://rpc-url,
Some(ETHEREUMSEPOLIAADDRESSES),
).await?;

// 裸客户端 + 自定义扩展
let bare = AlkahestClient::new(0x私钥, https://rpc-url).await?;
let extended = bare.extend::(Some(erc20_config)).await?;

Python

python
from alkahest_py import PyAlkahestClient

包含所有扩展的完整客户端(默认 Base Sepolia)

client = PyAlkahestClient(0x私钥, https://rpc-url)

自定义地址

from alkahest_py import DefaultExtensionConfig, PyErc20Addresses, ... config = DefaultExtensionConfig(erc20_addresses=..., ...) client = PyAlkahestClient(0x私钥, https://rpc-url, config)

核心模式

创建托管

TypeScript:
typescript
// 1. 授权代币
await client.erc20.util.approve({ address: 代币地址, value: 金额 }, escrow);

// 2. 创建托管
const { hash, attested } = await client.erc20.escrow.nonTierable.doObligation(
client.erc20.escrow.nonTierable.encodeObligationRaw({
token: 代币地址, amount: 金额, arbiter: 仲裁器地址, demand: 需求字节,
}),
);
const escrowUid = attested.uid;

Rust:
rust
// 1. 授权
client.erc20().approve(&Erc20Data { address: token, value: amount }, ApprovalPurpose::Escrow).await?;

// 2. 创建托管
let receipt = client.erc20().escrow().nontierable().makestatement(
token, amount, arbiter, demand_bytes, expiration,
).await?;
let attested = client.getattestedevent(receipt)?;

Python:
python

1. 授权


await client.erc20.util.approve(token_address, amount, escrow)

2. 创建托管

uid = await client.erc20.escrow.non_tierable.create( token=token_address, amount=amount, arbiter=arbiteraddress, demand=demandbytes, expiration=expiration, )

使用字符串义务履行

TypeScript:
typescript
const { attested } = await client.stringObligation.doObligation(
履行内容,
undefined, // schema
escrowUid, // refUID
);

Rust:
rust
let receipt = client.stringobligation().doobligation(
履行内容, None, Some(escrow_uid),
).await?;

Python:
python
uid = await client.stringobligation.doobligation(
履行内容,
refuid=escrowuid,
)

收取托管

TypeScript:
typescript
const { hash } = await client.erc20.escrow.nonTierable.collectObligation(
escrowUid,
fulfillmentUid,
);

Rust:
rust
let receipt = client.erc20().escrow().nontierable().collectpayment(
escrowuid, fulfillmentuid,
).await?;

Python:
python
txhash = await client.erc20.escrow.nontierable.collect(escrowuid, fulfillmentuid)

等待履行

TypeScript:
typescript
const result = await client.waitForFulfillment(
client.contractAddresses.erc20EscrowObligation,
escrowUid,
);

Rust:
rust
let log = client.waitforfulfillment(
client.erc20_address(Erc20Contract::EscrowObligation),
escrow_uid,
None, // from_block
).await?;

Python:
python
result = await client.waitforfulfillment(
escrowcontractaddress,
escrow_uid,
)

编码需求

TypeScript:
typescript
// 可信预言机
const demand = client.arbiters.general.trustedOracle.encodeDemand({
oracle: 预言机地址, data: 0x,
});

// 逻辑组合
const demand = client.arbiters.logical.all.encodeDemand({
arbiters: [仲裁器A, 仲裁器B],
demands: [需求A, 需求B],
});

// 证明属性
const demand = client.arbiters.attestationProperties.attester.encodeDemand({
attester: 所需证明者,
});

Rust:
rust
// 可信预言机(ABI 编码)
use alloy::sol_types::SolValue;
let demand = TrustedOracleArbiter::DemandData { oracle, data: Bytes::new() }.abi_encode();

// 解码仲裁器需求(自动检测)
let decoded = client.arbiters().decodearbiterdemand(arbiteraddr, &demandbytes)?;

Python:
python

可信预言机


demand = client.arbiters.trustedoracle.encodedemand(oracle=预言机地址, data=b)

逻辑组合

demand = client.arbiters.logical.all.encode( arbiters=[仲裁器A, 仲裁器B], demands=[需求A, 需求B], )

提交-揭示模式

TypeScript:
typescript
// 1. 计算承诺
const commitment = await client.commitReveal.computeCommitment(
escrowUid, claimerAddress, { payload, salt, schema },
);
// 2. 提交(以 ETH 形式发送保证金)
await client.commitReveal.commit(commitment);
// 3. 等待 1+ 个区块,然后揭示
const { attested } = await client.commitReveal.doObligation(
{ payload, salt, schema }, escrowUid,
);
// 4. 收回保证金
await client.commitReveal.reclaimBond(attested.uid);

Rust:
rust
let commitment = client.commitreveal().computecommitment(
escrowuid, claimer, &obligationdata,
).await?;
client.commit_reveal().commit(commitment).await?;
// 等待 1+ 个区块
let receipt = client.commitreveal().doobligation(&obligationdata, Some(escrowuid)).await?;
client.commitreveal().reclaimbond

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 alkahest-developer-1776110769 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 alkahest-developer-1776110769 技能

通过命令行安装

skillhub install alkahest-developer-1776110769

下载

⬇ 下载 alkahest-developer v1.0.0(免费)

文件大小: 16.77 KB | 发布时间: 2026-4-14 16:04

v1.0.0 最新 2026-4-14 16:04
Alkahest Developer Skill 1.0.0 – Initial Release

- Introduces documentation and patterns for integrating with Alkahest escrow smart contracts using TypeScript, Rust, and Python SDKs.
- Provides client setup guides for each supported language, with code samples for full, custom, and minimal clients.
- Demonstrates core escrow workflows: approving tokens, creating escrows, fulfilling obligations, collecting payments, and waiting for fulfillment.
- Details advanced patterns including encoding arbiter demands, commit-reveal flows, and barter utilities for atomic token swaps.
- Includes a summary of key type differences between SDKs for addresses and big integers.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部