Starknet 백서

Starknet

원문

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

ng pool, unsupported pair, or invalid amount). Verify the market exists for the current chain and that you are passing the correct tokens and pool. ### Provider does not support chain [Vesu](https://vesu.xyz/lite/markets) supports `SN_MAIN` and `SN_SEPOLIA`. Ensure the wallet is on one of these chains. If you use a custom provider, ensure it supports the wallet's chain. ### "No default lending provider configured" The default is set when the wallet is created (Vesu). If you replaced it, call `setDefaultProvider("vesu")` or pass `provider: "vesu"` in each request. ## Next steps * [Bitcoin, Stablecoins, and Tokens](/build/starkzap/erc20) — Token presets and amounts * [Transactions](/build/starkzap/transactions) — Execution options and fee modes * [Tx Builder](/build/starkzap/tx-builder) — Batching operations * [API Reference](/build/starkzap/api-reference) — Full method signatures # LST Staking Source: https://docs.starknet.io/build/starkzap/lst-staking Use Endur liquid staking through Starkzap with a staking-like API and asset-based vaults ## Overview Starkzap supports Endur liquid staking (LST) through `wallet.lstStaking(asset)`. LST staking is different from native delegation pools: * You stake into an asset vault (for example `STRK`, `WBTC`) instead of a validator pool. * Yield is reflected in LST share value over time. * There is no separate claim transaction for rewards. * Exits redeem shares; there is no native two-step cooldown flow. <Info> Looking for native delegation pools with `enterPool`, `addToPool`, and reward claims? See [Staking & Delegation](/build/starkzap/staking). </Info> ## Quick Start ```typescript theme={null} import { StarkZap, StarkSigner } from "starkzap"; const sdk = new StarkZap({ network: "mainnet" }); const wallet = await sdk.connectWallet({ account: { signer: new StarkSigner(privateKey) }, }); const lst = wallet.lstStaking("STRK"); ``` ## Supported Assets Supported assets come from chain-aware presets. * **Mainnet:** `STRK`, `WBTC`, `tBTC`, `LBTC`, `solvBTC` * **Sepolia:** `STRK`, `TBTC1`, `TBTC2` Use `wallet.lstStaking(asset)` with one of the supported asset symbols on the connected chain. ## Core Actions ### Enter LST Position `enter`, `stake`, and `add` all perform the same LST deposit operation. ```typescript theme={null} import { Amount } from "starkzap"; const tx = await lst.enter(wallet, Amount.parse("100", 18)); await tx.wait(); ``` ### Enter with Referral ```typescript theme={null} const tx = await lst.enterWithReferral( wallet, Amount.parse("100", 18), "ABC123" ); await tx.wait(); ``` ### Enter to Validator ```typescript theme={null} const tx = await lst.enterToValidator( wallet, Amount.parse("100", 18), "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" ); await tx.wait(); ``` ### Exit LST Position Redeem a specific amount with `exitIntent`: ```typescript theme={null} const tx = await lst.exitIntent(wallet, Amount.parse("25", 18)); await tx.wait(); ``` Redeem full share balance with `exit`: ```typescript theme={null} const tx = await lst.exit(wallet); await tx.wait(); ``` ## Read Operations ### Position ```typescript theme={null} const position = await lst.getPosition(wallet); if (position) { console.log(`Shares: ${position.staked.toFormatted()}`); console.log(`Total: ${position.total.toFormatted()}`); } ``` ### APY and TVL ```typescript theme={null} const apy = await lst.getAPY(); const tvl = await lst.getTVL(); console.log(apy); console.log(tvl); ``` ### Commission and Rewards ```typescript theme={null} const commission = await lst.getCommission(); // 0 console.log(commission); ``` `claimRewards` is not applicable for LST staking because yield is embedded in share price. ## Configuration You can pass fetch options when creating the LST client: ```typescript theme={null} const lst = wallet.lstStaking("STRK", { timeoutMs: 15000, }); ``` Use this when you need custom HTTP timeout behavior for APY/TVL reads. ## Best Practices 1. Always use the correct `Amount` decimals for the selected asset. 2. Treat LST and native delegation as separate UX flows in your app. 3. Show users that yield is reflected in share value rather than claimed rewards. 4. Validate supported assets per connected chain before rendering actions. ## Next Steps * Learn about [Staking & Delegation](/build/starkzap/staking) for native pool staking * Explore [Transaction Builder](/build/starkzap/transactions#transaction-builder) for batching operations * Check the [API Reference](/build/starkzap/api-reference) for detailed method signatures # Overview Source: https://docs.starknet.io/build/starkzap/overview TypeScript SDK for building consumer applications with Starknet wallet integration, token operations, and DeFi features <img alt="Starkzap SDK overview hero" /> ## Introduction **Starkzap** enables any application to bring Bitcoin, stablecoins, and DeFi to their users. Built on Starknet's native account abstraction, it provides the tools to integrate wallets, swap, stake token, borrow/lend, make private transfers, and execute transactions—without requiring users to manage seed phrases or understand blockchain complexity. **Quick Start:** Get your first wallet integration working in under 5 minutes with our [Quick Start Guide](/build/starkzap/quick-start) ## Key Features <CardGroup> <Card title="Quick Start" icon="rocket" href="/build/starkzap/quick-start"> Complete SDK with web, mobile, and server support, production-ready codebase, and minimal configuration </Card> <Card title="Modular Architecture" icon="building" href="/build/starkzap/configuration"> Independent modules that allow you to use only what you need while maintaining clean code separation </Card> <Card title="Protocol Integrations" icon="link" href="/build/starkzap/integrations/avnu-paymaster"> Ready-to-use integrations with major Starknet services including AVNU Paymaster, Privy, AVNU, EKUBO, Vesu, Tongo Cash and Cartridge Controller </Card> <Card title="Cross-Platform" icon="mobile" href="/build/starkzap/examples"> Works seamlessly in Node.js, browsers, and React Native with the same API </Card> <Card title="Web2-Friendly Auth" icon="lock" href="/build/starkzap/connecting-wallets"> Social login, email authentication, and biometrics—no seed phrases required </Card> <Card title="Seamless UX" icon="gift" href="/build/starkzap/paymasters"> Paymaster and Cartridge policy-based sponsorship where configured, plus staking, swapping, and borrowing for smooth user experiences </Card> </CardGroup> ## Protocol Integrations The SDK includes ready-to-use integrations with major Starknet services: **Wallet Solutions & Gas Management** * **Privy** - Like OAuth for wallets: users sign in with email or social accounts, and Privy securely manages their wallet keys on their servers (no seed phrases needed) * **Cartridge** - For games: social / passkey login on **web** (Controller) or **React Native** (native session with `starkzap-native`). Cartridge can sponsor **policy-matching** calls via its paymaster/session stack; other calls may still cost the user * **Argent Account** - Pre-built wallet template you can use (like using a UI component library) * **Braavos Account** - Another pre-built wallet template option * **AVNU Paymaster** - Service that pays transaction fees for your users (like offering free shipping—you cover the costs so users don't have to) **DeFi & Financial Services** * **Native Staking** - Let users earn passive income by staking tokens (like earning interest on a savings account) * **Token Operations** - Send and receive tokens, check balances (like handling payments and account balances) * **Swaps** - Let users exchange one token for another via AVNU (aggregator) or Ekubo (concentrated liquidity) * **Lending** - Enable users to supply, borrow, and repay with Vesu * **Troves** - Access Troves strategies, inspect positions, and route deposits or withdrawals through the wallet * **Privacy** - Two independent protocols: the STRK20 privacy pool hides amounts, sender, and recipient; Tongo Cash hides amounts * **Cross-chain Bridge** - Bridge assets from Ethereum or Solana into Starknet ## Who Is This For? <CardGroup> <Card title="Web2 Developers" icon="code"> Jump into blockchain development without learning everything from scratch. Leverage familiar patterns (REST APIs, OAuth) and focus on user experience. </Card> <Card title="Blockchain Developers" icon="link"> Extend your reach to consumer applications using pre-built integrations without learning mobile/web frameworks from scratch. </Card> <Card title="Entrepreneurs & Startups" icon="rocket"> Rapidly prototype and launch blockchain-based applications, reducing development time from months to weeks. </Card> </CardGroup> ## What Can You Build? <Tabs> <Tab title="DeFi Trading Apps"> Build applications where users can swap tokens, stake assets, and earn rewards—all with a simple API. **Examples:** * [**EKUBO**](https://ekubo.org) - Concentrated liquidity AMM * [**AVNU**](https://avnu.fi) - DEX aggregator and paymaster * [**VESU**](https://vesu.io) - DeFi protocol suite **Key Features:** * Token swapping and DEX integration * Staking and earning passive income * Portfolio management and analytics [Learn more about Staking](/build/starkzap/staking) </Tab> <Tab title="Payment & Fintech Apps"> Enable users to send and receive cryptocurrency, accept payments, and manage digital assets like Bitcoin and stablecoins. **Examples:** * [**Ready Wallet**](https://ready.gg) - Consumer payment and wallet solution **Key Features:** * Send/receive Bitcoin, stablecoins, and tokens * Payment processing and invoicing * Multi-currency wallet management [Learn more about Tokens](/build/starkzap/erc20) </Tab> <Tab title="On-Chain Gaming"> Create games with real digital assets, NFTs, and blockchain-based economies where players truly own their items. **Examples:** * [**LootSurvivor2**](https://lootsurvivor.io) - On-chain survival game * [**Ponziland**](https://ponziland.io) - Blockchain gaming platform **Key Features:** * In-game asset ownership * NFT integration * Play-to-earn mechanics * Gasless transactions for seamless gameplay [See Examples](/build/starkzap/examples) </Tab> <Tab title="Wallet Applications"> Build consumer-friendly wallets with social login, biometrics, and gasless transactions. **Examples:** * [**Ready**](https://ready.gg) - Consumer wallet * [**Cartridge**](https://cartridge.gg) - Gaming-focused wallet * [**Braavos**](https://braavos.app) - Multi-chain wallet * [**Privy**](https://privy.io) - Embedded wallet infrastructure **Key Features:** * Social login (Google, Twitter, email) * Biometric authentication (Face ID, Touch ID) * Multi-chain support * Gasless transaction experience [Learn about Wallets](/build/starkzap/connecting-wallets) </Tab> </Tabs> *** ## Architecture Overview The SDK consists of modular components that work together seamlessly: ``` Starkzap | +-- Core SDK | +-- StarkZap | | `-- Network & configuration orchestration | `-- WalletInterface | `-- Unified wallet abstraction | +-- Signer Backends | +-- StarkSigner | | `-- Local private key signing | +-- PrivySigner | | `-- Server-side key management | `-- Cartridge | `-- Social login & passkey authentication | `-- Feature Modules +-- Token Operations | `-- ERC20 transfers, balances, approvals +-- Staking & Delegation | `-- Pool management, rewards, exits +-- Bridge | `-- Deposit, quotes +-- Swap & DCA | `-- Swapping, quotes, dca +-- Borrowing & Lending | `-- Borrow, lend, withdraw +-- Troves | `-- Strategies, positions, deposits and withdrawals +-- Privacy — STRK20 pool | `-- Shielded deposit, transfer, withdraw; relayer submission +-- Privacy — Tongo | `-- Fund, transfer, withdraw against an encrypted balance +-- Transaction Builder | `-- Batching, preflight, fee estimation `-- Type-Safe Primitives `-- Address, Amount, ChainId ``` **Core Components:** * **StarkZap** - Main orchestration layer for network and configuration management * **WalletInterface** - Unified wallet abstraction with interchangeable backends * **Signer Backends** - StarkSigner, PrivySigner, Cartridge - flexible authentication * **Feature Modules** - Token ops, staking, bridging, swap and DCA, lending, Troves, transactions, type-safe primitives * **Privacy** - Two independent protocols with no shared interface: the [STRK20 pool](/build/starkzap/privacy/strk20) spends notes and proves remotely, [Tongo](/build/starkzap/privacy/tongo) keeps an encrypted balance and proves locally ## What's Next? Ready to start building? Here's your roadmap: **Setup Guide** * [Installation](/build/starkzap/installation) - Install the SDK and dependencies * [Quick Start](/build/starkzap/quick-start) - Get your first wallet integration working in minutes **Core Concepts** * [Configuration](/build/starkzap/configuration) - Configure networks, RPC providers, and integrations * [Paymasters](/build/starkzap/paymasters) - Set up gasless transactions (AVNU or Cartridge) * [Connecting Wallets](/build/starkzap/connecting-wallets) - Connect wallets with social login, biometrics, or email * [Transactions](/build/starkzap/transactions) - Send transactions, batch operations, and handle fees **Features** * [Bitcoin, Stablecoins, and Tokens](/build/starkzap/erc20) - Send and receive tokens, check balances * [Staking & DeFi](/build/starkzap/staking) - Enable staking and earning rewards * [Bridging](/build/starkzap/bridging) - Bridge assets from Ethereum and Solana into Starknet * [Swaps](/build/starkzap/swap) - Exchange tokens with AVNU or Ekubo * [DCA](/build/starkzap/dollar-cost-average) - Recurring buys (Dollar-Cost Averaging) with AVNU or Ekubo * [Lending](/build/starkzap/lending) - Supply, borrow, and repay with Vesu * [Troves](/build/starkzap/troves) - Discover strategies and deposit or withdraw through Troves * [Privacy](/build/starkzap/privacy/overview) - Choose between two independent protocols: the [STRK20 privacy pool](/build/starkzap/privacy/strk20) hides amounts, sender, and recipient; [Tongo](/build/starkzap/privacy/tongo) hides amounts * [Integrations](/build/starkzap/integrations/avnu-paymaster) - AVNU Paymaster, Privy, Cartridge **Examples** [Complete Examples](/build/starkzap/examples) - See practical examples for web, mobile, and server applications **Reference** * [Glossary](/build/starkzap/glossary) - Web3 terms explained in web2-friendly language * [API Reference](/build/starkzap/api-reference) - Complete API documentation <Note> New to blockchain? Don't worry! The SDK is designed to be beginner-friendly while remaining powerful for experienced developers. </Note> ## Community & Support Join our growing community: **Telegram Groups:** * **[Starknet Ecosystem Founders](https://t.me/+J6u7yj3DrghiZDA1)** - For founder exposure and ecosystem connections * **[Cairo Core Stars](https://t.me/sncorestars)** - For technical questions and Cairo development * **[Starknet Ecosystem](https://t.me/+9xp-85igaUtlYTY8)** - For ecosystem-wide visibility and discussions **Other Channels:** * **Discord** - [Starknet Community](https://discord.gg/starknet-community) - Get real-time help and connect with other developers * **Forum** - [Starknet Community Forum](https://community.starknet.io/) - Ask questions and share knowledge * **GitHub** - Report issues, contribute, and explore the codebase # Paymasters Source: https://docs.starknet.io/build/starkzap/paymasters Set up gasless transactions using AVNU Paymaster or Cartridge's built-in paymaster ## Overview Paymasters allow you to sponsor (pay for) transaction fees so users don't have to worry about gas costs. Starkzap supports two paymaster options depending on your wallet connection strategy. <Tabs> <Tab title="AVNU Paymaster"> Use AVNU Paymaster for **Privy** and **Private Key** strategies. AVNU provides both gasfree (you sponsor) and gasless (user pays in tokens) modes. ## When to Use AVNU Paymaster * ✅ Using **Privy** strategy for wallet connection * ✅ Using **Private Key** strategy (server-side) * ✅ Want to sponsor all gas fees for users (gasfree mode) * ✅ Want users to pay gas in tokens instead of STRK (gasless mode) <Tabs> <Tab title="You Sponsor (Gasfree)"> In gasfree mode, your dApp covers all gas costs. This is ideal for: * User onboarding flows * Premium UX experiences * Consumer applications ## Setup ### 1. Get an API Key Get an API key from the [AVNU Portal](https://portal.avnu.fi). This is required for gasfree mode. ### 2. Configure the SDK ```typescript theme={null} import { StarkZap } from "starkzap"; const sdk = new StarkZap({ network: "mainnet", paymaster: { nodeUrl: "https://starknet.paymaster.avnu.fi", headers: { "x-paymaster-api-key": "your-api-key-here" }, }, }); ``` ### 3. Use Sponsored Transactions ```typescript theme={null} // Execute with sponsored fees const tx = await wallet.execute([call], { feeMode: { type: "paymaster" }, }); // Or set as default when connecting const wallet = await sdk.connectWallet({ account: { signer }, feeMode: { type: "paymaster" }, }); ``` ## Propulsion Program The [Starknet Foundation Propulsion Program](https://docs.avnu.fi/docs/paymaster/propulsion-program) offers up to \$1M in gas subsidies for qualifying projects. This program helps reduce the cost of sponsoring transactions for your users. ## Server-Side Paymaster Proxy For production applications, you may want to proxy paymaster requests through your backend: ```typescript theme={null} // Backend endpoint app.post("/api/paymaster", async (req, res) => { const response = await fetch("https://starknet.paymaster.avnu.fi", { method: "POST", headers: { "Content-Type": "application/json", ...(AVNU_API_KEY && { "x-paymaster-api-key": AVNU_API_KEY }), }, body: JSON.stringify(req.body), }); const data = await response.json(); res.status(response.status).json(data); }); ``` Then configure the SDK to use your proxy: ```typescript theme={null} const sdk = new StarkZap({ network: "mainnet", paymaster: { nodeUrl: "https://your-api.example/paymaster", }, }); ``` </Tab> <Tab title="Gasless Mode"> In gasless mode, users pay gas fees in supported tokens instead of STRK. No API key required. ## Supported Tokens USDC, USDT, DAI, ETH, STRK, WBTC, solvBTC, LBTC, EKUBO, NSTR, LORDS, wstETH, and more. ## Setup ### 1. Configure the SDK ```typescript theme={null} import { StarkZap } from "starkzap"; const sdk = new StarkZap({ network: "mainnet", paymaster: { nodeUrl: "https://starknet.paymaster.avnu.fi", // No API key needed for gasless mode }, }); ``` ### 2. Use Transactions The SDK automatically handles gasless transactions when a paymaster is configured. Users can pay in any supported token: ```typescript theme={null} import { fromAddress } from "starkzap"; // Let users pay gas in a supported token (for example, USDC) const tx = await wallet.execute([call], { feeMode: { type: "paymaster", gasToken: fromAddress("0x053c91253bc96bfed3be381a97265e250ed0a2e2cbf1a54898ad0d2f7982f78f"), }, }); await tx.wait(); ``` Users will pay gas fees in their preferred token (USDC, USDT, etc.) instead of STRK. </Tab> </Tabs> ## Best Practices 1. **Use gasfree mode** for onboarding and critical user flows 2. **Use gasless mode** to let users pay in their preferred tokens 3. **Proxy paymaster requests** through your backend in production to keep API keys secure 4. **Monitor usage** through the [AVNU Portal](https://portal.avnu.fi) dashboard 5. **Apply for Propulsion Program** if eligible for gas subsidies ## Resources * [AVNU Paymaster Documentation](https://docs.avnu.fi/docs/paymaster/index) * [AVNU Portal](https://portal.avnu.fi) - Get your API key and monitor usage * [Propulsion
프로젝트로 돌아가기