1k-adding-chains

1k-adding-chains

热门

Guide for adding new blockchain chains to OneKey. Use when implementing new chain support, adding blockchain protocols, or understanding chain architecture. Triggers on chain, blockchain, protocol, network, coin, token, add chain, new chain.

2.3KStar
478Fork
更新于 1/27/2026
SKILL.md
readonly只读
name
1k-adding-chains
description

Guide for adding new blockchain chains to OneKey. Use when implementing new chain support, adding blockchain protocols, or understanding chain architecture. Triggers on chain, blockchain, protocol, network, coin, token, add chain, new chain.

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:

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:

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

// packages/core/src/chains/index.ts
export const chainRegistry = {
  evm: () => import('./evm'),
  btc: () => import('./btc'),
  sol: () => import('./sol'),
  mychain: () => import('./mychain'),
};

Address Validation

export function validateAddress(address: string): boolean {
  // Implement chain-specific validation
  return isValidAddress(address);
}

Transaction Building

export async function buildTransaction(params: TxParams): Promise<UnsignedTx> {
  // Build unsigned transaction
  return {
    // transaction data
  };
}

You Might Also Like

Related Skills

verify

verify

243K

Use when you want to validate changes before committing, or when you need to check all React contribution requirements.

facebook avatarfacebook
获取
test

test

243K

Use when you need to run tests for React core. Supports source, www, stable, and experimental channels.

facebook avatarfacebook
获取

Use when feature flag tests fail, flags need updating, understanding @gate pragmas, debugging channel-specific test failures, or adding new flags to React.

facebook avatarfacebook
获取

Use when adding new error messages to React, or seeing "unknown error code" warnings.

facebook avatarfacebook
获取
flow

flow

243K

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

facebook avatarfacebook
获取
flags

flags

243K

Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.

facebook avatarfacebook
获取