Skill站外收录 @skilllib/skill-2117939930272416635
1k-adding-chains
为 OneKey 钱包扩展对新区块链的支持,涵盖从底层链逻辑实现、链配置注册、交易与地址处理到 UI 适配和全流程测试的完整开发流程,确保新链能无缝集成进现有多链架构。
区块链 AI 技能
Skills.MD
# Adding New Chains to OneKey
## Overview
OneKey supports 40+ blockchains with pluggable chain implementations. This guide covers the process of adding new chain support.
## Steps to Add a New Chain
### 1. Implement Chain Core Logic
Location: `packages/core/src/chains/`
Create a new directory for the chain:
```
packages/core/src/chains/mychain/
├── index.ts # Main exports
├── types.ts # Chain-specific types
├── CoreChainSoftware/ # Software wallet implementation
│ └── index.ts
├── sdkMychain/ # SDK wrapper if needed
│ └── index.ts
└── @tests/ # Chain tests
└── index.test.ts
```
### 2. Add Chain Configuration
Location: `packages/shared/src/config/chains/`
Add chain constants and configuration:
```typescript
export const CHAIN_MYCHAIN = {
id: 'mychain',
name: 'My Chain',
symbol: 'MYC',
decimals: 18,
// ... other chain config
};
```
### 3. Update UI Components for Chain-Specific Features
Location: `packages/kit/src/`
Add any chain-specific UI components or modifications needed for:
- Transaction building
- Address display
- Token management
- Network selection
### 4. Add Tests for Chain Functionality
Location: `packages/core/src/chains/mychain/@tests/`
Write comprehensive tests:
```typescript
describe('MyChain', () => {
it('should generate valid addresses', () => {
// test address generation
});
it('should sign transactions correctly', () => {
// test transaction signing
});
it('should validate addresses', () => {
// test address validation
});
});
```
## Chain Implementation Checklist
- [ ] Core chain logic in `packages/core/src/chains/`
- [ ] Chain configuration in `packages/shared/`
- [ ] Address generation and validation
- [ ] Transaction building and signing
- [ ] Balance fetching
- [ ] Token support (if applicable)
- [ ] Hardware wallet support (if applicable)
- [ ] UI components updated
- [ ] Tests written and passing
- [ ] Documentation added
## Reference Existing Implementations
Look at existing chain implementations for guidance:
- EVM chains: `packages/core/src/chains/evm/`
- Bitcoin: `packages/core/src/chains/btc/`
- Solana: `packages/core/src/chains/sol/`
## Common Patterns
### Chain Registry Pattern
```typescript
// packages/core/src/chains/index.ts
export const chainRegistry = {
evm: () => import('./evm'),
btc: () => import('./btc'),
sol: () => import('./sol'),
mychain: () => import('./mychain'),
};
```
### Address Validation
```typescript
export function validateAddress(address: string): boolean {
// Implement chain-specific validation
return isValidAddress(address);
}
```
### Transaction Building
```typescript
export async function buildTransaction(params: TxParams): Promise<UnsignedTx> {
// Build unsigned transaction
return {
// transaction data
};
}
```
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「1k-adding-chains」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次