Safe Multisig Skill
TypeScript-strict scripts for interacting with Safe multisig accounts via:
- - Safe Transaction Service (read state, propose txs, submit confirmations)
- Safe{Core} SDK (create Safes, create txs, compute hashes, sign, execute)
All scripts use ethers v6, validate inputs (addresses, tx hashes), and output JSON.
Quick start
CODEBLOCK0
Core scripts
| Script | Description |
|---|
| INLINECODE1 | Predict address + optionally deploy a new Safe |
| INLINECODE2 |
Fetch Safe info (owners/threshold/nonce) |
|
list-pending.ts | List pending (queued) multisig transactions |
|
safe_txs_list.ts | List all multisig transactions (queued + executed) |
|
propose-tx.ts | Create + propose a multisig tx |
|
approve-tx.ts | Add an off-chain confirmation for a tx hash |
|
execute-tx.ts | Execute a fully-confirmed tx onchain |
All scripts: INLINECODE8
Common tasks
1) Create a new Safe
CODEBLOCK1
Add --deploy + SAFE_SIGNER_PRIVATE_KEY to send the deployment tx.
2) Get Safe info
CODEBLOCK2
3) List pending transactions
CODEBLOCK3
4) Propose a new transaction
Create a tx request JSON (see references/tx_request.schema.json and references/examples.md).
CODEBLOCK4
5) Confirm (approve) a proposed transaction
CODEBLOCK5
6) Execute a confirmed transaction (onchain)
CODEBLOCK6
Configuration
All scripts accept:
- -
--chain <slug> (recommended): e.g. base, base-sepolia, mainnet, arbitrum, INLINECODE18 - INLINECODE19 : Override the transaction service URL
- INLINECODE20 : RPC endpoint (or
RPC_URL env var) - INLINECODE22 : Safe Transaction Service API key (or
SAFE_TX_SERVICE_API_KEY env var)
Security rules
- - Never paste private keys into chat. Use env vars or files.
- Prefer low-privilege signers and spending limits.
- Always verify Safe address, chainId / RPC, and nonce before signing.
References
- -
references/examples.md — example requests + workflows - INLINECODE25 — tx request JSON shape
- INLINECODE26 — chain slugs + notes
Safe 多签技能
用于通过以下方式与 Safe 多签账户交互的 TypeScript 严格脚本:
- - Safe 交易服务(读取状态、提议交易、提交确认)
- Safe{Core} SDK(创建 Safe、创建交易、计算哈希、签名、执行)
所有脚本均使用 ethers v6,验证输入(地址、交易哈希),并输出 JSON。
快速开始
bash
cd <此技能目录>
./scripts/bootstrap.sh
检查网络 + 服务
./scripts/safe_about.sh --chain base
核心脚本
| 脚本 | 描述 |
|---|
| create-safe.ts | 预测地址 + 可选部署新的 Safe |
| safe-info.ts |
获取 Safe 信息(所有者/阈值/随机数) |
| list-pending.ts | 列出待处理(排队中)的多签交易 |
| safe
txslist.ts | 列出所有多签交易(排队中 + 已执行) |
| propose-tx.ts | 创建 + 提议多签交易 |
| approve-tx.ts | 为交易哈希添加链下确认 |
| execute-tx.ts | 在链上执行完全确认的交易 |
所有脚本:npx tsx scripts/<名称>.ts --help
常见任务
1) 创建新的 Safe
bash
npx tsx scripts/create-safe.ts \
--chain base \
--owners 0xOwner1,0xOwner2,0xOwner3 \
--threshold 2
添加 --deploy 和 SAFESIGNERPRIVATE_KEY 以发送部署交易。
2) 获取 Safe 信息
bash
npx tsx scripts/safe-info.ts --chain base --safe 0xYourSafe
3) 列出待处理交易
bash
npx tsx scripts/list-pending.ts --chain base --safe 0xYourSafe
4) 提议新交易
创建交易请求 JSON(参见 references/tx_request.schema.json 和 references/examples.md)。
bash
export SAFESIGNERPRIVATE_KEY=...
npx tsx scripts/propose-tx.ts \
--chain base \
--rpc-url $BASERPCURL \
--tx-file ./references/example.tx.json
5) 确认(批准)提议的交易
bash
export SAFESIGNERPRIVATE_KEY=...
npx tsx scripts/approve-tx.ts \
--chain base \
--safe 0xYourSafe \
--safe-tx-hash 0x...
6) 执行已确认的交易(链上)
bash
export SAFESIGNERPRIVATE_KEY=...
npx tsx scripts/execute-tx.ts \
--chain base \
--rpc-url $BASERPCURL \
--safe 0xYourSafe \
--safe-tx-hash 0x...
配置
所有脚本接受:
- - --chain <标识符>(推荐):例如 base、base-sepolia、mainnet、arbitrum、optimism
- --tx-service-url :覆盖交易服务 URL
- --rpc-url :RPC 端点(或 RPCURL 环境变量)
- --api-key :Safe 交易服务 API 密钥(或 SAFETXSERVICEAPI_KEY 环境变量)
安全规则
- - 切勿在聊天中粘贴私钥。 使用环境变量或文件。
- 优先使用低权限签名者和支出限额。
- 在签名前始终验证 Safe 地址、chainId / RPC 和随机数。
参考资料
- - references/examples.md — 示例请求 + 工作流程
- references/txrequest.schema.json — 交易请求 JSON 格式
- references/txservice_slugs.md — 链标识符 + 说明