Skip to content

selendra/selendra-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selendra SDK

SDK for building applications on Selendra blockchain.

npm version License

Overview

TypeScript SDK for Selendra blockchain with full support for:

  • 30 Pallets - Complete coverage of all Selendra runtime pallets
  • EVM Support - Full Ethereum compatibility via Frontier
  • React Hooks - Production-ready hooks for dApp development
  • Unified Accounts - Seamless Substrate ↔ EVM account mapping
  • Type Safety - Full TypeScript with comprehensive types

Packages

Package Description NPM
@selendrajs/sdk Core SDK with all pallets npm
@selendrajs/cli Command-line interface npm

Installation

# Core SDK
npm install @selendrajs/sdk

# CLI (global)
npm install -g @selendrajs/cli

Quick Start

import { createSDK } from "@selendrajs/sdk";

// Connect to Selendra
const sdk = createSDK({ rpcUrl: "wss://rpc.selendra.org" });
await sdk.connect();

// Query balance
const balance = await sdk.pallets.balances.queries.getBalance("5GrwvaEF...");
console.log(`Balance: ${balance.free}`);

// Transfer tokens
const result = await sdk.pallets.balances.manager.transfer(
  signer,
  signerAddress,
  { dest: "5FHneW46...", value: "1000000000000000000" }
);

// Disconnect
await sdk.disconnect();

React Integration

import {
  SelendraProvider,
  useSelendra,
  useBalance,
} from "@selendrajs/sdk/react";

function App() {
  return (
    <SelendraProvider config={{ rpcUrl: "wss://rpc.selendra.org" }}>
      <Wallet />
    </SelendraProvider>
  );
}

function Wallet() {
  const { isConnected } = useSelendra();
  const { balance, isLoading } = useBalance("5GrwvaEF...");

  if (!isConnected) return <div>Connecting...</div>;
  if (isLoading) return <div>Loading...</div>;

  return <div>Balance: {balance?.free}</div>;
}

Supported Pallets

Core

  • Balances - Token transfers and queries
  • Staking - Validator nomination and rewards
  • Session - Session key management

Governance

  • Democracy - Proposals and referenda
  • Council - Collective decision-making
  • Technical Committee - Technical governance
  • Treasury - Community funding
  • Elections - Council elections (Phragmen)

Account Management

  • Identity - On-chain identity
  • Multisig - Multi-signature accounts
  • Proxy - Account delegation
  • Vesting - Token vesting schedules
  • Utility - Batch transactions

Smart Contracts

  • Contracts - ink! WASM contracts
  • EVM - Ethereum Virtual Machine
  • Ethereum - Ethereum transaction compatibility
  • XVM - Cross-VM calls

Selendra-Specific

  • Aleph - Consensus and finality
  • Elections - Validator elections
  • Committee Management - Validator performance
  • Operations - Account maintenance
  • Unified Accounts - Substrate ↔ EVM mapping

Administration

  • Sudo - Privileged operations
  • Safe Mode - Emergency protection
  • Tx Pause - Transaction pausing
  • Scheduler - Scheduled calls
  • Preimage - Preimage storage

Project Structure

selendra-sdk/
├── packages/
│   ├── core/                  # @selendrajs/sdk
│   │   ├── src/
│   │   │   ├── core/          # SDK core classes
│   │   │   ├── pallets/       # All 30 pallet implementations
│   │   │   ├── providers/     # Connection providers
│   │   │   ├── react/         # React hooks
│   │   │   ├── unified/       # Unified accounts
│   │   │   ├── types/         # TypeScript types
│   │   │   └── utils/         # Utilities
│   │   ├── tests/             # Jest tests
│   │   └── examples/          # Usage examples
│   │
│   └── cli/                   # @selendrajs/cli
│       ├── src/
│       │   ├── commands/      # CLI commands
│       │   ├── utils/         # CLI utilities
│       │   └── templates/     # Project templates
│       └── example/           # Example projects
│
├── package.json               # Workspace root
└── README.md

CLI Usage

# Create new project
selendra init my-dapp

# Check network status
selendra status --network testnet

# Check balance
selendra balance 0x742d35Cc6634C0532925a3b844Bc9e7595f3f4A

# Create account
selendra account new

# Deploy contract
selendra deploy MyToken --network testnet

# Staking info
selendra stake info

See CLI README for full documentation.

Examples

See the packages/core/examples/ directory for comprehensive examples:

  • balance/ - Balance queries and transfers
  • staking/ - Staking operations
  • governance/ - Democracy, Council, Treasury
  • pools/ - Nomination pools
  • evm/ - EVM interactions
  • contracts/ - ink! smart contracts
  • unified/ - Unified accounts

Development

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm test

# Build specific packages
npm run build:core
npm run build:cli

# Run CLI in development
npm run cli -- status --network testnet

Documentation

Legacy Code

The legacy Rust and old TypeScript implementations are preserved in the legacy branch:

git checkout legacy

License

Apache-2.0 - see LICENSE

Contributing

Contributions welcome! Please read our contributing guidelines before submitting PRs.

Links

About

selendra official sdk for rust and typescript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages