Sardis 托管 - 智能合约支付保护
通过智能合约托管实现安全的代理间支付。资金在确认交付前被锁定,在自主交易中同时保护买卖双方。
功能
- - 创建托管:建立无需信任的支付协议
- 注入资金:将资金存入智能合约托管
- 确认交付:卖家确认工作/商品已交付
- 释放付款:买家验证后释放资金
- 托管状态:实时托管状态追踪
- 争议解决:内置仲裁机制处理交付失败
安全模型
托管保护:资金锁定在智能合约中,直至双方确认。无中心化托管。
快速设置
bash
export SARDISAPIKEY=skyourkey_here
API 端点模式
基础URL:https://api.sardis.sh/v2
创建托管
bash
建立新的托管协议
curl -X POST https://api.sardis.sh/v2/escrow \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
buyer
walletid: wallet_buyer123,
seller
walletid: wallet_seller456,
amount: 500.00,
token: USDC,
chain: base,
description: API开发服务 - 40小时,
delivery_deadline: 2026-03-01T00:00:00Z,
auto
releaseafter_hours: 72,
milestones: [
{
description: 阶段1:设计,
amount: 150.00,
deadline: 2026-02-25T00:00:00Z
},
{
description: 阶段2:实施,
amount: 250.00,
deadline: 2026-02-28T00:00:00Z
},
{
description: 阶段3:测试与部署,
amount: 100.00,
deadline: 2026-03-01T00:00:00Z
}
]
}
示例响应:
{
escrowid: escrowxyz789,
contract_address: 0x1234567890abcdef...,
status: created,
buyer: wallet_buyer123,
seller: wallet_seller456,
amount: 500.00,
token: USDC,
chain: base,
funded: false,
created_at: 2026-02-21T10:00:00Z
}
注入资金
bash
买家将资金存入托管合约
curl -X POST https://api.sardis.sh/v2/escrow/{escrow_id}/fund \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
escrow
id: escrowxyz789,
wallet
id: walletbuyer123
}
示例:
curl -X POST https://api.sardis.sh/v2/escrow/escrow_xyz789/fund \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {escrow
id: escrowxyz789, wallet
id: walletbuyer123}
确认交付
bash
卖家确认商品/服务已交付
curl -X POST https://api.sardis.sh/v2/escrow/{escrow_id}/confirm-delivery \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
escrow
id: escrowxyz789,
wallet
id: walletseller456,
delivery_proof: {
type: github_pr,
url: https://github.com/company/repo/pull/123,
commit_hash: abc123def456,
notes: 所有3个里程碑已完成并通过测试
}
}
释放托管
bash
买家验证后向卖家释放资金
curl -X POST https://api.sardis.sh/v2/escrow/{escrow_id}/release \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
escrow
id: escrowxyz789,
wallet
id: walletbuyer123,
amount: 500.00,
milestone_id: null,
rating: 5,
feedback: 出色的工作,提前交付
}
里程碑部分释放:
curl -X POST https://api.sardis.sh/v2/escrow/escrow_xyz789/release \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
escrow
id: escrowxyz789,
wallet
id: walletbuyer123,
amount: 150.00,
milestone
id: milestone1
}
获取托管状态
bash
查询当前托管状态和交易历史
curl -X GET https://api.sardis.sh/v2/escrow/{escrow_id} \
-H Authorization: Bearer $SARDIS
APIKEY
示例:
curl -X GET https://api.sardis.sh/v2/escrow/escrow_xyz789 \
-H Authorization: Bearer $SARDIS
APIKEY
示例命令
完整托管工作流
bash
1. 创建托管协议
ESCROW=$(curl -s -X POST https://api.sardis.sh/v2/escrow \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
buyer
walletid: wallet_buyer123,
seller
walletid: wallet_seller456,
amount: 500.00,
token: USDC,
chain: base,
description: 开发工作
})
ESCROWID=$(echo $ESCROW | jq -r .escrowid)
echo 已创建托管:$ESCROW_ID
2. 买家注入资金
echo 正在注入资金...
curl -X POST https://api.sardis.sh/v2/escrow/$ESCROW_ID/fund \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {\escrow
id\: \$ESCROWID\, \wallet
id\: \walletbuyer123\}
3. 等待卖家交付(自动化)
echo 正在等待交付确认...
4. 卖家确认交付
curl -X POST https://api.sardis.sh/v2/escrow/$ESCROW_ID/confirm-delivery \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {\escrow
id\: \$ESCROWID\, \wallet
id\: \walletseller456\}
5. 买家验证并释放
echo 正在向卖家释放付款...
curl -X POST https://api.sardis.sh/v2/escrow/$ESCROW_ID/release \
-H Authorization: Bearer $SARDIS
APIKEY \
-H Content-Type: application/json \
-d {
\escrow
id\: \$ESCROWID\,
\wallet
id\: \walletbuyer123\,
\amount\: \500.00\,
\rating\: 5
}
echo 托管已完成!
监控托管状态
bash
追踪托管进度
ESCROW
ID=escrowxyz789
while true; do
STATUS=$(curl -s -X GET https://api.sardis.sh/v2/escrow/$ESCROW_ID \
-H Authorization: Bearer $SARDISAPIKEY)
STATE=$(echo $STATUS | jq -r .status)
FUNDED=$(echo $STATUS | jq -r .funded)
DELIVERED=$(echo $STATUS | jq -r .delivery_confirmed)
echo === 托管状态 ===
echo 状态:$STATE
echo 已注入资金:$F