360 Secure SkillHub
360 安全技能中心

WEB3 Integration

核心功能:基于ethers/viem/web3js等指定库,按安全可测试模式实现钱包连接、链配置、合约调用、链控、日志审计及测试覆盖。典型场景:DApp需读写合约状态、后端需索引链上事件、需钱包连接UX与链门控。输入为开发栈、链信息、合约地址等参数,输出为封装模块、环境配置要求及验证命令,全程遵循安全规则。

mzfshark
mzfshark
热度 35.75
最近更新 2026-05-11 17:45:41
分类:开发依赖:纯提示词应用场景:代码生成 / API 集成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add axodus-web3-integration
Metadata
name
web3-integration
description
Integrate apps with blockchain providers, wallets, and contract calls safely.
metadata
{"author":"RedHat Dev","version":"1.0.0","owner":"RedHat Dev Agent","category":"blockchain"}

SKILL: web3-integration

Purpose

Integrate a frontend/backend with blockchain interaction (wallet connect, provider configuration, contract calls) using safe, testable patterns.

When to Use

  • A dApp needs to read/write contract state.
  • A backend service must index or react to on-chain events.
  • Wallet connection UX and chain gating is required.

Inputs

  • stack (required, enum: ethers|viem|web3js): preferred client library.
  • chain (required, string): chain name + chainId.
  • rpc (optional, string): RPC URL reference (env/config), not hardcoded.
  • contract_address (required, string).
  • abi_source (required, string): ABI path/artifact reference.
  • wallet_flow (optional, enum: injected|walletconnect|server_signer).

Steps

  1. Validate chain/contract coordinates (chainId, address format, ABI match).
  2. Set provider/signer flow:
    • frontend: user wallet signer
    • backend: server signer only when explicitly required and keys are secured externally
  3. Implement contract client wrapper:
    • typed interfaces when possible
    • explicit timeouts/retries for RPC
  4. Add chain gating:
    • refuse wrong chain
    • prompt network switch (frontend)
  5. Add logging/audit hooks for write operations.
  6. Add tests:
    • unit tests for wrapper
    • local chain simulation when available

Validation

  • No secrets stored in repo (keys only via secrets manager/env).
  • Wrong-chain behavior is safe (no accidental writes).
  • Errors are handled deterministically (retry policy is explicit).

Output

  • Wrapper module path(s)
  • Environment variable contract (what must be configured)
  • Validation commands (tests/build)

Safety Rules

  • Never request or paste private keys into chat/output.
  • Never default to mainnet.
  • Avoid “auto-sign” server flows unless explicitly required and approved.

Example

Input:

  • stack: viem
  • chain: base:8453
  • contract_address: 0x...
  • abi_source: artifacts/MyContract.json

Output:

  • src/web3/client.ts with chainId checks and a typed contract instance.