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)โ
- Hello SELF - Basic connection and query
- Token Transfer - Send TEST tokens
- Block Explorer - Read blockchain data
- Event Watcher - Subscribe to events
Advanced Examples (Coming Later)โ
- Simple dApp - Basic decentralized application
- NFT Minting - Create test NFTs
- Governance Voting - Participate in test governance
- 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:
- Principle of Least Privilege - Only expose what's necessary
- Testnet Isolation - Clear separation from mainnet
- Fail-Safe Defaults - Conservative limits and checks
- Transparent Communication - Clear about limitations
Questions?โ
- Discord: #sdk-development
- GitHub: Create an issue with [SDK] tag
- Email: sdk@self.app
โ ๏ธ Remember: These SDKs are for TESTNET only. Never use with real assets!