From 3c0c262104721ac6b2887bfb2c32c684de2b14d5 Mon Sep 17 00:00:00 2001 From: alexander-sei Date: Thu, 26 Feb 2026 17:22:14 +0100 Subject: [PATCH 1/2] Add create-sei, add seijs index --- content/evm/_meta.js | 23 +------ content/evm/sei-js/_meta.js | 4 ++ content/evm/sei-js/create-sei.mdx | 108 ++++++++++++++++++++++++++++++ content/evm/sei-js/index.mdx | 82 +++++++++++++++++++++++ 4 files changed, 196 insertions(+), 21 deletions(-) create mode 100644 content/evm/sei-js/_meta.js create mode 100644 content/evm/sei-js/create-sei.mdx create mode 100644 content/evm/sei-js/index.mdx diff --git a/content/evm/_meta.js b/content/evm/_meta.js index 537c7939..926b93b5 100644 --- a/content/evm/_meta.js +++ b/content/evm/_meta.js @@ -55,26 +55,7 @@ export default { type: 'separator', title: 'sei-js Library' }, - 'seijs-introduction': { - title: 'Introduction to sei-js', - href: 'https://sei-js.docs.sei.io/introduction' - }, - 'scaffold-sei': { - title: 'Scaffold Sei', - href: 'https://sei-js.docs.sei.io/create-sei/welcome' - }, - 'mcp-server-seijs': { - title: 'MCP Server', - href: 'https://sei-js.docs.sei.io/mcp-server/introduction' - }, - 'sei-x402': { - title: 'X402', - href: 'https://sei-js.docs.sei.io/x402/introduction' - }, - 'seijs-ledger': { - title: 'Ledger', - href: 'https://sei-js.docs.sei.io/ledger/introduction' - }, + 'sei-js': '@sei-js SDK', '-- Ecosystem Tutorials': { type: 'separator', @@ -104,5 +85,5 @@ export default { type: 'separator', title: 'Hardware Wallets' }, - 'ledger-ethers': 'Using Ledger with Ethers' + 'ledger-ethers': 'Ledger Hardware Wallet' }; diff --git a/content/evm/sei-js/_meta.js b/content/evm/sei-js/_meta.js new file mode 100644 index 00000000..ba03498a --- /dev/null +++ b/content/evm/sei-js/_meta.js @@ -0,0 +1,4 @@ +export default { + index: 'Introduction', + 'create-sei': 'Scaffold Sei' +}; diff --git a/content/evm/sei-js/create-sei.mdx b/content/evm/sei-js/create-sei.mdx new file mode 100644 index 00000000..7e28e0cf --- /dev/null +++ b/content/evm/sei-js/create-sei.mdx @@ -0,0 +1,108 @@ +--- +title: 'Scaffold Sei' +description: 'CLI tool for scaffolding production-ready Sei applications with pre-configured templates' +keywords: ['create-sei', 'scaffold', 'cli', 'sei', 'nextjs', 'wagmi', 'viem', 'template'] +--- + +import { Callout, Steps, Tabs } from 'nextra/components'; + +# Scaffold Sei + +`@sei-js/create-sei` is a CLI tool that scaffolds production-ready Sei dApps in seconds. Quickly spin up templates with Next.js, modern wallet integration, and TypeScript support. + +```bash +npx @sei-js/create-sei app --name my-sei-app +``` + +Every generated project includes wallet connections, contract interactions, TypeScript, Tailwind CSS, Mantine UI, Biome for formatting, and responsive layouts — no additional setup required. + +## Quick Start + +You don't need to install `@sei-js/create-sei` globally. Use it directly with npx or pnpm: + + + ```bash npx @sei-js/create-sei app --name my-sei-app ``` + ```bash pnpm create @sei-js/create-sei app --name my-sei-app ``` + + +## Interactive Setup + + + +### Run the CLI + +Execute the create-sei command with your project name: + +```bash +npx @sei-js/create-sei app +``` + +### Install and run + +```bash +cd my-sei-app +npm install +npm run dev +``` + +### Start building + +The CLI automatically configures TypeScript, Next.js, Tailwind CSS, Biome formatting, Mantine UI components, and Git initialization. + + + +### CLI Options + +| Command | Description | +| ----------------------- | ----------------------------------------------------- | +| `app` | Create a new Sei dApp | +| `app --name ` | Specify a project name (must be a valid package name) | +| `app --extension ` | Add an optional extension to your project | +| `list-extensions` | List available extensions | + +## Default Template + +The default template creates a **Next.js + Wagmi (EVM)** application — a production-ready Next.js app with Wagmi for type-safe Ethereum wallet connections and blockchain interactions. Includes built-in support for MetaMask, WalletConnect, Coinbase Wallet, and other popular wallets. + +**Tech Stack:** Next.js 14, Wagmi v2, Viem, TanStack Query, Tailwind CSS + +```bash +npx @sei-js/create-sei app --name my-sei-app +``` + +## Extensions + +Enhance your project with additional functionality using extensions. + +### List Available Extensions + +```bash +npx @sei-js/create-sei list-extensions +``` + +### Precompiles Extension + +Add Sei precompile contract integration with examples for querying native blockchain data like token supply, staking info, and governance proposals. + +```bash +npx @sei-js/create-sei app --name my-sei-precompile-app --extension precompiles +``` + +Includes Bank precompile, Staking precompile, and Governance precompile examples. + +## What's Included + +After running the CLI, you'll have a fully configured Sei dApp ready for development: + +- **Project structure** — Organized file structure with components, hooks, and utilities +- **Wallet integration** — Pre-configured wallet connections and hooks +- **Development tools** — TypeScript, Biome, Mantine UI, and Tailwind CSS with sensible defaults +- **Sei network integration** — Built-in network configuration and contract interaction examples + +**Prerequisites:** Node.js v18 or higher is required. Use `node --version` to verify your installation. + +## Troubleshooting + +- **Node version conflicts** — Use `nvm use` to switch to the correct Node.js version +- **Permission errors** — Avoid using `sudo` with npm. Use `nvm` or fix npm permissions +- **Network timeouts** — Try switching to a different registry: `npm config set registry https://registry.npmjs.org/` diff --git a/content/evm/sei-js/index.mdx b/content/evm/sei-js/index.mdx new file mode 100644 index 00000000..9eef803f --- /dev/null +++ b/content/evm/sei-js/index.mdx @@ -0,0 +1,82 @@ +--- +title: '@sei-js SDK' +description: 'A complete TypeScript SDK for building decentralized applications on Sei Network' +keywords: ['sei-js', 'typescript', 'sdk', 'sei network', 'evm', 'precompiles', 'wallet', 'mcp'] +--- + +import { Callout, Cards } from 'nextra/components'; + +# @sei-js SDK + +@sei-js is the complete TypeScript SDK for building applications on Sei Network. Whether you're creating DeFi protocols, NFT marketplaces, or blockchain games, @sei-js provides everything you need to ship faster. + +**Works with your favorite tools:** Sei is fully EVM-compatible, so you can use Viem, Ethers.js, Foundry, Hardhat, and all your existing Ethereum development tools without any changes. @sei-js extends these tools with Sei-specific features like precompiled contracts and optimized wallet connections. + +@sei-js is open source. Contribute at [github.com/sei-protocol/sei-js](https://github.com/sei-protocol/sei-js). + +## Why @sei-js? + +- **Complete TypeScript support** — Full type safety for every function, contract interaction, and API response. Catch errors at compile time. +- **Production ready** — Battle-tested components used by major applications in the Sei ecosystem. +- **Optimized for Sei** — Take advantage of Sei's fast finality, low gas fees, and native features. + +## Package Ecosystem + +### [@sei-js/precompiles](/evm/precompiles) + +Access Sei's precompiled contracts directly from your EVM applications. Interact with native blockchain functions for staking, governance, IBC, and more. + +```bash +npm install @sei-js/precompiles +``` + +### [@sei-js/create-sei](/evm/sei-js/create-sei) + +Bootstrap new Sei projects with pre-configured templates and tooling. Scaffold production-ready dApps in seconds. + +```bash +npx @sei-js/create-sei app +``` + +### [@sei-js/sei-global-wallet](/evm/sei-global-wallet) + +Connect to any Sei-compatible wallet using the EIP-6963 standard. Provides a cross-application embedded wallet experience with social login. + +```bash +npm install @sei-js/sei-global-wallet +``` + +### [@sei-js/ledger](/evm/ledger-ethers) + +Secure transaction signing with Ledger hardware wallets. Provides TypeScript helper functions for the SEI Ledger app. + +```bash +npm install @sei-js/ledger +``` + +### [@sei-js/mcp-server](/evm/ai-tooling/mcp-server) + +Teach Claude, Cursor, Windsurf, or any LLM to interact with the Sei blockchain through the Model Context Protocol. + +```bash +npx @sei-js/mcp-server +``` + +## Quick Start + +Generate a new Sei application using the CLI tool: + +```bash +npx @sei-js/create-sei app +cd app +npm install +npm run dev +``` + +This creates a production-ready project with TypeScript, wallet connections, and Sei network integration out of the box. See the [Scaffold Sei](/evm/sei-js/create-sei) page for details on available templates and options. + +## Community & Support + +- [GitHub Discussions](https://github.com/sei-protocol/sei-js/discussions) — Ask questions and discuss features +- [Discord](https://discord.gg/sei) — Join the Sei developer community +- [GitHub Issues](https://github.com/sei-protocol/sei-js/issues) — Report bugs and request features From 3b14f64e397da132aa12802b2d8b58ffec264fda Mon Sep 17 00:00:00 2001 From: alexander-sei Date: Sat, 14 Mar 2026 17:04:39 -0400 Subject: [PATCH 2/2] split up ledger tutorial --- content/evm/_meta.js | 2 +- content/evm/ledger-ethers.mdx | 197 +++++++--------------------------- content/evm/sei-js/_meta.js | 3 +- content/evm/sei-js/index.mdx | 4 +- content/evm/sei-js/ledger.mdx | 144 +++++++++++++++++++++++++ 5 files changed, 186 insertions(+), 164 deletions(-) create mode 100644 content/evm/sei-js/ledger.mdx diff --git a/content/evm/_meta.js b/content/evm/_meta.js index 1d7ab786..22283840 100644 --- a/content/evm/_meta.js +++ b/content/evm/_meta.js @@ -85,5 +85,5 @@ export default { type: 'separator', title: 'Hardware Wallets' }, - 'ledger-ethers': 'Ledger Hardware Wallet' + 'ledger-ethers': 'Ledger Setup (EVM)' }; diff --git a/content/evm/ledger-ethers.mdx b/content/evm/ledger-ethers.mdx index aa3cb663..b812d51b 100644 --- a/content/evm/ledger-ethers.mdx +++ b/content/evm/ledger-ethers.mdx @@ -1,200 +1,77 @@ --- -title: "Using Ledger Wallet with Ethers on Sei" -description: "Learn how to integrate Ledger hardware wallets with the ethers.js library for secure Sei EVM transactions, including wallet setup, connection, and transaction signing." -keywords: ["ledger wallet", "ethers.js", "hardware wallet", "blockchain security", "sei transactions"] +title: 'Ledger Setup (EVM)' +description: 'Set up your Ledger hardware wallet for signing EVM transactions on Sei, including device configuration, Ethers.js integration, and a simple transfer example.' +keywords: ['ledger wallet', 'ethers.js', 'hardware wallet', 'blockchain security', 'sei transactions', 'evm'] --- -# Using Ledger wallet with ethers on Sei -## Prerequisites & Setup +import { Callout } from 'nextra/components'; + +# Ledger Setup (EVM) + +This guide covers connecting a Ledger hardware wallet to Sei's EVM for signing transactions with Ethers.js. For Cosmos-side signing with the `@sei-js/ledger` package, see the [@sei-js/ledger reference](/evm/sei-js/ledger). + +## Prerequisites 1. **Ledger App Installation** - - On your Ledger device, open the Manager in Ledger Live and install **either** the **Sei** app **or** the **Ethereum** app. - - The Ethereum app on Ledger supports any EVM chain (like Sei), but the native Sei app may provide optimal compatibility. + On your Ledger device, open the Manager in Ledger Live and install **either** the **Sei** app **or** the **Ethereum** app. The Ethereum app supports any EVM chain (like Sei), but the native Sei app may provide optimal compatibility. 2. **Enable Blind Signing** - - Still in the Ledger device's Ethereum or Sei app settings, **enable "Blind signing"**. - - This permits the device to sign arbitrary EVM transactions and contract calls (e.g. precompiles), which would otherwise be rejected for safety. + In the Ledger device's Ethereum or Sei app settings, **enable "Blind signing"**. This permits the device to sign arbitrary EVM transactions and contract calls (e.g. precompiles), which would otherwise be rejected. -3. **USB Permissions on Linux** +3. **USB Permissions (Linux only)** - - If you're on Linux, you'll likely need a **udev rule** so your process can talk to the Ledger over USB/HID. - - Clone the official rules from → https://github.com/LedgerHQ/udev-rules - - Copy the provided `49-ledger.rules` into `/etc/udev/rules.d/`, then `sudo udevadm control --reload-rules` and replug your Ledger. + You'll need a **udev rule** so your process can talk to the Ledger over USB/HID. Clone the official rules from [LedgerHQ/udev-rules](https://github.com/LedgerHQ/udev-rules), copy `49-ledger.rules` into `/etc/udev/rules.d/`, then run `sudo udevadm control --reload-rules` and replug your Ledger. 4. **Install Dependencies** ```bash copy - npm install ethers @ethers-ext/signer-ledger @sei-js/evm @ledgerhq/hw-transport-node-hid + npm install ethers @ethers-ext/signer-ledger @ledgerhq/hw-transport-node-hid ``` - - `@ethers-ext/signer-ledger` provides a `LedgerSigner` that wraps Ledger's USB/HID transport for Ethers.js. - - `@sei-js/evm` exports each precompile's address & ABI. - -## Connecting Your Ledger to Sei via Ethers.js -**Why this matters:** - -- The **provider** connects to the blockchain RPC. -- The **LedgerSigner** injects `signTransaction`/`signMessage` calls to your device. -- Every contract call or tx will require your physical confirmation on the Ledger. +## Connecting Your Ledger ```tsx copy import { LedgerSigner } from '@ethers-ext/signer-ledger'; import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; import { ethers } from 'ethers'; -// 1. Create an RPC provider (here: Sei testnet) const rpcUrl = 'https://evm-rpc-testnet.sei-apis.com'; const provider = new ethers.JsonRpcProvider(rpcUrl); - -// 2. Initialize the LedgerSigner -// - TransportNodeHid handles the low-level USB/HID connection. -// - The signer will prompt your Ledger for each transaction. const signer = new LedgerSigner(TransportNodeHid, provider); -// 3. (Optional) Confirm the address on-device -(async () => { - const addr = await signer.getAddress(); - console.log('Using Ledger address:', addr); -})(); +const addr = await signer.getAddress(); +console.log('Using Ledger address:', addr); ``` -## Governance Precompile Example +Every transaction sent through this signer will require physical confirmation on the Ledger device. -**Key points before you code:** +## Sending a Transfer -- **Precompiles** are optimized, built-in contracts—no external contract deployment needed. -- You must supply the **`value`** field in overrides to attach SEI. -- Every transaction pauses to let you **approve** on Ledger. +A simple example sending SEI from your Ledger to another address: ```tsx copy -import { GOVERNANCE_PRECOMPILE_ADDRESS, GOVERNANCE_PRECOMPILE_ABI } from '@sei-js/evm'; +import { LedgerSigner } from '@ethers-ext/signer-ledger'; +import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; import { ethers } from 'ethers'; -/** - * Deposit SEI into a governance proposal. - * - * @param signer – an initialized LedgerSigner - * @param proposalId – the on-chain ID of the proposal you're participating in - * @param amount – how many SEI to lock (as a decimal string, e.g. "5") - */ -async function depositToProposal(signer: LedgerSigner, proposalId: number, amount: string) { - // 1. Instantiate the precompile contract - const gov = new ethers.Contract(GOVERNANCE_PRECOMPILE_ADDRESS, GOVERNANCE_PRECOMPILE_ABI, signer); - - // 2. Prepare overrides to include SEI value - const overrides = { - value: ethers.parseEther(amount) - }; - - try { - // 3. Send the tx (this will prompt your Ledger to confirm) - const tx = await gov.deposit(proposalId, overrides); - console.log('Deposit TX sent:', tx.hash); - await tx.wait(); // wait for on-chain confirmation - console.log('✅ Deposit confirmed!'); - } catch (err) { - console.error('❌ Deposit failed:', err); - } -} - -/** - * Cast a vote on a governance proposal. - * - * @param signer – LedgerSigner - * @param proposalId – the proposal ID - * @param option – vote choice (1=Yes, 2=Abstain, 3=No, 4=NoWithVeto) - */ -async function castVote(signer: LedgerSigner, proposalId: number, option: number) { - const gov = new ethers.Contract(GOVERNANCE_PRECOMPILE_ADDRESS, GOVERNANCE_PRECOMPILE_ABI, signer); - try { - const tx = await gov.vote(proposalId, option); - console.log('Vote TX sent:', tx.hash); - await tx.wait(); - console.log('✅ Vote recorded!'); - } catch (err) { - console.error('❌ Vote failed:', err); - } -} - -// Bring it all together -async function runGovernanceDemo() { - const proposalId = 1; // ← your target proposal - const depositAmount = '5'; // ← e.g. "5" SEI - const voteOption = 1; // ← Yes - - // Deposit then vote - await depositToProposal(signer, proposalId, depositAmount); - await castVote(signer, proposalId, voteOption); -} - -runGovernanceDemo(); -``` - -## Staking via Precompile Example - -**Before you run the code:** +const provider = new ethers.JsonRpcProvider('https://evm-rpc-testnet.sei-apis.com'); +const signer = new LedgerSigner(TransportNodeHid, provider); -- The staking precompile is simply another in-chain contract that handles delegation logic. -- You must set both `value` (SEI to lock) **and** `from` (your EVM address). -- Gas limits on precompiles can be very low—start small and raise if you hit errors. +const tx = await signer.sendTransaction({ + to: '0xRECIPIENT_ADDRESS', + value: ethers.parseEther('1.0') +}); -```tsx copy -import { STAKING_PRECOMPILE_ADDRESS, STAKING_PRECOMPILE_ABI } from '@sei-js/evm'; - -/** - * Stake SEI to a validator via the staking precompile. - * - * @param signer – LedgerSigner - * @param amount – decimal string of SEI to stake - * @param fromAddress – your EVM account address (for 'from' override) - * @param validatorAddress – the `seivaloper…` address of your validator - */ -async function stake(signer: LedgerSigner, amount: string, fromAddress: string, validatorAddress: string) { - const staking = new ethers.Contract(STAKING_PRECOMPILE_ADDRESS, STAKING_PRECOMPILE_ABI, signer); - - // Attach SEI and explicitly set the 'from' so the precompile knows who's delegating - const overrides = { - from: fromAddress, - value: ethers.parseEther(amount), - // A minimal gas limit; adjust if you get underpriced errors - gasLimit: 100_000 - }; - - console.log(`Staking ${amount} SEI → ${validatorAddress}`); - try { - const tx = await staking.delegate(validatorAddress, overrides); - console.log('Stake TX sent:', tx.hash); - await tx.wait(); - console.log('✅ Stake confirmed!'); - } catch (err) { - console.error('❌ Staking failed:', err); - } -} - -// Demo runner -async function runStakingDemo() { - const validatorAddress = 'seivaloper…'; // ← your chosen validator - const defaultAddress = await signer.getAddress(); - - // Stake 5 SEI - await stake(signer, '5', defaultAddress, validatorAddress); -} - -runStakingDemo(); +console.log('TX sent:', tx.hash); +const receipt = await tx.wait(); +console.log('Confirmed in block:', receipt.blockNumber); ``` -## Additional Tips - -- **Error Handling:** - - - If the Ledger **times out**, increase the HID timeouts or ensure the device stays awake. - - If you see "blind signing required" errors, double-check the app settings on the device itself. +This signer works with any contract interaction — you can pass it to `ethers.Contract` constructors to sign [precompile](/evm/precompiles) calls, ERC-20 transfers, or any other EVM transaction. -- **Reading Events & Logs:** - You can attach an `on("receipt", …)` or use `provider.getTransactionReceipt(tx.hash)` to inspect events emitted by - the precompile for richer UX. +## Troubleshooting -- **Security Reminder:** - Always verify the **contract address** and **ABI** match official Sei docs. Using a wrong address can lead to lost - funds. +- **Timeouts:** If the Ledger times out, increase the HID timeouts or ensure the device stays awake during signing. +- **"Blind signing required" errors:** Double-check that blind signing is enabled in the app settings on the device itself. +- **Connection failures:** Make sure no other application (e.g. Ledger Live) is holding the USB connection to your device. diff --git a/content/evm/sei-js/_meta.js b/content/evm/sei-js/_meta.js index ba03498a..6f4e1809 100644 --- a/content/evm/sei-js/_meta.js +++ b/content/evm/sei-js/_meta.js @@ -1,4 +1,5 @@ export default { index: 'Introduction', - 'create-sei': 'Scaffold Sei' + 'create-sei': 'Scaffold Sei', + ledger: '@sei-js/ledger' }; diff --git a/content/evm/sei-js/index.mdx b/content/evm/sei-js/index.mdx index 9eef803f..867bd044 100644 --- a/content/evm/sei-js/index.mdx +++ b/content/evm/sei-js/index.mdx @@ -46,9 +46,9 @@ Connect to any Sei-compatible wallet using the EIP-6963 standard. Provides a cro npm install @sei-js/sei-global-wallet ``` -### [@sei-js/ledger](/evm/ledger-ethers) +### [@sei-js/ledger](/evm/sei-js/ledger) -Secure transaction signing with Ledger hardware wallets. Provides TypeScript helper functions for the SEI Ledger app. +Secure transaction signing with Ledger hardware wallets. Provides TypeScript helper functions for address derivation and offline Amino signing via the SEI Ledger app. ```bash npm install @sei-js/ledger diff --git a/content/evm/sei-js/ledger.mdx b/content/evm/sei-js/ledger.mdx new file mode 100644 index 00000000..ed588b2e --- /dev/null +++ b/content/evm/sei-js/ledger.mdx @@ -0,0 +1,144 @@ +--- +title: '@sei-js/ledger' +description: 'TypeScript library for SEI Ledger app helper functions — address derivation, Amino signing, and CosmJS integration' +keywords: ['sei-js', 'ledger', 'hardware wallet', 'cosmos', 'amino', 'cosmjs', 'offline signer'] +--- + +import { Callout } from 'nextra/components'; + +# @sei-js/ledger + +The `@sei-js/ledger` package provides TypeScript helper functions for the SEI Ledger hardware wallet app. It enables address derivation and offline Amino signing for Cosmos-side transactions on Sei. + +For EVM-side transaction signing with Ethers.js, see the [Ledger Setup (EVM)](/evm/ledger-ethers) guide instead. + +## Installation + +```bash copy +npm install @sei-js/ledger +``` + +## Hardware Requirements + +- Ledger Nano S Plus, Nano X, or compatible device +- **SEI app** installed on the Ledger device (via Ledger Live Manager) +- USB or Bluetooth connection to your computer + +## Core Functions + +### createTransportAndApp + +Creates a transport connection and app instance for communicating with the Ledger device. + +```typescript copy +import { createTransportAndApp } from '@sei-js/ledger'; + +const { transport, app } = await createTransportAndApp(); +``` + +**Returns:** `Promise<{ transport: Transport, app: SeiApp }>` + +### getAddresses + +Retrieves both EVM and Cosmos addresses from the Ledger device for a given derivation path. + +```typescript copy +import { createTransportAndApp, getAddresses } from '@sei-js/ledger'; + +const { app } = await createTransportAndApp(); +const { evmAddress, nativeAddress } = await getAddresses(app, "m/44'/60'/0'/0/0"); + +console.log('EVM address:', evmAddress); +console.log('Sei address:', nativeAddress); +``` + +**Parameters:** +| Parameter | Type | Description | +|-----------|------|-------------| +| `app` | `SeiApp` | Ledger Sei app instance | +| `path` | `string` | HD derivation path (e.g. `"m/44'/60'/0'/0/0"`) | + +**Returns:** `Promise<{ evmAddress: string, nativeAddress: string }>` + +### SeiLedgerOfflineAminoSigner + +A signer class compatible with CosmJS that enables offline Amino signing via Ledger. + +```typescript copy +import { SeiLedgerOfflineAminoSigner } from '@sei-js/ledger'; + +const ledgerSigner = new SeiLedgerOfflineAminoSigner(app, "m/44'/60'/0'/0/0"); +``` + +**Constructor Parameters:** +| Parameter | Type | Description | +|-----------|------|-------------| +| `app` | `SeiApp` | Ledger Sei app instance | +| `path` | `string` | HD derivation path | + +#### getAccounts + +Retrieves account information from the Ledger device. + +```typescript copy +const accounts = await ledgerSigner.getAccounts(); +// [{ address: 'sei1...', pubkey: { type: 'tendermint/PubKeySecp256k1', value: '...' } }] +``` + +#### signAmino + +Signs a transaction document using the Ledger device. The device will prompt for physical confirmation. + +```typescript copy +import { StdSignDoc } from '@cosmjs/amino'; + +const signDoc: StdSignDoc = { + /* your transaction document */ +}; +const { signed, signature } = await ledgerSigner.signAmino('sei1...', signDoc); +``` + +## Complete Example: Delegating Tokens + +```typescript copy +import { coins, SigningStargateClient, StdFee } from '@cosmjs/stargate'; +import { createTransportAndApp, getAddresses, SeiLedgerOfflineAminoSigner } from '@sei-js/ledger'; + +async function delegateWithLedger() { + const rpcUrl = 'https://rpc-testnet.sei-apis.com/'; + const path = "m/44'/60'/0'/0/0"; + + const { app } = await createTransportAndApp(); + const { nativeAddress } = await getAddresses(app, path); + const ledgerSigner = new SeiLedgerOfflineAminoSigner(app, path); + + const client = await SigningStargateClient.connectWithSigner(rpcUrl, ledgerSigner); + + const msgDelegate = { + typeUrl: '/cosmos.staking.v1beta1.MsgDelegate', + value: { + delegatorAddress: nativeAddress.address, + validatorAddress: 'seivaloper1...', + amount: coins(500, 'usei') + } + }; + + const fee: StdFee = { + amount: [{ denom: 'usei', amount: '20000' }], + gas: '200000' + }; + + const result = await client.signAndBroadcast(nativeAddress.address, [msgDelegate], fee, 'Delegation via Ledger'); + + console.log('Broadcast result:', result); +} + +delegateWithLedger(); +``` + +## Security + +- Ensure your Ledger device is genuine and purchased from official sources +- Always verify transaction details on the Ledger screen before confirming +- Keep your Ledger firmware and the SEI app updated +- Store your recovery phrase securely and never share it