Selendra SDK
TypeScript SDK for Selendra
TypeScript library for building dApps on Selendra. Wraps Substrate pallets with React hooks.
Status
| Component | Status |
|---|---|
| Substrate | ✓ Production (staking, governance, treasury) |
| React | ✓ Production (15 hooks) |
| Account Conversion | ✓ Production (Substrate ↔ EVM) |
| EVM | Beta (basic queries only) |
| Rust SDK | In 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 candidatesvote()- Vote for councilsubmitCandidacy()- Run for council
Account Management:
get_balance()- Query account balanceget_account_info()- Full account data (nonce, balances)transfer()- Send tokensaccount_id()- Get account ID
Unified Accounts:
substrateToEvm()- Convert addressesevmToSubstrate()- Convert addressesclaimDefaultEvmAddress()- Claim EVM addresshasMappingOnChain()- 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 balancegetBlockNumber()- Current blockgetTransactionCount()- 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
- TypeScript API Reference - Complete API docs
- React Hooks Guide - React integration
- Rust API - Rust SDK (in development)
- Production Status - What works, what doesn't
- Use Cases - When to use SDK
- Migration Guides - From polkadot.js or ethers
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
- GitHub Issues: github.com/selendra/selendra-sdk/issues
- GitHub Discussions: github.com/selendra/selendra-sdk/discussions
- Documentation: selendra.org/docs/sdk
Comparison: SDK vs Direct Libraries
Built on top of these established libraries:
| Feature | Selendra SDK | polkadot.js | web3.js |
|---|---|---|---|
| Substrate Pallets | Wrapped API | Full access | Not supported |
| EVM Contracts | Basic (uses ethers) | Not supported | Full support |
| React Hooks | 15 hooks | Build your own | Use wagmi/other |
| Unified Accounts | Built-in | Manual conversion | Not supported |
| Learning Curve | Simplified | Lower-level | Mid-level |
| Bundle Size | ~300KB | ~500KB+ | ~200KB |
| TypeScript | Yes | Yes | Yes |
Selendra SDK wraps Polkadot.js for Substrate and Ethers.js for EVM. Choose the tool that fits your use case.
Found an issue or want to contribute?
Help us improve this documentation by editing this page on GitHub.
