Selendra

Documentation

Selendra SDK

TypeScript SDK for Selendra

TypeScript library for building dApps on Selendra. Wraps Substrate pallets with React hooks.

Status

ComponentStatus
Substrate✓ Production (staking, governance, treasury)
React✓ Production (15 hooks)
Account Conversion✓ Production (Substrate ↔ EVM)
EVMBeta (basic queries only)
Rust SDKIn Development

Install

npm install @selendrajs/sdk

Package: @selendrajs/sdk

When to Use

Use SDK if:

  • Building React dApps
  • Need Substrate features (staking, governance)
  • Want unified accounts

Use polkadot.js if:

  • Need full Substrate control
  • Non-React apps

Use web3.js/ethers if:

  • Pure EVM dApp only

Quick Example

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

const sdk = new SelendraSDK({
  endpoint: "wss://rpc-testnet.selendra.org",
});
await sdk.connect();

const balance = await sdk.getBalance(address);

Features

TypeScript - Core SDK API

React - Hooks and components

Rust - Rust SDK (in development)

Status - Feature completion

Use Cases - Real examples

  • getCandidates() - Get candidates
  • vote() - Vote for council
  • submitCandidacy() - Run for council

Account Management:

  • get_balance() - Query account balance
  • get_account_info() - Full account data (nonce, balances)
  • transfer() - Send tokens
  • account_id() - Get account ID

Unified Accounts:

  • substrateToEvm() - Convert addresses
  • evmToSubstrate() - Convert addresses
  • claimDefaultEvmAddress() - Claim EVM address
  • hasMappingOnChain() - Check mapping exists

React Hooks (Production)

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

function MyComponent() {
  const { isConnected } = useSelendra();
  const { balance } = useBalance(address);
  const { bond, nominate } = useStaking();

  return <div>Balance: {balance}</div>;
}

Available hooks: 15 production-ready hooks

  • Connection management
  • Balance queries
  • Transaction handling
  • Contract interaction
  • Event listening
  • Block subscriptions
  • Staking operations
  • Network status

EVM (Beta - Limited)

Works:

  • getBalance() - Query ETH balance
  • getBlockNumber() - Current block
  • getTransactionCount() - Get nonce

Not Ready:

  • Contract deployment
  • Gas estimation
  • Transaction history
  • Cross-chain bridge

For full EVM support, use web3.js or ethers.js directly.

Documentation

Network Endpoints

Mainnet:

  • WebSocket: wss://rpc.selendra.org
  • HTTP: https://rpc.selendra.org

Testnet:

  • WebSocket: wss://rpc-testnet.selendra.org

Examples

// Staking example
import { Connection, keypair_from_string } from "@selendrajs/sdk";

const conn = await Connection.new("wss://rpc-testnet.selendra.org");
const keypair = keypair_from_string("//Alice");
const signed = conn.sign(keypair);

// Bond tokens
const tx = await signed.stake_bond(1_000_000_000_000);

// Nominate validators
const validators = [validator1, validator2];
await signed.stake_nominate(validators);
// React example
import { SelendraProvider } from "@selendrajs/sdk/react";

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

Package Info

npm: @selendrajs/sdk
Status: Published and available on npm registry
TypeScript: Full type support
React: ≥18.0.0
Bundle: Tree-shakeable ESM + CJS

Support

Comparison: SDK vs Direct Libraries

Built on top of these established libraries:

FeatureSelendra SDKpolkadot.jsweb3.js
Substrate PalletsWrapped APIFull accessNot supported
EVM ContractsBasic (uses ethers)Not supportedFull support
React Hooks15 hooksBuild your ownUse wagmi/other
Unified AccountsBuilt-inManual conversionNot supported
Learning CurveSimplifiedLower-levelMid-level
Bundle Size~300KB~500KB+~200KB
TypeScriptYesYesYes

Selendra SDK wraps Polkadot.js for Substrate and Ethers.js for EVM. Choose the tool that fits your use case.

Contribute

Found an issue or want to contribute?

Help us improve this documentation by editing this page on GitHub.

Edit this page on GitHub