Selendra SDK
Official TypeScript SDK for building applications on Selendra blockchain
Selendra SDK
The official TypeScript SDK for building decentralized applications on Selendra blockchain. Provides comprehensive access to all Selendra runtime pallets with full type safety.
Status (v2.0.0)
| Component | Status |
|---|---|
| 29 Pallets | ✓ Production (complete coverage) |
| React Hooks | ✓ Production (6 core hooks) |
| Unified Accounts | ✓ Production (Substrate ↔ EVM) |
| EVM (Frontier) | ✓ Production (full support) |
| TypeScript | ✓ Full type safety |
| viem + wagmi | ✓ Modern EVM tooling |
Install
# Core SDK
npm install @selendrajs/sdk
# CLI (global, optional)
npm install -g @selendrajs/cli
Packages:
- @selendrajs/sdk - Core SDK
- @selendrajs/cli - CLI tools
Quick Start
import { createSDK } from "@selendrajs/sdk";
// Connect to Selendra
const sdk = createSDK({
rpcUrl: "wss://rpc.selendra.org",
});
await sdk.connect();
// Query balance using pallet queries
const balance = await sdk.pallets.balances.queries.account(
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
);
console.log(`Free: ${balance.free}`);
// Transfer tokens using pallet manager
const tx = sdk.pallets.balances.manager.transfer({
dest: "5FHneW46...",
value: "1000000000000000000",
});
await tx.signAndSend(signer);
// Disconnect when done
await sdk.disconnect();
SDK Architecture
The SDK uses a pallet manager pattern for organizing blockchain operations:
sdk.pallets.<pallet-name>.queries → Read-only queries
sdk.pallets.<pallet-name>.manager → Transactions/extrinsics
All 29 Pallets
| Category | Pallets |
|---|---|
| Core | balances, staking, session, utility |
| Governance | democracy, council, treasury, elections, electionsPhragmen, technicalCommittee |
| EVM (Frontier) | evm, ethereum, ethereumChecked, dynamicEvmBaseFee |
| Smart Contracts | contracts, xvm |
| Account | identity, proxy, multisig, vesting |
| Selendra | aleph, committeeManagement, operations, nominationPools |
| Admin | sudo, scheduler, preimage, safeMode, txPause |
Features
TypeScript API - Complete API reference
Pallets Reference - All 29 pallet APIs
React Hooks - Hooks and components
CLI Tools - Command-line interface
React Hooks (Production)
import { useSelendra, useBalance, useTransaction } from "@selendrajs/sdk/react";
function MyComponent() {
const { sdk, isConnected } = useSelendra();
const { balance, loading } = useBalance(address);
const { submit, status } = useTransaction();
return <div>Balance: {balance?.free}</div>;
}
Available hooks:
| Hook | Description |
|---|---|
useSelendra | SDK connection and state management |
useBalance | Account balance queries |
useTransaction | Transaction submission and tracking |
useTransactions | Multiple transaction management |
SelendraProvider | React context provider |
Coming soon: useStaking, useGovernance, useNominationPools
EVM Support (Full via Frontier + viem)
The SDK provides complete EVM support through Frontier integration with viem and wagmi:
import { createWalletClient, http } from 'viem';
import { selendra, selendraTestnet } from '@selendrajs/sdk/chains';
// Create viem client
const client = createWalletClient({
chain: selendra,
transport: http(),
});
// Deploy contract
const createTx = sdk.pallets.evm.manager.create({
source: evmAddress,
init: bytecode,
value: 0n,
gasLimit: 1000000n,
maxFeePerGas: 1000000000n,
});
// Call contract
const callTx = sdk.pallets.evm.manager.call({
source: evmAddress,
target: contractAddress,
input: encodedData,
value: 0n,
gasLimit: 100000n,
maxFeePerGas: 1000000000n,
});
// Query EVM state
const balance = await sdk.pallets.evm.queries.accountBasic(evmAddress);
const code = await sdk.pallets.evm.queries.accountCodes(contractAddress);
Wagmi Integration
import { WagmiProvider } from 'wagmi';
import { selendra, selendraTestnet } from '@selendrajs/sdk/chains';
import { createConfig } from 'wagmi';
const config = createConfig({
chains: [selendra, selendraTestnet],
transports: {
[selendra.id]: http(),
[selendraTestnet.id]: http(),
},
});
function App() {
return (
<WagmiProvider config={config}>
<YourApp />
</WagmiProvider>
);
}
Chain Definitions
Pre-configured chain definitions for viem and wagmi:
import { selendra, selendraTestnet } from '@selendrajs/sdk/chains';
// Mainnet
selendra.id // 1961
selendra.rpcUrls // wss://rpc.selendra.org, https://rpc.selendra.org
// Testnet
selendraTestnet.id // 1953
selendraTestnet.rpcUrls // wss://rpc-testnet.selendra.org
Network Endpoints
| Network | Substrate RPC | EVM RPC | Chain ID |
|---|---|---|---|
| Mainnet | wss://rpc.selendra.org | https://rpc.selendra.org | 1961 |
| Testnet | wss://rpc-testnet.selendra.org | https://rpc-testnet.selendra.org | 1953 |
| Local | ws://127.0.0.1:9944 | http://127.0.0.1:8545 | - |
Migration from ethers.js
If migrating from ethers.js, see our migration guide.
Key changes:
- Replace
ethers.providerswith viemcreatePublicClient - Replace
ethers.Walletwith viemcreateWalletClient - Use viem's type-safe contract interactions
- Leverage wagmi for React applications
Next Steps
- TypeScript API - Complete API reference
- Pallets Reference - All 29 pallet APIs
- React Hooks - Build React dApps
- CLI Tools - Command-line interface
Found an issue or want to contribute?
Help us improve this documentation by editing this page on GitHub.