Safeheron Skill
Instructing AI to write production-ready Safeheron integration code using natural language — A complete guide from zero to deployment.
1. Product Overview
1.1 What Is Safeheron Skill
Safeheron Skill is an AI Skill plugin for Claude Code and Cursor IDEs. Once installed, developers can describe their requirements in natural language and have the AI generate production-ready Java SDK code — no more digging through Safeheron API documentation page by page.
Core capabilities include:
Code Generation — Simply describe your business scenario, and the AI will automatically generate SDK-compliant Java code, complete with correct imports, exception handling, and security validations.
Full API Coverage — Covers all APIs, including wallet management, transfers, MPC Sign, Web3 Sign, webhook callbacks, whitelists, Gas Station, AML/KYT compliance checks, and Co-Signer approvals.
Debugging & Troubleshooting — Input error codes or exception messages, and the AI will directly pinpoint the root cause and provide a solution.
Built-In Security & Compliance — Every code snippet generated strictly adheres to Safeheron's security best practices, including key management, idempotency, and AML checks.
1.2 Who Is This For
Role
Use Case
Backend Developer
Quickly generate SDK integration code, minimizing the time spent on documentation.
Technical Architect
Explore the boundaries of Safeheron's APIs to design comprehensive system architecture solutions.
Security Engineer
Review code security and gain deep insights into MPC self-custody security requirements.
Product Manager
Rapidly discover supported business scenarios and the full scope of Safeheron's capabilities.
1.3 Key Concepts
Before diving into the examples, here are the foundational concepts you need to know:
MPC Self-Custody: Safeheron utilizes a 3-of-3 MPC (Secure Multi-Party Computation) architecture. The complete private key never exists on any single device. Instead, three key shards are distributed between your team's local environment and the Safeheron cloud, which collaboratively sign transactions.
Wallet Account: A Safeheron wallet account is a omnichain wallet — each account can hold addresses across multiple blockchains (ETH, BTC, USDT, etc.). As a best practice, we recommend mapping one end-user to exactly one Safeheron Wallet Account (a 1:1 relationship).
SDK Calling Pattern: The Java SDK follows a strict three-step pattern:
Every API call must be wrapped with ServiceExecutor.execute(). Calling interface methods directly will fail silently.
Transaction Lifecycle:
1.4 Built-In Knowledge Base
The Skill ships with 20 comprehensive reference documents covering every aspect of the Safeheron API:
Category
Document
Description
Getting Started
GETTING_STARTED.md
Zero to first API call
SDK Setup
SDK_SETUP.md
Maven/Gradle config, Spring Boot integration
Authentication
AUTH.md
RSA + AES encryption and signing flow
Wallets
WALLET_API.md
Wallet creation, querying, coin management
Transactions
TRANSACTION_API.md
Transfers, queries, cancellation, speed-up
MPC Signing
MPC_SIGN_API.md
Raw hash signing
Web3
WEB3_API.md
EVM chain signing operations
Webhooks
WEBHOOK.md
Event callback handling
Whitelists
WHITELIST_API.md
Address whitelist management
Compliance
COMPLIANCE_API.md
AML/KYT reporting
Tools
TOOLS_API.md
AML address risk screening
Gas
GAS_API.md
Gas Station status queries
Co-Signer
COSIGNER.md
Automated approval callbacks
Security
SECURITY_BEST_PRACTICES.md
Mandatory security coding standards
Checklist
SECURITY_CHECKLIST.md
Pre-launch security checklist
Policy
POLICY_STRATEGY.md
Approval policy configuration
Business Patterns
BUSINESS_PATTERNS.md
Deposit / withdrawal / sweep architecture
Error Codes
ERROR_CODES.md
Common error troubleshooting
FAQ
FAQ.md
Real-world Q&A
Coins
COIN_API.md
Coin queries, address validation
2. Setup & Installation
2.1 Prerequisites
Java 8+
Maven 3.x or Gradle 7+
OpenSSL (pre-installed on macOS/Linux; use Git Bash or WSL on Windows)
Safeheron Web Console account (https://www.safeheron.com)
Claude Code or Cursor IDE
2.2 Install the Skill
Claude Code
Option 1: Plugin install (recommended)
Option 2: Manual install (project-level)
Option 3: Manual install (user-level, applies globally)
Cursor
Cursor natively supports the SKILL.md format and is also compatible with .claude/skills/, so a single install covers both IDEs.
Note:
~/.cursor/skills-cursor/is Cursor's built-in read-only directory — do not install there. Use~/.cursor/skills/instead.


2.3 Verify Installation
After installation, enter the following prompt in Claude Code or Cursor to test:
If the AI recognizes the Safeheron SKILL and begins guiding you through the setup, the installation was successful.

2.4 Safeheron Platform Configuration
Before writing any code, complete the following configuration in the Safeheron Console:
Step 1: Generate an RSA Key Pair
Safeheron uses RSA-4096 for request signing and payload encryption.
Generated files and their purposes:
File
Purpose
Used By
api_public.pem
Public key
Upload to Safeheron Console
api_pkcs8.pem
PKCS8-encoded private key
SDK config **rsaPrivateKey** field
Extract the Base64 values (strip PEM headers/footers):
Security: Never commit private key files to version control. Always add
*.pemto.gitignore.
Step 2: Configure in the Console
Log in to Safeheron Web Console → Settings → API
Copy the Safeheron Platform Public Key (this is the
safeheronRsaPublicKeyin your SDK config)Create an API Key:
Paste your RSA public key (base64 content from
api_public.pem)Select required permissions
Add your server IP to the whitelist (mandatory — unregistered IPs are rejected)
Save the generated API Key string


Step 3: Add SDK Dependency
Maven (pom.xml):
Gradle (build.gradle):
Step 4: Inject Credentials
Option A: Environment variables (recommended for production)
Option B: Spring Boot **application.yml**
Note:
requestTimeoutis a Long (milliseconds). Use20000Lin code, not20000.
3. Integration Examples
The following four examples cover the most common business scenarios: wallet creation, deposit detection with sweeping, withdrawal processing, and webhook handling. Each includes an AI Prompt example and generated code reference to demonstrate how the SKILL works in practice.
Example 1: Wallet Creation & Deposit Address Allocation
Business requirement: Create an independent wallet for each end-user, add ETH and USDT coins, and retrieve deposit addresses.
AI Prompt
Enter in Claude Code or Cursor:

Generated Code Reference
Key Points
hiddenOnUI(true)— Deposit wallets don't need to appear in the Console UI; keeps things cleanaccountTag("DEPOSIT")— Required for Auto-Sweep; the sweep engine only processes wallets taggedDEPOSITAdding an ERC-20 token (e.g. USDT) automatically adds ETH as well (needed for gas fees)
accountKeyis the wallet's permanent unique identifier — always persist it to your database after creation
Example 2: Deposit Detection & Asset Sweeping
Business requirement: Detect when users deposit funds, credit their accounts upon confirmation, then sweep assets from individual deposit wallets into the platform's hot wallet.
AI Prompt


Generated Code Reference
Deposit Detection (Webhook Handler)
Asset Sweeping (Internal Transfer)
Key Points
Prefer Auto-Sweep: If you have an API Co-Signer deployed, configure Auto-Sweep rules in the Console for zero-code automated sweeping
Webhook + REST API polling: Deposit detection must implement both — webhook as primary, REST API polling as fallback
No status rollback: If a transaction is already
COMPLETEDin your database, discard any late-arrivingCONFIRMINGeventDust attack protection: External actors may send tiny amounts to your deposit addresses to pollute your webhook stream — always set a minimum deposit threshold
Example 3: Withdrawal Processing
Business requirement: Process user withdrawal requests from the hot wallet to external addresses, including AML screening and address validation.
AI Prompt

Generated Code Reference
Key Points
DB-first pattern: Create the withdrawal order in your database (with
customerRefId) before calling the Safeheron API. On timeout, retry with the same ID — Safeheron returns the existing transaction rather than creating a new onePre-flight AML check: Screen the destination address via
ToolsApiServicebefore submitting the transactionString amounts:
txAmountmust be a String (e.g."0.01"); useBigDecimalfor application-side calculations. Never use float/double**failOnAml: true**: Even with pre-flight AML checks, keep this enabled as a second line of defenseFor recurring transfer destinations (exchange hot wallets, partner addresses), use whitelisted addresses (
WHITELISTING_ACCOUNT) instead ofONE_TIME_ADDRESS
Example 4: Webhook Handler
Business requirement: Implement a complete webhook handler with signature verification, event routing, idempotency, and security event alerting.
AI Prompt

Generated Code Reference
Webhook Configuration
Webhook Controller
Key Points
Signature verification is mandatory: The SDK's
WebhookConverter.convert()internally handles RSA signature verification and AES decryption; it throwsSafeheronExceptionon failureIP whitelist: Safeheron's webhook egress IPs are fixed:
18.162.105.64,18.167.22.59,18.167.21.182. Enforce this at the firewall/security group level, not just in application codeAlways return HTTP 200: Even if processing fails. Non-200 responses trigger Safeheron's retry mechanism (7 attempts: 30s → 1m → 5m → 1h → 12h → 24h)
No status rollback: Webhook events may arrive out of order. Terminal states (COMPLETED/FAILED/REJECTED/CANCELLED) must never be overwritten by intermediate states
Security event handling: Always subscribe to
ILLEGAL_IP_REQUEST,NO_MATCHING_TRANSACTION_POLICY,GAS_BALANCE_WARNING, andAML_KYT_ALERTevents and route them to your alerting system
4. Best Practices
4.1 Security Requirements (Non-Negotiable)
These security requirements are mandatory — all Safeheron integration code must comply:
Key Management
AWS Cloud
AWS KMS / Secrets Manager
GCP Cloud
GCP KMS
Self-Hosted
HashiCorp Vault
Local Development
Environment variables or files outside the project directory (never committed to Git)
Never hardcode API Keys or RSA private keys in source code.
Transfer Security
**customerRefId**first: Generate a UUID and save it to your database before calling any Safeheron create API. On timeout, retry with the same IDAddress validation: Call
CoinApiService.checkCoinAddress()to verify the address format before any operationPre-flight AML screening: Screen every destination address via
ToolsApiServicebefore outbound transfersAmount precision: Use String in API calls (
"0.01"), BigDecimal in application logic. Never use float/double**failOnAml: true**: Keep this enabled by default; only disable with explicit business justificationWhitelist first: Recurring transfer destinations should be whitelisted;
ONE_TIME_ADDRESSis only for genuinely one-off payments
Co-Signer Security
No blind approval: Every transaction must be validated against
customerRefId, amount, and destination addressCo-Signer must be deployed in an isolated private network with no public internet inbound access
Production Co-Signer API Keys must have a Callback URL configured
Webhook Security
Verify RSA signature before processing any event
Production endpoints must use HTTPS
Implement idempotent handlers to prevent double-crediting or double-processing
Restrict inbound traffic to Safeheron egress IPs at the firewall level
Always implement REST API polling as a fallback alongside webhooks
4.2 Architecture Recommendations
Tiered Approval Strategy
For exchange-grade deployments, configure layered approval policies:
Single tx ≤ $100,000
API Co-Signer auto-approve
Single tx > $100,000
Ops team 2-of-3
24H total $100K–$500K
Ops team 2-of-3
24H total $500K–$2M
Finance team 2-of-2
24H total > $2M
Executive 1-of-2
Always add a catch-all blocking rule at the bottom of the policy stack to intercept unmatched transactions.
Complete Deposit–Withdrawal Architecture
4.3 Effective Prompt Techniques
Here are some proven, high-impact prompts for use with the SKILL:
Quick start
"Use Safeheron skill to set up my first API call"
Create wallet
"Generate Java code to create a wallet and add ETH and USDT"
Send transaction
"Create a transaction to send 0.01 ETH from wallet abc to address 0x1234..."
Spring Boot config
"Generate Spring Boot configuration class for Safeheron SDK"
Webhook handler
"Write a webhook handler that processes incoming transaction events"
Co-Signer setup
"Help me set up the API Co-Signer approval callback service"
Error debugging
"My API call returns error 1010 — what's wrong and how do I fix it?"
Security review
"Review my Safeheron integration code for security issues"
Prompt tips:
Specify context: Tell the AI your business scenario (e.g. "exchange deposit flow") and it will automatically include security checks and best practices
Name your framework: If you use Spring Boot, mention it in the prompt — the AI will generate corresponding Bean configurations and dependency injection
State constraints: Mention security requirements (e.g. "inject keys via environment variables") and the AI will comply
Iterate: Start with basic code, then ask the AI to "add exception handling" or "add AML screening"
4.4 Testnet Environment
Safeheron supports the following test networks — always test thoroughly before going live:
Ethereum Sepolia
ETH_SEPOLIA
Bitcoin Testnet
BITCOIN_BTC_TESTNET
TRON Shasta
TRX_SHASTA
Use a prompt like this to generate testnet code:
5. Troubleshooting
5.1 API Error Code Quick Reference
1010
Parameter decryption failed
Wrong safeheronRsaPublicKey in config
Re-copy the Safeheron Platform Public Key from Console
1012
Signature verification failed
rsaPrivateKey not in PKCS8 format, or doesn't match the public key in Console
Re-run openssl pkcs8 conversion
9001
customerRefId already exists
Duplicate submission
Query the existing transaction instead of creating a new one
9028
MPC Sign policy not configured
First-time MPC Sign usage
Contact Safeheron Support to activate
Illegal IP
IP not whitelisted
Server IP not registered
Add IP in Console → API Keys → IP Whitelist
5.2 Common SDK Coding Errors
Error: Calling interface methods directly
Error: Wrong data types
Error: Numeric amount types
Error: Swapping config fields
5.3 Using the SKILL for Quick Debugging
When you encounter an error, paste it directly to the AI:
The AI will use the SKILL's built-in ERROR_CODES.md knowledge to pinpoint the issue and provide step-by-step fixes.

6. Appendix
6.1 SDK API Service Quick Reference
Wallet Account
AccountApiService
Create/query wallets, add coins
Coin Management
CoinApiService
Query coin info, validate addresses
Transaction
TransactionApiService
Create/query/cancel/speed-up transactions
MPC Signing
MPCSignApiService
Raw hash signing
Web3
Web3ApiService
EVM chain signing operations
Whitelist
WhitelistApiService
Address whitelist CRUD
Compliance
ComplianceApiService
AML/KYT report queries
Gas Station
GasApiService
Gas balance and refill records
Tools
ToolsApiService
AML address risk screening
6.2 Transaction Status Flow
6.3 Resources
Safeheron SKILL GitHub
Safeheron API Docs
Java SDK GitHub
Safeheron Web Console
Last updated

