Skip to main content

SELF Chain SDK Structure (Testnet)

โš ๏ธ TESTNET ONLY: These SDKs are for testnet use only. Do not use in production or with real assets.

Repository Structure Planโ€‹

This document outlines the planned structure for SELF Chain SDKs. These will be separate repositories when released.

Planned SDK Repositoriesโ€‹

self-chain-sdk-js/          # JavaScript/TypeScript SDK
self-chain-sdk-rust/ # Rust SDK
self-chain-sdk-python/ # Python SDK
self-chain-sdk-go/ # Go SDK

JavaScript/TypeScript SDK Structureโ€‹

self-chain-sdk-js/
โ”œโ”€โ”€ README.md # โš ๏ธ TESTNET warnings prominent
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ index.ts
โ”‚ โ”œโ”€โ”€ client/
โ”‚ โ”‚ โ”œโ”€โ”€ SELFClient.ts # Main client class
โ”‚ โ”‚ โ”œโ”€โ”€ testnet.ts # Testnet-specific configuration
โ”‚ โ”‚ โ””โ”€โ”€ types.ts
โ”‚ โ”œโ”€โ”€ crypto/
โ”‚ โ”‚ โ”œโ”€โ”€ keys.ts # Key generation (testnet only)
โ”‚ โ”‚ โ”œโ”€โ”€ signing.ts
โ”‚ โ”‚ โ””โ”€โ”€ hashing.ts
โ”‚ โ”œโ”€โ”€ transactions/
โ”‚ โ”‚ โ”œโ”€โ”€ builder.ts # Transaction construction
โ”‚ โ”‚ โ”œโ”€โ”€ types.ts
โ”‚ โ”‚ โ””โ”€โ”€ validation.ts
โ”‚ โ”œโ”€โ”€ poai/ # PoAI interaction (limited in testnet)
โ”‚ โ”‚ โ”œโ”€โ”€ validator.ts
โ”‚ โ”‚ โ””โ”€โ”€ colorMarker.ts
โ”‚ โ””โ”€โ”€ utils/
โ”‚ โ”œโ”€โ”€ constants.ts # TESTNET constants
โ”‚ โ””โ”€โ”€ errors.ts
โ”œโ”€โ”€ examples/ # Testnet examples only
โ”‚ โ”œโ”€โ”€ 01-connect.ts # Basic connection
โ”‚ โ”œโ”€โ”€ 02-transfer.ts # Token transfer
โ”‚ โ”œโ”€โ”€ 03-query.ts # Query blockchain
โ”‚ โ””โ”€โ”€ README.md # โš ๏ธ Testnet warning
โ”œโ”€โ”€ tests/
โ”‚ โ”œโ”€โ”€ unit/
โ”‚ โ””โ”€โ”€ integration/
โ””โ”€โ”€ docs/
โ”œโ”€โ”€ getting-started.md # Testnet focus
โ””โ”€โ”€ api-reference.md

Core SDK Features (Testnet Limited)โ€‹

1. Client Connectionโ€‹

// Example usage (TESTNET ONLY)
import { SELFClient } from '@self-chain/sdk';

const client = new SELFClient({
network: 'testnet', // ONLY testnet supported
endpoint: 'https://testnet-api.self.app',
warning: true // Shows testnet warning on connection
});

// SDK will display warning:
// โš ๏ธ WARNING: Connected to SELF Chain TESTNET
// Do not use real assets or production data!

2. Transaction Buildingโ€‹

// All transactions include testnet marker
const tx = await client.transaction()
.transfer({
to: 'self1234...', // Testnet address
amount: '100', // TEST tokens only
memo: 'Test transfer'
})
.sign(privateKey) // Testnet key only
.broadcast();

// Response includes testnet warning
console.log(tx.warning); // "This is a testnet transaction"

3. Safety Featuresโ€‹

All SDKs will include:

// Automatic testnet detection
if (isMainnetAddress(address)) {
throw new Error('Mainnet address detected! Use testnet addresses only.');
}

// Transaction limits
const MAX_TESTNET_AMOUNT = 10000; // TEST tokens
if (amount > MAX_TESTNET_AMOUNT) {
throw new Error('Amount exceeds testnet limits');
}

// Prominent warnings
console.warn('๐Ÿšง TESTNET TRANSACTION - NO REAL VALUE ๐Ÿšง');

Public Interfaces (Security-Safe)โ€‹

Exposed APIsโ€‹

These interfaces can be safely made public:

// Read-only blockchain queries
interface BlockchainQuery {
getBlock(height: number): Promise<Block>;
getTransaction(hash: string): Promise<Transaction>;
getAccount(address: string): Promise<Account>;
getValidators(): Promise<Validator[]>;
}

// Transaction construction (no security secrets)
interface TransactionBuilder {
transfer(params: TransferParams): Transaction;
delegate(params: DelegateParams): Transaction;
undelegate(params: UndelegateParams): Transaction;
}

// Event subscription (read-only)
interface EventSubscription {
onBlock(callback: BlockCallback): Unsubscribe;
onTransaction(callback: TxCallback): Unsubscribe;
onEvent(type: string, callback: EventCallback): Unsubscribe;
}

Hidden/Restricted APIsโ€‹

These remain in private repositories:

// โŒ NOT exposed in public SDKs:
// - AI validation thresholds
// - Pattern matching algorithms
// - Consensus mechanism internals
// - Security-critical parameters
// - Production configurations

SDK Development Guidelinesโ€‹

1. Testnet-First Designโ€‹

  • Every function assumes testnet
  • Prominent warnings throughout
  • Automatic mainnet detection and rejection
  • Test token limits enforced

2. Security Boundariesโ€‹

  • No exposure of validation logic
  • No consensus parameters
  • No security thresholds
  • Read-only blockchain access

3. Developer Experienceโ€‹

  • Clear error messages with testnet context
  • Comprehensive examples (testnet only)
  • TypeScript types for safety
  • Intuitive API design

Example Applications Planโ€‹

Basic Examples (Safe for Testnet)โ€‹

  1. Hello SELF - Basic connection and query
  2. Token Transfer - Send TEST tokens
  3. Block Explorer - Read blockchain data
  4. Event Watcher - Subscribe to events

Advanced Examples (Coming Later)โ€‹

  1. Simple dApp - Basic decentralized application
  2. NFT Minting - Create test NFTs
  3. Governance Voting - Participate in test governance
  4. Cross-Chain Bridge - Test bridge functionality

Release Timeline (Tentative)โ€‹

Phase 1: Core SDKs (Q1 2024)โ€‹

  • JavaScript/TypeScript SDK (testnet)
  • Basic transaction support
  • Read-only queries
  • Event subscriptions

Phase 2: Extended Features (Q2 2024)โ€‹

  • Python SDK
  • Rust SDK
  • Smart contract interaction
  • Advanced queries

Phase 3: Developer Tools (Q3 2024)โ€‹

  • Go SDK
  • CLI improvements
  • Testing frameworks
  • Documentation expansion

Contributing to SDKsโ€‹

When SDKs are released, contributions welcome for:

  • ๐Ÿ”ง Bug fixes
  • ๐Ÿ“š Documentation improvements
  • ๐Ÿงช Test coverage
  • ๐ŸŒ Internationalization
  • โ™ฟ Accessibility features

NOT accepted:

  • ๐Ÿšซ Mainnet features (until ready)
  • ๐Ÿšซ Security bypass attempts
  • ๐Ÿšซ Consensus modifications
  • ๐Ÿšซ Production features

Security Considerationsโ€‹

All SDK development follows:

  1. Principle of Least Privilege - Only expose what's necessary
  2. Testnet Isolation - Clear separation from mainnet
  3. Fail-Safe Defaults - Conservative limits and checks
  4. Transparent Communication - Clear about limitations

Questions?โ€‹


โš ๏ธ Remember: These SDKs are for TESTNET only. Never use with real assets!