Verona 백서

Verona

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 54쪽 중 19쪽

ny, ); const signer = await abstraxionAuth.getSigner( abstraxionBackend.gasPriceDefault, ); // Convert amount to micro units const amountNum = parseFloat(amount); const microAmount = Math.floor(amountNum * 1_000_000).toString(); const denomMicro = denom === "VER" || denom === "XION" ? "uxion" : "uusdc"; // Create the bank send message const msgSend: MsgSend = { fromAddress: status.metaAccountAddress, toAddress: to, amount: [ { denom: denomMicro, amount: microAmount, }, ], }; // Sign and broadcast the transaction const result = await signer.signAndBroadcast( status.metaAccountAddress, [ { typeUrl: "/cosmos.bank.v1beta1.MsgSend", value: msgSend, }, ], "auto", ); return { transactionHash: result.transactionHash, fromAddress: status.metaAccountAddress, toAddress: to, amount: amount, denom: denom, gasUsed: result.gasUsed?.toString(), gasWanted: result.gasWanted?.toString(), }; } catch (error) { console.error("Error sending transaction:", error); throw new Error( error instanceof Error ? error.message : "Failed to send transaction", ); } }, { schema: sendTransactionSchema, schemaType: "body", rateLimit: "normal", allowedMethods: ["POST"], }, ); ``` > Note: For this example, we are using the `MsgSend` message to send $VERONA tokens. So please make sure in your treasury permission, you have granted the `Send Token` permission. Learn more about how to grant permissions. ## Testing Your API ### Basic API Testing You can test your API endpoints using curl or any HTTP client: ```bash # Test wallet connection curl -X POST http://localhost:3000/api/wallet/connect \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{ "permissions": { "contracts": ["contract1"], "bank": [{"denom": "uxion", "amount": "1000"}] } }' # Test wallet status curl -X GET http://localhost:3000/api/wallet/status \ -H "Authorization: Bearer <token>" # Test transaction curl -X POST http://localhost:3000/api/wallet/transaction/send \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{ "to": "xion1...", "amount": "100", "denom": "uxion" }' ``` ## Deployment ### Production Environment Variables Create production environment variables: ```env # Production Database DATABASE_URL="postgresql://user:password@host:port/database" # Configuration XION_NETWORK="mainnet" XION_REDIRECT_URL="https://yourdomain.com/api/callback/grant_session" XION_TREASURY="xion1..." # Security NEXTAUTH_SECRET="your-production-secret" ENCRYPTION_KEY="your-production-encryption-key" # Session Configuration SESSION_KEY_EXPIRY_MS=864000000 REFRESH_THRESHOLD_MS=3600000 ``` ### Build and Deploy ```bash # Build the application pnpm build # Start production server pnpm start ``` ### API Documentation #### Endpoints Summary | Method | Endpoint | Description | Authentication | | -------- | ------------------------------ | -------------------------- | -------------- | | `POST` | `/api/wallet/connect` | Initiate wallet connection | Required | | `GET` | `/api/wallet/status` | Check wallet status | Required | | `DELETE` | `/api/wallet/disconnect` | Disconnect wallet | Required | | `POST` | `/api/wallet/transaction/send` | Send transaction | Required | | `GET` | `/api/callback/grant_session` | OAuth callback handler | None | #### Response Format All API responses follow this format: ```json { "success": boolean, "data": object | null, "error": string | null } ``` ### Security Considerations #### Encryption * All sensitive data (private keys) is encrypted using AES-256-CBC * Encryption keys are generated securely and stored in environment variables * Each encryption operation uses a unique IV for security #### Session Management * Automatic key rotation before expiry * Configurable refresh threshold * Background monitoring service for expired sessions ### Troubleshooting #### Common Issues 1. **Database Connection Errors** * Ensure `DATABASE_URL` is correctly set * Check database server is running * Verify database permissions 2. **Encryption Key Issues** * Ensure `ENCRYPTION_KEY` is base64 encoded * Key must be exactly 32 bytes (256 bits) * Use the provided script to generate keys 3. **Verona network Issues** * Verify `XION_NETWORK` is correct * Check network connectivity * Ensure treasury address is valid 4. **Session Key Problems** * Check `SESSION_KEY_EXPIRY_MS` configuration * Verify `REFRESH_THRESHOLD_MS` settings ### Next Steps Now that you have a fully functional RESTful API with account abstraction and backend session management, you can: 1. **Extend the API** with additional endpoints for specific use cases 2. **Add a frontend** to interact with your API 3. **Implement additional security features** like 2FA or biometric authentication 4. **Scale the application** with load balancers and multiple instances This implementation provides a solid foundation for building Web3 applications with Web2 user experience, leveraging Verona's account abstraction capabilities while maintaining security and scalability. For more detailed implementation examples, comprehensive error handling, advanced features, and complete source code, please refer to the [backend-session demo repository](https://github.com/burnt-labs/xion.js/tree/main/apps/backend-session). # Tools & SDKs Libraries and CLIs for building on Verona—whether you ship a web or mobile app, automate from the terminal, or integrate native signing in Python, Kotlin, Swift, or Rust. ## Code agents For AI coding agents, install **skills** from [verona-dev-plugin](https://github.com/burnt-labs/verona-dev-plugin) per [INSTALL.md](https://github.com/burnt-labs/verona-dev-plugin/blob/main/INSTALL.md)—not from the toolkit repo. The plugin routes app SDK work vs CLI automation; stack decision rules live in plugin `references/`. See the [stack selection table](/en/build-on-verona/overview#stack-selection) on the developers overview. <table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Verona Dev Plugin — agent skills</strong></td><td>Install once per host (Cursor, Codex, Claude Code, Kimi). Shared <code>skills/</code> tree for Meta Accounts, treasury, OAuth2, app SDK guides, and toolkit CLI workflows.</td><td><a href="/en/about-verona/ai-agents">For AI Agents</a></td></tr><tr><td><strong>Verona Agent Toolkit — CLI</strong></td><td><code>verona-toolkit</code> binary for Treasury, OAuth2 clients, and gasless automation from the terminal. Pair with the Dev Plugin for agent-driven CLI ops—not a skills install path. <strong>Beta</strong>.</td><td><a href="/en/build-on-verona/tools/verona-toolkit">Verona Agent Toolkit (CLI)</a></td></tr></tbody></table> ## xion.js [**xion.js**](https://github.com/burnt-labs/xion.js) is Verona’s JavaScript monorepo for Meta Accounts, gasless transactions, and Abstraxion. It powers React web apps and React Native mobile apps with shared packages (`@burnt-labs/abstraxion-react`, `@burnt-labs/abstraxion-js`, `@burnt-labs/abstraxion-react-native`) and reference demos in [`demos/react`](https://github.com/burnt-labs/xion.js/tree/main/demos/react). If you are building in JavaScript or TypeScript, start here—then follow the platform guides below for end-to-end integration. For React web auth modes, try the [live demos](https://sdk-react.demos.burnt.com/) (`/auto`, `/embedded`, `/signer-mode`, `/saas`) or the [Web App hub](/en/build-on-verona/accounts/web-app#live-demos). <table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Web App Development</strong></td><td>React + Abstraxion: Meta Accounts, Treasury gasless flows, auth modes (<code>auto</code>, <code>signer</code>, <code>embedded</code>), and tutorials backed by <code>xion.js</code>.</td><td><a href="/en/build-on-verona/accounts/web-app">Web App Development</a></td></tr><tr><td><strong>Mobile App Development</strong></td><td>React Native + Expo with Abstraxion: environment setup, Meta Account auth, gasless UX, and common mobile fixes.</td><td><a href="/en/build-on-verona/accounts/mobile-app">Mobile App Development</a></td></tr></tbody></table> ## Mob **Mob** is a multi-platform signing client for Verona—Rust at the core, with native bindings via [UniFFI](https://github.com/mozilla/uniffi-rs) for Kotlin, Swift, Python, Ruby, and more. Use it when you are not in JavaScript: native iOS/Android, backend services, scripts, or automation. It supports session keys, treasury-paid gas, and meta-accounts—the native counterpart to xion.js. <table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Mob: multi-platform signing library</strong></td><td>Sign and send, query chain state, gasless transfers, authz session keys, and meta-account authenticators—same API surface across supported languages.</td><td><a href="/en/build-on-verona/tools/mob-signing-client">Mob: multi-platform signing client</a></td></tr></tbody></table> ## CLI tools For direct chain interaction, scripting, and validator workflows, use the command-line tools below. They complement the SDKs above rather than replacing app integration paths. For agent skills, use the [Dev Plugin](#code-agents) section—not toolkit install docs. <table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Verona Agent Toolkit (<code>verona-toolkit</code>)</strong></td><td>CLI for gasless development with Meta Accounts, Treasury management, and OAuth2 client management. <strong>Beta</strong>—testnet (default) and mainnet (<code>--network mainnet</code>); faucet is testnet-only.</td><td><a href="/en/build-on-verona/tools/verona-toolkit">Verona Agent Toolkit (CLI)</a></td></tr><tr><td><strong>Daemon CLI (<code>xiond</code>)</strong></td><td>Traditional chain CLI for querying and transacting directly with Verona endpoints.</td><td><a href="/en/build-on-verona/tools/daemon-cli">Interacting with the chain using the daemon CLI</a></td></tr></tbody></table> # Mob: multi-platform signing client Multi-platform signing client library for Verona (Rust + UniFFI) **Mob** is a multi-platform signing client for the Verona network with first-class session-key support. It's written in Rust and exposed through Mozilla's [UniFFI](https://github.com/mozilla/uniffi-rs) and has native libraries for **Kotlin, Swift, Python, Ruby, and any other UniFFI target,** plus the Rust crate itself for server and CLI use. Mobile, backend, scripts, desktop, automation: same SDK, same surface, same code paths. It's the native equivalent of [xion.js](https://github.com/burnt-labs/xion.js) which is our JavaScript signing client without being tied to JavaScript or a web view. ### Why we built it For most of Verona's history, building against the chain meant utilizing [xion.js](https://github.com/burnt-labs/xion.js). That's fine if you're shipping a web app or a React Native app. It's a problem if you're not. * A **Python data team** wanting to script a treasury or batch payouts had to either shell out to `xiond` or hand-roll protobuf signing. * A **Ruby backend** doing payment reconciliation against on-chain state had no SDK at all. * A **Go or Rust service** had to import `cosmrs` and re-implement Verona's account-abstraction wrappers from scratch. * A **native Android or iOS team** had to drag in React Native + a JavaScript bundle + a web-view OAuth dance to get session keys and gasless UX. Every team was solving the same problem, sign a Verona transaction, talk to an RPC, optionally wrap the call in `MsgExec` for authz, in their own way, in their own language, with their own bugs. **Mob** is one implementation of that problem, in Rust, with idiomatic bindings to whatever language you're already writing. ### What can you do with it * **Sign and send.** BIP39 mnemonics → BIP44 derivation → secp256k1 → Bech32 addresses. Three lines from mnemonic to a broadcast transaction, in any supported language. * **Query.** Block height, account info, balances, transactions by hash. CosmWasm smart queries against any contract via the LCD endpoint. * **Send tokens gaslessly.** Pass a `feeGranter` and gas is paid by a treasury contract — the user (or the script, or the service) pays nothing. * **Run authz session keys.** Pass a `granter` and your write call gets wrapped in a `MsgExec`, signed by the session key but executed against another account. This is the native equivalent of an abstraxion session, and it works the same whether you're a mobile app, a backend service signing on behalf of customers, or a CLI tool. * **Use meta-accounts.** Full `AbstractAccount` support with `Secp256k1`, `WebAuthn`, `JWT`, and `MultiSig` authenticators. * **Catch typed errors.** A single `MobError` enum with 13 variants covers everything from `InsufficientFunds` to `KeyDerivation` — no string-matching against RPC blobs. The same `send()` call across four languages, same parameter names, same return type: **Rust** ```rust let tx = client.send( recipient, vec![Coin::new("uxion", "1000000")], Some("gasless transfer".into()), ).await?; ``` **Kotlin** ```kotlin val tx = client.send( toAddress = recipient, amount = listOf(Coin(denom = "uxion", amount = "1000000")), granter = state.metaAccountAddress, feeGranter = state.treasuryAddress, memo = "gasless transfer" ) ``` **Swift** ```swift let tx = try client.send( toAddress: recipient, amount: [Coin(denom: "uxion", amount: "1000000")], granter: state.metaAccountAddress, feeGranter: state.treasuryAddress, memo: "gasless transfer" ) ``` **Python** ```python tx = client.send( to_address=recipient, amount=[Coin(denom="uxion", amount="1000000")], granter=state.meta_account_address, fee_granter=state.treasury_address, memo="gasless transfer", ) ``` That's the whole authz / fee-granting story. Set `granter` and `feeGranter` to non-nil and you're routing through a meta-account with treasury-paid gas. Set them to null and you're a standalone wallet. Same client, same code, both modes. ### Demo project [**xion-brale-demo**](https://github.com/burnt-labs/xion-brale-demo) is Brale's reference stablecoin wallet, shipping mob in both apps: * **iOS** — SwiftUI, Keychain-backed mnemonic storage, native `ASWebAuthenticationSession` for the abstraxion OAuth handshake, FFI calls dispatched on a serial queue so the main thread never blocks. * **Android** — Jetpack Compose, `EncryptedSharedPreferences` for the mnemonic, Custom Tabs for OAuth, the same FFI surface running through JNA. The full flow works end-to-end today: a user signs in with abstraxion, the app verifies the on-chain grant, and from then on every transfer is signed by a session key, executed against the user's meta-account, and gassed by a treasury contract. Same flow on both platforms, same SDK on both platforms. The mobile case is the most visible, but it's the same library a Python script uses to disburse a payroll, a Ruby backend uses to reconcile on-chain state, or a Rust service uses to sign treasury operations. ### When to use mob | You're building… | Use | | ------------------------------------ | ------------------------------------------------ | | A web app | `xion.js` / `abstraxion` | | A React Native app | `xion.js` /`@burnt-labs/abstraxion-react-native` | | A native iOS or Android app | **mob** (Swift / Kotlin) | | A Python script, ETL job, or backend | **mob** (Python bindings) | | A Ruby service | **mob** (Ruby bindings) | | A Rust service, CLI, or daemon | **mob** (Rust crate, no FFI) | | Anything else with a UniFFI target | **mob** (generate bindings yourself) | If you're already in JavaScript-land, `xion.js` is still the right choice. Everywhere else, mob is the SDK we wish we'd had. # Verona Agent Toolkit (CLI) Quick start and user guide for Verona Agent Toolkit Verona Agent Toolkit (CLI package `verona-toolkit`) is a CLI-first toolkit for building on the Verona network with Meta Accounts and gasless workflows. This guide is for developers who are new to Verona but already comfortable with CLI tools and AI coding agents. {% hint style="warning" %} **Beta:** Verona Agent Toolkit is in **beta**. It supports **testnet** (default) and **mainnet**. Use testnet for development and the faucet; switch to mainnet when you are ready for production (see [Networks](#networks) below). {% endhint %} {% hint style="info" %} This page focuses on practical onboarding and high-signal workflows. For complete command coverage, use the official repository references linked throughout this guide. {% endhint %} ## Why use this toolkit Verona Agent Toolkit is useful when you want to: * Automate **Treasury management** from terminal or scripts * Manage **OAuth2 clients** for your app lifecycle * Pair with AI coding agents via [verona-dev-plugin](https://github.com/burnt-labs/verona-dev-plugin) ([INSTALL.md](https://github.com/burnt-labs/verona-dev-plugin/blob/main/INSTALL.md)) * Build gasless flows without handling private keys directly If you need conceptual background first, see: * [Generalized Abstraction](/en/about-verona/generalized-abstraction) * [Enabling Gasless Transactions with Treasury](/en/build-on-verona/accounts/getting-started/treasury-contracts) ## Installation ### Install CLI **macOS / Linux** ```bash curl --proto '=https' --tlsv1.2 -LsSf \ https://github.com/burnt-labs/verona-agent-toolkit/releases/latest/download/verona-agent-toolkit-installer.sh | sh ``` **Windows (PowerShell)** ```powershell powershell -c "irm https://github.com/burnt-labs/verona-agent-toolkit/releases/latest/download/verona-agent-toolkit-installer.ps1 | iex" ``` ### AI agents and skills Agent skills for Verona—including toolkit CLI workflows—ship in [**verona-dev-plugin**](https://github.com/burnt-labs/verona-dev-plugin). Install the plugin per [INSTALL.md](https://github.com/burnt-labs/verona-dev-plugin/blob/main/INSTALL.md); host-specific steps live there only. {% hint style="info" %} **Migration:** Skills that were previously installed from `verona-agent-toolkit` (for example via `npx skills add`) now live in the Dev Plugin. Use [INSTALL.md](https://github.com/burnt-labs/verona-dev-plugin/blob/main/INSTALL.md) instead of legacy `INSTALL-FOR-AGENTS.md` from the toolkit repo. {% endhint %} After the plugin is installed, authenticate the CLI: ```bash verona-toolkit auth login ``` For the full agent onboarding path, see [For AI Agents](/en/about-verona/ai-agents). ### Verify install ```bash verona-toolkit --version verona-toolkit --help ``` For full CLI installation detail: * [README](https://github.com/burnt-labs/verona-agent-toolkit/blob/main/README.md) ## Networks Verona Agent Toolkit targets **testnet** by default and also supports **mainnet**. Pick the network that matches your Treasury and OAuth2 setup. | Network | CLI flag / config | Notes | | ----------- | ------------------------------------------------------------------------------- | --------------------------------------------------------- | | **Testnet** | Default, or `--network testnet`, or `verona-toolkit config set-network testnet` | Use for development; faucet and test tokens are available | | **Mainnet** | `--network mainnet`, or `verona-toolkit config set-network mainnet` | Production Meta Accounts, Treasuries, and OAuth2 clients | Examples: ```bash # One-off mainnet command verona-toolkit --network mainnet status # Persist default network verona-toolkit config set-network mainnet ``` For full CLI flags and configuration, see the [Verona Agent Toolkit repository](https://github.com/burnt-labs/verona-agent-toolkit) and [Configuration](https://github
프로젝트로 돌아가기