360 Secure SkillHub
360 安全技能中心

WEB3 Integration

按技术栈、链、合约地址与 ABI 来源,生成钱包连接、provider/signer 配置、合约调用封装和链切换校验代码,要求显式重试策略、写操作审计与测试;强调密钥不落库、不默认主网。输出模块路径、环境变量契约和验证命令。

分类:开发
mzfshark
mzfshark
热度 25.15
最近更新 2026-05-11 17:45:41

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add mzfshark/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.