diff --git a/assets/starkzap/bridges.png b/assets/starkzap/bridges.png new file mode 100644 index 0000000000..5342fcd62e Binary files /dev/null and b/assets/starkzap/bridges.png differ diff --git a/assets/starkzap/confidential-transfers.png b/assets/starkzap/confidential-transfers.png new file mode 100644 index 0000000000..763deea529 Binary files /dev/null and b/assets/starkzap/confidential-transfers.png differ diff --git a/assets/starkzap/dca.png b/assets/starkzap/dca.png new file mode 100644 index 0000000000..afc6a2c024 Binary files /dev/null and b/assets/starkzap/dca.png differ diff --git a/assets/starkzap/lending-borrowing.png b/assets/starkzap/lending-borrowing.png new file mode 100644 index 0000000000..bb929ceb61 Binary files /dev/null and b/assets/starkzap/lending-borrowing.png differ diff --git a/assets/starkzap/swapping.png b/assets/starkzap/swapping.png new file mode 100644 index 0000000000..e2f2d7a395 Binary files /dev/null and b/assets/starkzap/swapping.png differ diff --git a/build/starkzap/api-reference.mdx b/build/starkzap/api-reference.mdx index 1311ece057..57e6df6868 100644 --- a/build/starkzap/api-reference.mdx +++ b/build/starkzap/api-reference.mdx @@ -19,10 +19,11 @@ new StarkZap(config: SDKConfig): StarkZap | Method | Returns | Description | | ---------------------------- | -------------------------- | ------------------------------------ | | `connectWallet(options)` | `Promise` | Connect with signer + account preset | -| `connectCartridge(options?)` | `Promise` | Connect via Cartridge Controller | +| `connectCartridge(options?)` | `Promise` | Connect via Cartridge (**web:** Controller popup; **RN:** native session when supported — register adapter first) | | `onboard(options)` | `Promise` | Onboard with strategy selection | | `stakingTokens()` | `Promise` | Get stakeable tokens | | `getStakerPools(staker)` | `Promise` | Get validator's delegation pools | +| `getBridgingTokens(chain?)` | `Promise` | Get bridgeable tokens by source chain | | `getProvider()` | `RpcProvider` | Get the underlying RPC provider | ### Configuration @@ -35,6 +36,7 @@ interface SDKConfig { paymaster?: { nodeUrl: string }; explorer?: ExplorerConfig; staking?: StakingConfig; + bridging?: BridgingConfig; } ``` @@ -76,6 +78,10 @@ The wallet interface provides access to account operations, transactions, and to | `getChainId()` | `ChainId` | Get chain ID | | `getFeeMode()` | `FeeMode` | Get default fee mode | | `disconnect()` | `Promise` | Disconnect wallet | +| `deposit(recipient, amount, token, externalWallet, options?)` | `Promise<{ hash: string }>` | Bridge deposit from external chain | +| `getDepositBalance(token, externalWallet)` | `Promise` | Get source-chain available balance | +| `getAllowance(token, externalWallet)` | `Promise` | Get source-chain allowance (if applicable) | +| `getDepositFeeEstimate(token, externalWallet, options?)` | `Promise` | Estimate bridge route fees | ## Tx @@ -113,6 +119,16 @@ Fluent API for building and executing batched transactions. | `.claimPoolRewards(pool)` | `TxBuilder` | Claim staking rewards | | `.exitPoolIntent(pool, amount)` | `TxBuilder` | Start exit process | | `.exitPool(pool)` | `TxBuilder` | Complete exit after window | +| `.lendDeposit(request)` | `TxBuilder` | Lending deposit (supply) | +| `.lendWithdraw(request)` | `TxBuilder` | Lending withdraw | +| `.lendWithdrawMax(request)` | `TxBuilder` | Lending max withdraw | +| `.lendBorrow(request)` | `TxBuilder` | Lending borrow | +| `.lendRepay(request)` | `TxBuilder` | Lending repay | +| `.dcaCreate(request)` | `TxBuilder` | Create a DCA (recurring buy) order | +| `.dcaCancel(request)` | `TxBuilder` | Cancel a DCA order | +| `.confidentialFund(confidential, details)` | `TxBuilder` | Fund confidential account | +| `.confidentialTransfer(confidential, details)` | `TxBuilder` | Confidential transfer | +| `.confidentialWithdraw(confidential, details)` | `TxBuilder` | Withdraw from confidential to public address | | `.calls()` | `Promise` | Resolve all calls without sending | | `.estimateFee()` | `Promise` | Estimate gas cost | | `.preflight()` | `Promise` | Simulate the transaction | @@ -169,7 +185,7 @@ new PrivySigner(config: { walletId: string; publicKey: string; serverUrl?: string; - rawSign?: (walletId: string, hash: string) => Promise; + rawSign?: (walletId: string, hash: string) => Promise; }): PrivySigner ``` @@ -259,6 +275,66 @@ interface Token { } ``` +### BridgingConfig + +```typescript +interface BridgingConfig { + layerZeroApiKey?: string; // required for OFT/OFT-migrated routes + ethereumRpcUrl?: string; + solanaRpcUrl?: string; +} +``` + +### ExternalChain + +```typescript +enum ExternalChain { + ETHEREUM = "ethereum", + SOLANA = "solana", +} +``` + +### BridgeToken + +```typescript +interface BridgeToken { + id: string; + name: string; + symbol: string; + decimals: number; + chain: ExternalChain; + protocol: Protocol; + address: ExternalAddress; // source-chain token + bridgeAddress: ExternalAddress; // source-chain bridge + starknetAddress: Address; // destination token on Starknet + starknetBridge: Address; // destination bridge contract +} +``` + +### Connected External Wallets + +```typescript +ConnectedEthereumWallet.from( + { + chain: ExternalChain.ETHEREUM, + provider: eip1193Provider, + address: "0x...", + chainId: "0x1", + }, + starknetChainId +); + +ConnectedSolanaWallet.from( + { + chain: ExternalChain.SOLANA, + provider: solanaProvider, + address: "So1...", + chainId: "", + }, + starknetChainId +); +``` + ### Pool ```typescript diff --git a/build/starkzap/bridging.mdx b/build/starkzap/bridging.mdx new file mode 100644 index 0000000000..d861c18736 --- /dev/null +++ b/build/starkzap/bridging.mdx @@ -0,0 +1,185 @@ +--- +title: Bridging +description: "Bridge assets from Ethereum or Solana into Starknet using Starkzap bridge tokens, external wallet adapters, and deposit APIs" +icon: link +--- + +![Bridge hero](/assets/starkzap/bridges.png) + +## Overview + +Starkzap supports **deposit bridging into Starknet** from supported external chains: + +- **Ethereum** (Canonical, CCTP, OFT, OFT-migrated routes) +- **Solana** (Hyperlane routes) + +The bridge flow is: +1. Configure the SDK (including optional bridging config) +2. Fetch bridgeable tokens with `sdk.getBridgingTokens(...)` +3. Connect an external wallet (`ConnectedEthereumWallet` or `ConnectedSolanaWallet`) +4. Inspect balance, allowance, and estimated fees +5. Call `wallet.deposit(...)` to submit the source-chain transaction + + + Current wallet bridge APIs are for **external chain → Starknet deposits**. Outbound Starknet → external bridge flows are not exposed through this API surface. + + +## Install Optional Dependencies + +Install only what you use. + +For Ethereum routes: +```bash +npm install ethers +``` + +For Solana routes: + +```bash +npm install @solana/web3.js @hyperlane-xyz/sdk @hyperlane-xyz/registry @hyperlane-xyz/utils +``` + +## SDK Configuration + +Use `bridging` config when you need custom external RPCs or OFT support. +The SDK uses external RPCs to read source-chain state (balances/allowances), estimate bridge fees, and submit source-chain transactions reliably. Without explicit RPC URLs, these operations can be rate-limited or unavailable depending on your environment: + +```typescript +import { StarkZap } from "starkzap"; + +const sdk = new StarkZap({ + network: "mainnet", + bridging: { + ethereumRpcUrl: "https://eth-mainnet.g.alchemy.com/v2/", + solanaRpcUrl: "https://solana-mainnet.g.alchemy.com/v2/", + layerZeroApiKey: "", // required for OFT/OFT-migrated routes + }, +}); +``` + + + OFT bridging requires `bridging.layerZeroApiKey` and is supported on Starknet Mainnet routes only. + + +## Fetch Bridgeable Tokens + +```typescript +import { ExternalChain } from "starkzap"; + +// All bridgeable tokens for current Starknet environment +const allTokens = await sdk.getBridgingTokens(); + +// Filter by source chain +const ethereumTokens = await sdk.getBridgingTokens(ExternalChain.ETHEREUM); +const solanaTokens = await sdk.getBridgingTokens(ExternalChain.SOLANA); +``` + +## Connect External Wallets + +Take a look at the [Examples](/build/starkzap/examples). For WalletConnect setup details, see [WalletConnect Docs](https://docs.walletconnect.network/). In practice, you establish the external wallet session first (for example with WalletConnect), then pass its provider/account/chain into `ConnectedEthereumWallet.from(...)` or `ConnectedSolanaWallet.from(...)` for bridge calls. + +### Ethereum (EIP-1193) + +```typescript +import { ConnectedEthereumWallet, ExternalChain } from "starkzap"; + +const evmProvider = window.ethereum; +const [evmAddress] = await evmProvider.request({ method: "eth_requestAccounts" }); +const evmChainId = await evmProvider.request({ method: "eth_chainId" }); // "0x1" or "0xaa36a7" + +const ethWallet = await ConnectedEthereumWallet.from( + { + chain: ExternalChain.ETHEREUM, + provider: evmProvider, + address: evmAddress, + chainId: evmChainId, // evm wallet's chain id + }, + wallet.getChainId() // starknet wallet's chain id +); +``` + +### Solana + +```typescript +import { ConnectedSolanaWallet, ExternalChain } from "starkzap"; + +const solWallet = await ConnectedSolanaWallet.from( + { + chain: ExternalChain.SOLANA, + provider: solanaProvider, // must implement signAndSendTransaction() + address: solanaAddress, + chainId: solanaChainId, // e.g. mainnet/testnet genesis hash from wallet adapter + }, + wallet.getChainId() +); +``` + + + External wallet network and Starknet network must match by environment: + Ethereum Mainnet with Starknet Mainnet, Ethereum Sepolia with Starknet Sepolia, Solana Mainnet with Starknet Mainnet, and Solana Testnet with Starknet Sepolia. + + | External Network | Identifier | Starknet Network | + | --- | --- | --- | + | Ethereum Mainnet | `1` | Starknet Mainnet | + | Ethereum Sepolia | `11155111` | Starknet Sepolia | + | Solana Mainnet | `5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | Starknet Mainnet | + | Solana Testnet | `4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z` | Starknet Sepolia | + + +## Estimate and Deposit + +```typescript +import { Amount, fromAddress } from "starkzap"; + +const token = ethereumTokens[0]; +if (!token) throw new Error("No bridge token available"); + +// 1) Source-chain available balance +const available = await wallet.getDepositBalance(token, ethWallet); + +// 2) ERC20 allowance (null for native/non-allowance routes) +const allowance = await wallet.getAllowance(token, ethWallet); + +// 3) Fee estimation (fastTransfer only applies to CCTP) +const fees = await wallet.getDepositFeeEstimate(token, ethWallet, { + fastTransfer: true, +}); + +// 4) Submit deposit tx on source chain +const recipient = fromAddress( + "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +); // Starknet recipient + +const tx = await wallet.deposit( + recipient, + Amount.parse("25", token.decimals, token.symbol), + token, + ethWallet, + { fastTransfer: true } +); + +console.log(tx.hash); +``` + +## Protocol Notes + +| Protocol | Chain | Notes | +| --- | --- | --- | +| `canonical` | Ethereum | Standard bridge flow; approval may be required for ERC20 tokens. | +| `cctp` | Ethereum | Supports `fastTransfer`; fee estimate includes CCTP fast transfer bp fee. | +| `oft` / `oft-migrated` | Ethereum | Requires `bridging.layerZeroApiKey`; mainnet-only route availability. | +| `hyperlane` | Solana | Requires Solana + Hyperlane optional dependencies. | + +## Common Errors + +- **Chain mismatch**: token source chain and connected external wallet chain must match. +- **Missing LayerZero key**: OFT routes require `bridging.layerZeroApiKey`. +- **Unsupported chain pair**: Ethereum mainnet must pair with Starknet mainnet; testnet pairings must match. + +For additional issues, see [Troubleshooting](/build/starkzap/troubleshooting). + +## Next Steps + +- [Configuration](/build/starkzap/configuration) — full `SDKConfig` options +- [API Reference](/build/starkzap/api-reference) — exact method signatures +- [Examples](/build/starkzap/examples) — web example with bridge UI flow diff --git a/build/starkzap/confidential.mdx b/build/starkzap/confidential.mdx new file mode 100644 index 0000000000..2a1c49fd84 --- /dev/null +++ b/build/starkzap/confidential.mdx @@ -0,0 +1,216 @@ +--- +title: Confidential Transfers +description: "Fund, transfer, and withdraw using Tongo—privacy-preserving balances and transfers with the Tongo SDK" +icon: lock +--- + +![Confidential Transfers hero](/assets/starkzap/confidential-transfers.png) + +## Overview + +Starkzap supports **confidential** (privacy-preserving) transfers through the **[Tongo](https://www.tongo.cash/)** protocol. Using the Tongo SDK, users can perform confidential transfers (amount is obfuscated) on Starknet. + +**What users can do with confidential:** +- 🔐 **Transfer confidentially** - Send to another confidential account by recipient public key; amounts are hidden on-chain +- 📋 **Compliance and auditing** - [Tongo](https://www.tongo.cash/) provides flexible auditing mechanisms that enable compliance without sacrificing user privacy. Through viewing keys and ex-post proving, regulators can verify transaction details while preserving confidentiality for all other parties. +- ⚡ **Ragequit** -- Exit full balance and rollover (activate pending balance) + + + + The Tongo private key is separate from the Starknet wallet key. Your app must create and hold a `TongoConfidential` instance with the user's Tongo key and the correct Tongo contract address for the chain. + + +## Configuration + +Create a `TongoConfidential` instance with the Tongo contract for your chain, the user's Tongo private key, and an RPC provider (typically the wallet's provider). + +```typescript +import { StarkZap, TongoConfidential } from "starkzap"; + +const sdk = new StarkZap({ network: "mainnet" }); +const wallet = await sdk.connectWallet({ account: { signer, accountClass } }); + +const confidential = new TongoConfidential({ + privateKey: tongoPrivateKey, // BigNumberish or Uint8Array + contractAddress: TONGO_CONTRACT, // Address for mainnet or Sepolia + provider: wallet.getProvider(), +}); +``` + +Use the Tongo protocol [documentation](https://docs.tongo.cash/protocol/contracts.html) or deployment list for the correct `contractAddress` per chain. There is no wallet-level "register confidential"; you pass the `TongoConfidential` (or any `ConfidentialProvider`) into the tx builder methods. + +## TongoConfidential: address and state + +**Tongo address (for display or sharing):** + +```typescript +const tongoAddress = confidential.address; // base58-encoded public key +``` + +**Recipient identity (for receiving confidential transfers):** + +Share `recipientId` with others so they can send confidential transfers to this account. It is the public key `{ x, y }` used on-chain: + +```typescript +const recipientId = confidential.recipientId; // { x, y } — pass as `to` in confidentialTransfer +``` + +**Decrypted state (balance, pending, nonce):** + +```typescript +const state = await confidential.getState(); + +console.log("Active balance:", state.balance); // spendable +console.log("Pending balance:", state.pending); // needs rollover to become active +console.log("Nonce:", state.nonce); +``` + +### ConfidentialState shape + +```typescript +interface ConfidentialState { + balance: bigint; // active (spendable) + pending: bigint; // pending (activate via rollover) + nonce: bigint; +} +``` + +### Unit conversion (optional) + +Convert between public ERC20 amounts and confidential (Tongo) units when you need to display or validate amounts: + +```typescript +const confidentialUnits = await confidential.toConfidentialUnits(Amount.parse("100", USDC)); +const publicUnits = await confidential.toPublicUnits(confidentialUnits); +``` + +## Funding a confidential account + +Convert public ERC20 into confidential balance. The tx builder calls the provider's `fund()` method, which returns the approve call (if needed) and the fund call. + +```typescript +const tx = await wallet + .tx() + .confidentialFund(confidential, { + amount: Amount.parse("100", USDC), + sender: wallet.address, + }) + .send(); +await tx.wait(); +``` + +Optional: pay a fee to the sender (e.g. for relayed transactions): + +```typescript +.confidentialFund(confidential, { + amount: Amount.parse("100", USDC), + sender: wallet.address, + feeTo: feeAmount, +}) +``` + +## Confidential transfer + +Send from this confidential account to another confidential account. The recipient is identified by their `recipientId` (public key). + +```typescript +const tx = await wallet + .tx() + .confidentialTransfer(confidential, { + amount: Amount.parse("50", USDC), + to: recipientConfidential.recipientId, // { x, y } + sender: wallet.address, + }) + .send(); +await tx.wait(); +``` + +The transfer generates ZK proofs locally and submits the call on-chain; amounts are not visible on the public ledger. + +## Withdrawing to a public address + +Convert confidential balance back to ERC20 and send to a Starknet address. + +```typescript +const tx = await wallet + .tx() + .confidentialWithdraw(confidential, { + amount: Amount.parse("25", USDC), + to: wallet.address, // or any Starknet address + sender: wallet.address, + }) + .send(); +await tx.wait(); +``` + +## Tongo-specific: ragequit and rollover + +**Ragequit** — Exit the entire confidential balance to a public address in one call. Use when the user wants to close the confidential account or move everything on-chain. + +```typescript +const calls = await confidential.ragequit({ + to: wallet.address, + sender: wallet.address, +}); + +const tx = await wallet.tx().add(...calls).send(); +await tx.wait(); +``` + +**Rollover** — Move pending balance (from received confidential transfers) into the active balance so it can be spent. + +```typescript +const calls = await confidential.rollover({ sender: wallet.address }); +const tx = await wallet.tx().add(...calls).send(); +await tx.wait(); +``` + +## Batching with the transaction builder + +You can combine confidential operations with transfers, approvals, or other builder methods: + +```typescript +const tx = await wallet + .tx() + .confidentialFund(confidential, { amount: Amount.parse("100", USDC), sender: wallet.address }) + .transfer(USDC, [{ to: anotherAddress, amount: Amount.parse("10", USDC) }]) + .send(); +await tx.wait(); +``` + +**Builder methods for confidential:** + +| Method | Description | +|--------|-------------| +| `.confidentialFund(confidential, details)` | Fund confidential account (includes approve when needed) | +| `.confidentialTransfer(confidential, details)` | Transfer to another confidential account | +| `.confidentialWithdraw(confidential, details)` | Withdraw to a public Starknet address | + +Ragequit and rollover are not on the builder; use `confidential.ragequit(...)` / `confidential.rollover(...)` and add the returned calls with `.add(...calls)`. + +## Best practices + +1. **Keep the Tongo key separate** from the Starknet wallet key; treat it as sensitive user data and protect it accordingly. +2. **Use the same Tongo contract address** as the rest of your app (same chain) so all operations are consistent. +3. **Check state before withdraw** — ensure `state.balance` (and pending if needed) is sufficient; use `toPublicUnits` / `toConfidentialUnits` if you need to show human-readable amounts. + +## Troubleshooting + +### Wrong contract or chain + +Ensure `contractAddress` matches the [Tongo](https://www.tongo.cash/) deployment for the wallet's chain. A mismatch can lead to failed transactions or wrong state. + +### Fund fails or "approve" errors + +The provider includes the approve call in `fund()`; if the token or spender is non-standard, you may need to approve manually before calling the builder. Verify the token is the one supported by the Tongo contract. + +### Recipient format for confidential transfer + +`to` must be a `ConfidentialRecipient` — the object `{ x, y }` from the recipient's `confidential.recipientId`. Do not pass a Starknet address; use the recipient's Tongo public key. + +## Next steps + +- [Bitcoin, Stablecoins, and Tokens](/build/starkzap/erc20) — Token presets and amounts +- [Transactions](/build/starkzap/transactions) — Execution options +- [Tx Builder](/build/starkzap/tx-builder) — Batching and builder method list +- [API Reference](/build/starkzap/api-reference) — Full method signatures diff --git a/build/starkzap/configuration.mdx b/build/starkzap/configuration.mdx index 01a17fee60..a61689dbe5 100644 --- a/build/starkzap/configuration.mdx +++ b/build/starkzap/configuration.mdx @@ -1,6 +1,6 @@ --- -title: Network RPC and Staking -description: "Configure networks, RPC providers, and staking for the SDK" +title: Network, RPC, Staking, and Bridging +description: "Configure networks, RPC providers, staking, and bridging for the SDK" icon: cog --- @@ -111,6 +111,35 @@ The `StarkZap` accepts configuration through a single options object. You can us **Ready to implement staking?** See the [Staking & Delegation Guide](/build/starkzap/staking) for complete instructions on how users can stake tokens, claim rewards, and manage their positions. + + + Configure optional cross-chain bridge settings when depositing assets from Ethereum or Solana into Starknet. + + ```typescript + import { StarkZap } from "starkzap"; + + const sdk = new StarkZap({ + network: "mainnet", + bridging: { + ethereumRpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY", + solanaRpcUrl: "https://solana-mainnet.g.alchemy.com/v2/YOUR_KEY", + layerZeroApiKey: "YOUR_LAYERZERO_API_KEY", // for OFT routes + }, + }); + ``` + + - `ethereumRpcUrl`: Custom Ethereum RPC for bridge fee/balance operations + - `solanaRpcUrl`: Custom Solana RPC (falls back to cluster URL if omitted) + - `layerZeroApiKey`: Required for OFT/OFT-migrated routes + + + OFT routes require `bridging.layerZeroApiKey` and are supported on mainnet bridge routes only. + + + + For the full deposit flow (`getBridgingTokens`, external wallet adapters, fee estimate, deposit), see the [Bridging Guide](/build/starkzap/bridging). + + ## Complete Configuration Example @@ -132,6 +161,10 @@ const sdk = new StarkZap({ "0x00ca1702e64c81d9a07b86bd2c540188d92a2c73cf5cc0e508d949015e7e84a7" ), }, + bridging: { + ethereumRpcUrl: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY", + layerZeroApiKey: "YOUR_LAYERZERO_API_KEY", + }, }); ``` @@ -151,6 +184,9 @@ const sdk = new StarkZap({ "0x00ca1702e64c81d9a07b86bd2c540188d92a2c73cf5cc0e508d949015e7e84a7" ), }, + bridging: { + solanaRpcUrl: "https://solana-mainnet.g.alchemy.com/v2/YOUR_KEY", + }, }); ``` @@ -170,11 +206,18 @@ interface SDKConfig { // Optional features paymaster?: { nodeUrl: string; apiKey?: string }; staking?: StakingConfig; + bridging?: BridgingConfig; } interface StakingConfig { contract: Address; // optional override } + +interface BridgingConfig { + layerZeroApiKey?: string; + ethereumRpcUrl?: string; + solanaRpcUrl?: string; +} ``` @@ -185,5 +228,6 @@ interface StakingConfig { - Set up [Paymasters](/build/starkzap/paymasters) for gasless transactions - Enable [Staking & Delegation](/build/starkzap/staking) so users can earn passive income +- Configure [Bridging](/build/starkzap/bridging) for Ethereum/Solana deposits into Starknet - Learn about [Connecting Wallets](/build/starkzap/connecting-wallets) with different signers - Configure [Account Presets](/build/starkzap/connecting-wallets#account-presets) for your use case diff --git a/build/starkzap/connecting-wallets.mdx b/build/starkzap/connecting-wallets.mdx index f0c2bb1ca8..ce87f4f224 100644 --- a/build/starkzap/connecting-wallets.mdx +++ b/build/starkzap/connecting-wallets.mdx @@ -22,14 +22,14 @@ Choose the right method for your use case: |--------|----------|-----------------|----------|-----------------| | **Private Key** | Server-side apps, development | Manual key entry | ⚠️ User pays (or configure AVNU Paymaster) | ⭐ Simple | | **Privy** | Consumer apps, mobile/web | Email/social login | ⚠️ User pays (or configure AVNU Paymaster) | ⭐⭐ Moderate | -| **Cartridge** | Gaming applications | Social login, Face ID/Touch ID | ✅ **Automatic - Cartridge pays** | ⭐⭐ Moderate | +| **Cartridge** | Gaming applications | Social login, Face ID/Touch ID (web popup or native session) | ✅ **Policy-matching calls can be sponsored** | ⭐⭐ Moderate (RN: Metro + adapter) | ### Quick Decision Guide -- **Building a game?** → Use **Cartridge** (includes automatic gasless transactions) +- **Building a game?** → Use **Cartridge** (web: `@cartridge/controller`; React Native: `@starkzap/native` + [React Native Integration](/build/starkzap/react-native)) - **Building a consumer app?** → Use **Privy** (email/social login, configure AVNU Paymaster for gasless) - **Building a server-side service?** → Use **Private Key** (with proper security, configure AVNU Paymaster for gasless) -- **Need automatic gasless transactions?** → Use **Cartridge** (built-in paymaster) +- **Need gasless-style UX for approved game calls?** → Use **Cartridge** with policies that match your contract calls - **Need email-based auth?** → Use **Privy** - **Just testing?** → Use **Private Key** for quick setup @@ -135,16 +135,22 @@ const signer = new PrivySigner({ }); ``` -### 3. Cartridge Controller +### 3. Cartridge (web Controller or native session) + +[Cartridge](https://cartridge.gg) is specialized for gaming applications and provides social login and passkey authentication. + +- **Web:** opens a Controller popup (install `@cartridge/controller`). +- **React Native / Expo:** in-app browser / deep-link **session** flow via `@starkzap/native` — register the native Cartridge adapter before connecting; see [React Native Integration](/build/starkzap/react-native). + +Best for: -[Cartridge](https://cartridge.gg) is specialized for gaming applications and provides social login and passkey authentication. Opens a popup for user authentication. Best for: - Gaming applications - Social login integration - Passkey-based authentication -- Apps that want automatic gasless transactions +- Policy-approved, paymastered execution (not every arbitrary call) - **Key Advantage:** Cartridge includes a built-in paymaster that automatically sponsors (pays for) all transactions, so users never pay gas fees. This is perfect for gaming where you want seamless, gasless transactions. For detailed integration instructions, see the [Cartridge Controller Integration Guide](/build/starkzap/integrations/cartridge-controller). + **Key advantage:** Cartridge can sponsor **policy-matching** transactions through its paymaster/session stack after users approve policies. Other calls may still require user fees or extra steps. See the [Cartridge Controller Integration Guide](/build/starkzap/integrations/cartridge-controller). ```typescript diff --git a/build/starkzap/dollar-cost-average.mdx b/build/starkzap/dollar-cost-average.mdx new file mode 100644 index 0000000000..b636ff6913 --- /dev/null +++ b/build/starkzap/dollar-cost-average.mdx @@ -0,0 +1,163 @@ +--- +title: Dollar-Cost Averaging +description: "Schedule recurring buys with AVNU or Ekubo—create orders, preview cycles, and cancel via wallet.dca()" +icon: calendar-clock +--- + +![DCA hero](/assets/starkzap/dca.png) + +## Overview + +Starkzap supports **Dollar-Cost Averaging (DCA)** through **[AVNU](https://app.avnu.fi/en)** and **[Ekubo](https://ekubo.org/starknet/swap)**. Users can create recurring buy orders (sell token X, buy token Y on a schedule), preview the expected swap per cycle, and cancel orders. DCA uses the same [swap providers](/build/consumer-app-sdk/swap#providers) under the hood for execution and cycle quoting. + +**What users can do with DCA:** +- 📅 **Create recurring orders** - Set token pair, amount per cycle, and frequency (e.g. daily); optional min/max bounds with AVNU +- 📊 **Preview a cycle** - See the expected buy amount for the next cycle before creating or on existing orders +- 📋 **List orders** - Fetch active (and optionally past) DCA orders for the wallet +- ❌ **Cancel orders** - Cancel by order id or order address +- 📦 **Batch with other actions** - Use the transaction builder to combine DCA create/cancel with transfers or swaps + + + DCA providers rely on swap providers for cycle execution and preview. Register [swap providers](/build/consumer-app-sdk/swap#registering-swap-providers) and a default swap provider when using DCA; `previewCycle` uses the wallet's default (or specified) swap provider to quote the next cycle. + + +## Configuration + +### Registering DCA providers + +Register DCA providers when connecting the wallet (or at runtime). The wallet's `dca()` client uses these providers for create/cancel and for cycle preview (which uses the swap provider to quote the next cycle). + +```typescript +import { StarkZap, AvnuSwapProvider, EkuboSwapProvider, AvnuDcaProvider, EkuboDcaProvider } from "starkzap"; + +const sdk = new StarkZap({ network: "mainnet" }); + +const wallet = await sdk.connectWallet({ + account: { signer, accountClass: ArgentPreset }, + swapProviders: [new AvnuSwapProvider(), new EkuboSwapProvider()], + defaultSwapProviderId: "avnu", + dcaProviders: [ + new AvnuDcaProvider(), + new EkuboDcaProvider(), + ], + defaultDcaProviderId: "avnu", +}); +``` + +At runtime (e.g. after Cartridge onboard), register DCA providers and set the default the same way you do for [swap providers](/build/consumer-app-sdk/swap#registering-swap-providers): `wallet.dca().registerProvider(provider)`, `wallet.dca().setDefaultDcaProvider(providerId)`. + + + Register swap providers and a default swap provider when using DCA; cycle execution and `previewCycle` depend on them. + + +## Creating a DCA order + +Create a recurring order with token pair, amount per cycle, frequency, and optional bounds (AVNU supports min/max buy amount per cycle; Ekubo uses TWAMM-style continuous execution). + +```typescript +const tx = await wallet.dca().create({ + tokenIn: STRK, + tokenOut: USDC, + amountInPerCycle: Amount.parse("10", STRK), + frequency: "P1D", // ISO 8601 duration, e.g. daily + // Optional (AVNU): minBuyAmountBase, maxBuyAmountBase + // Optional: provider, startTime, endTime +}); +await tx.wait(); +``` + +To batch DCA create with other operations, use the [Tx Builder](/build/consumer-app-sdk/tx-builder) (e.g. `.dcaCreate(...)`). + +## Previewing a cycle + +Show users the expected outcome of the next DCA cycle (quote from the swap provider) before they create the order or to display on an existing order: + +```typescript +const quote = await wallet.dca().previewCycle({ + tokenIn: STRK, + tokenOut: USDC, + amountInPerCycle: Amount.parse("10", STRK), + provider: "avnu", // optional; uses default DCA provider and swap provider for quote +}); +console.log(quote.amountOutBase); // expected buy amount for one cycle +``` + +## Listing and cancelling orders + +List active (and optionally past) DCA orders for the wallet, then cancel by order id or order address: + +```typescript +const orders = await wallet.dca().getOrders({ provider: "avnu" }); + +for (const order of orders) { + console.log(order.id, order.tokenIn.symbol, order.tokenOut.symbol, order.frequency); +} + +// Cancel by order id (provider-specific string) or by order address +const tx = await wallet.dca().cancel({ orderId: orders[0].id }); +await tx.wait(); +``` + +## Using the transaction builder + +Batch DCA create or cancel with other actions: + +```typescript +const tx = await wallet + .tx() + .dcaCreate({ + tokenIn: STRK, + tokenOut: USDC, + amountInPerCycle: Amount.parse("10", STRK), + frequency: "P1D", + }) + .transfer(USDC, [{ to: recipient, amount: Amount.parse("5", USDC) }]) + .send(); +await tx.wait(); +``` + +Cancel via the builder: + +```typescript +const tx = await wallet.tx().dcaCancel({ orderId: myOrderId }).send(); +await tx.wait(); +``` + +See [Tx Builder](/build/consumer-app-sdk/tx-builder) for the full list of builder methods. + +## DCA providers + +| Provider | Id | Description | +| -------- | ----- | ----------- | +| **[AVNU](https://app.avnu.fi/en)** | `avnu` | Recurring orders with optional min/max buy amount per cycle; uses AVNU swap routing for execution. | +| **[Ekubo](https://ekubo.org/starknet/swap)** | `ekubo` | TWAMM-style continuous DCA; no discrete per-cycle amount (continuous flow). Supports order list and cancel. | + +Provider-specific options (e.g. AVNU bounds, Ekubo time alignment) are documented in the SDK types. Use `wallet.dca().listProviders()` to see registered DCA provider ids and `setDefaultDcaProvider(providerId)` to change the default. + +## Best practices + +1. **Register swap providers first** so DCA cycle execution and `previewCycle` have a quote source. +2. **Use token presets** from `getPresets(chainId)` or `mainnetTokens` / `sepoliaTokens` for `tokenIn` and `tokenOut` so addresses and decimals match the chain. +3. **Preview before create** — call `previewCycle` and show users the expected buy amount per cycle before they confirm the order. +4. **Handle provider differences** — AVNU supports discrete cycles and optional min/max bounds; Ekubo is continuous (TWAMM). Validate inputs per provider when building forms. + +## Troubleshooting + +### "No default DCA provider configured" + +Register at least one DCA provider and call `setDefaultDcaProvider(providerId)` (or pass `defaultDcaProviderId` when connecting). Alternatively, pass `provider: "avnu"` or `provider: "ekubo"` on each DCA request. + +### DCA relies on swap providers + +If `previewCycle` or cycle execution fails, ensure swap providers are registered and a default swap provider is set. DCA uses the swap provider to get quotes and execute each cycle. + +### Chain or provider mismatch + +Ensure the wallet is on a chain supported by the chosen DCA provider (AVNU and Ekubo support mainnet and Sepolia). Align the SDK network config with the RPC/wallet chain. + +## Next steps + +- [Swaps](/build/starkzap/swap) — One-off quotes and swaps (used by DCA under the hood) +- [Bitcoin, Stablecoins, and Tokens](/build/starkzap/erc20) — Token presets and amounts +- [Tx Builder](/build/starkzap/tx-builder) — Batching DCA with other operations +- [API Reference](/build/starkzap/api-reference) — Full method signatures diff --git a/build/starkzap/erc20.mdx b/build/starkzap/erc20.mdx index 0703c47c41..475454e976 100644 --- a/build/starkzap/erc20.mdx +++ b/build/starkzap/erc20.mdx @@ -1,7 +1,7 @@ --- -title: Bitcoin, Stablecoins, and Token +title: "Stablecoins & Token" description: "Check balances, transfer tokens, and work with amounts using type-safe primitives" -icon: credit-card +icon: "credit-card" --- ![Bitcoin, Stablecoins, and Token hero](/assets/starkzap/bitcoin-stablecoins-token.png) @@ -264,4 +264,4 @@ if (balance.lt(totalNeeded)) { - Learn about [Staking & Delegation](/build/starkzap/staking) - Explore [Transaction Builder](/build/starkzap/transactions#transaction-builder) for complex operations -- Check the [API Reference](/build/starkzap/api-reference) for detailed method signatures +- Check the [API Reference](/build/starkzap/api-reference) for detailed method signatures \ No newline at end of file diff --git a/build/starkzap/examples.mdx b/build/starkzap/examples.mdx index 293a3293ae..5e09215297 100644 --- a/build/starkzap/examples.mdx +++ b/build/starkzap/examples.mdx @@ -121,6 +121,7 @@ The repository includes example applications in the [examples/](https://github.c - ✅ Account deployment and status checking - ✅ Test transactions (regular and sponsored) - ✅ Support for multiple account presets (OpenZeppelin, Argent, Braavos, etc.) + - ✅ Bridge demo flow (Ethereum/Solana wallets, bridgeable tokens, fee estimate, deposit) ### Getting Started @@ -143,6 +144,31 @@ The repository includes example applications in the [examples/](https://github.c Then update the `PRIVY_SERVER_URL` in `examples/web/main.ts` to point to your server. + ### Bridge Setup (Web Example) + + The web example can also demonstrate bridge flows from Ethereum/Solana into Starknet. + + Set optional environment variables in `examples/web/.env`: + + ```bash + VITE_ALCHEMY_API_KEY= # external RPCs for Ethereum/Solana bridge operations + VITE_OFT_PUBLIC_KEY= # LayerZero API key for OFT routes + ``` + + SDK setup in `examples/web/main.ts`: + + ```typescript + const sdk = new StarkZap({ + rpcUrl: RPC_URL, + chainId: SDK_CHAIN_ID, + bridging: { + ethereumRpcUrl: `https://eth-mainnet.g.alchemy.com/v2/${VITE_ALCHEMY_API_KEY}`, + solanaRpcUrl: `https://solana-mainnet.g.alchemy.com/v2/${VITE_ALCHEMY_API_KEY}`, + layerZeroApiKey: VITE_OFT_PUBLIC_KEY, + }, + }); + ``` + ### Key Code Snippets **Connecting with Cartridge:** @@ -465,4 +491,4 @@ console.log("Transaction confirmed!"); - Explore the example code in the `examples/` directory - Adapt the patterns to your own application - Check the [API Reference](/build/starkzap/api-reference) for detailed method documentation -- Review the [Troubleshooting](/build/starkzap/troubleshooting) guide if you encounter issues \ No newline at end of file +- Review the [Troubleshooting](/build/starkzap/troubleshooting) guide if you encounter issues diff --git a/build/starkzap/installation.mdx b/build/starkzap/installation.mdx index 5b471c67d5..2bed983d1a 100644 --- a/build/starkzap/installation.mdx +++ b/build/starkzap/installation.mdx @@ -18,18 +18,51 @@ or yarn add starkzap ``` + + Building for React Native/Expo? Use [React Native Integration](/build/starkzap/react-native) and install `@starkzap/native` instead of using `starkzap` directly in your mobile app. + + ### Dependencies -The SDK has two peer dependencies: +The SDK depends on: - [`starknet`](https://www.npmjs.com/package/starknet) (v9+) - Starknet.js core library -- [`@cartridge/controller`](https://www.npmjs.com/package/@cartridge/controller) - Cartridge wallet integration (optional, only needed for Cartridge support) -These will be installed automatically when you install `starkzap`. +This will be installed automatically when you install `starkzap`. + +#### Peer dependencies by feature + +All peer dependencies are **optional** to keep the package lean. Install only what you need: + +| Feature | Included in | Peer Dependencies | +| --- | --- | --- | +| **Ethereum bridging** (deposit / withdraw to Ethereum) | `starkzap`,
`@starkzap/native` | `ethers@^6` | +| **Solana bridging** (deposit / withdraw to Solana via Hyperlane) | `starkzap`,
`@starkzap/native` | `@solana/web3.js@^1`, `@hyperlane-xyz/sdk@^14`, `@hyperlane-xyz/registry@^19`, `@hyperlane-xyz/utils@^14` | +| **Cartridge Controller wallet** (web-only) | `starkzap` | `@cartridge/controller@^0.13` | +| **Confidential transfers** (Tongo) | `starkzap`,
`@starkzap/native` | `@fatsolutions/tongo-sdk@^1` | +| **React Native / Expo** | `@starkzap/native` | `react-native-get-random-values@^1`, `fast-text-encoding@^1`, `@ethersproject/shims@^5`, `buffer@^6` | + +```bash +# Ethereum bridging +npm install ethers + +# Solana bridging +npm install @solana/web3.js @hyperlane-xyz/sdk @hyperlane-xyz/registry @hyperlane-xyz/utils + +# Cartridge Controller (only for Web) +npm install @cartridge/controller + +# Confidential transfers +npm install @fatsolutions/tongo-sdk + +# React Native / Expo (use @starkzap/native instead of starkzap) +npm install @starkzap/native react-native-get-random-values fast-text-encoding @ethersproject/shims buffer +``` ## Next Steps Once installed, configure the SDK: 1. Set up [Configuration](/build/starkzap/configuration) for networks, RPC providers, and optional features -2. Then check out the [Quick Start Guide](/build/starkzap/quick-start) to get your first wallet integration working in minutes +2. If you are building a mobile app, follow [React Native Integration](/build/starkzap/react-native) for `@starkzap/native` + Metro setup +3. Then check out the [Quick Start Guide](/build/starkzap/quick-start) to get your first wallet integration working in minutes diff --git a/build/starkzap/integrations/cartridge-controller.mdx b/build/starkzap/integrations/cartridge-controller.mdx index e2690c6b5a..45e8e073ac 100644 --- a/build/starkzap/integrations/cartridge-controller.mdx +++ b/build/starkzap/integrations/cartridge-controller.mdx @@ -13,14 +13,44 @@ description: "Use Cartridge Controller with network-safe session configuration" - **Passkey Authentication**: Biometric authentication (Face ID, Touch ID, Windows Hello) - **Policy-Based Access**: Define policies for what contracts/methods can be called - **Delegated Transactions**: Users can approve transactions without managing keys directly -- **Built-in Paymaster**: **Automatic gasless transactions** - Cartridge sponsors (pays for) all transaction fees automatically +- **Built-in Paymaster**: **Policy-bound sponsorship** — Cartridge can sponsor fees for calls that match **approved policies** (and eligible session / SNIP-9 paths), not every arbitrary transaction. -Starkzap integrates seamlessly with Cartridge Controller, making it perfect for gaming applications where you want seamless, gasless transactions. +Starkzap integrates with Cartridge for gaming-style flows: **web** uses `@cartridge/controller`; **React Native / Expo** uses `@starkzap/native` with a **native session adapter** (register it before connecting) when your package version supports native Cartridge. + +## StarkZap integration + +When StarkZap connects Cartridge, it forwards your SDK network configuration (for example `rpcUrl` and `chainId`) into the Cartridge flow so you typically configure the network once on `new StarkZap(...)`. + + + **Network alignment is not auto-validated.** You must use the same `rpcUrl` / `chainId` (or `network` preset) you intend the Cartridge session and paymaster to target. The SDK forwards these values but does **not** verify that some other tab, deep link, or preset was opened on a different chain. Mismatches often show up as SNIP-9 or paymaster errors. + + +You do not need to pass chain settings again when calling `sdk.connectCartridge()` or `sdk.onboard({ strategy: "cartridge" })` on the same `StarkZap` instance. + +## Web (browser) vs React Native + +| | **Web** | **React Native / Expo** | +| --- | --- | --- | +| Package | `starkzap` + `@cartridge/controller` | `@starkzap/native` (depends on `starkzap`) | +| UX | Controller popup / embedded flow | In-app browser / deep link **session** flow | +| Before connect | Install `@cartridge/controller` | [React Native setup](/build/starkzap/react-native): Metro `withStarkzap`, optional `import "@starkzap/native/polyfills"` first, **register** the native Cartridge adapter when your SDK version exports it | +| Import | `import { StarkZap } from "starkzap"` | `import { StarkZap } from "@starkzap/native"` | + +## React Native / Expo (native Cartridge session) + +1. Follow [React Native Integration](/build/starkzap/react-native) for Metro (`withStarkzap`) and dependencies. +2. Optionally add `import "@starkzap/native/polyfills"` as the **first** line in your entrypoint if you are not relying solely on Metro-injected polyfills. +3. **Register** the native Cartridge adapter once at startup before `connectCartridge` / `onboard({ strategy: "cartridge" })` (for example `registerCartridgeTsAdapter` / `registerCartridgeNativeAdapter` — exact exports depend on your `@starkzap/native` version). +4. Pass **policies** and/or a Cartridge **preset** that resolves policies for your chain. +5. **Onboarding:** native Cartridge often defaults to **`deploy: "never"`** or recommends it when deployment differs from the browser Controller; pass `deploy: "if_needed"` explicitly if you need core-style deployment checks. +6. **Sponsored execution** on native is tied to the session wallet (commonly **`feeMode: "sponsored"`** only). + +See the `examples/tic-tac-toe` app in the [Starkzap repository](https://github.com/keep-starknet-strange/starkzap) when available for a full Expo reference. ## Why Use Cartridge? - ✅ **Perfect for Gaming**: Specialized for gaming applications with session-based transactions -- ✅ **Automatic Gasless Transactions**: Built-in paymaster sponsors all transactions—users never pay gas fees +- ✅ **Gasless-style UX for approved calls**: Built-in paymaster can sponsor **policy-matching** transactions after users approve policies - ✅ **Better UX**: No seed phrases or private key management - ✅ **Social Login**: Users sign in with familiar accounts (Google, Twitter, etc.) - ✅ **Biometric Auth**: Face ID, Touch ID, Windows Hello support @@ -28,14 +58,14 @@ Starkzap integrates seamlessly with Cartridge Controller, making it perfect for - ✅ **Session Management**: Users approve policies once, then transactions happen automatically - **Key Value Proposition:** Unlike Privy or Private Key strategies (which require separate AVNU Paymaster configuration), Cartridge includes a built-in paymaster that automatically sponsors all transactions. This means users never see gas fees or need to approve individual transactions—perfect for gaming where you want seamless, uninterrupted gameplay. + **Key value:** Unlike Privy or private-key flows (which often use AVNU Paymaster for sponsorship), Cartridge can sponsor **policy-approved** calls through its paymaster/session stack—so matching game or token operations stay gasless after users approve policies. Other calls may still require user fees or extra steps. -## Setup +## Setup (web browser) ### 1. Install Cartridge Controller -The Cartridge Controller is included as a peer dependency of Starkzap: +For **web**, install the Controller peer used by `starkzap`: ```bash npm install @cartridge/controller @@ -49,7 +79,7 @@ import { StarkZap, OnboardStrategy } from "starkzap"; const sdk = new StarkZap({ network: "mainnet" }); ``` -## Integration +## Integration (web) ### Basic Connection @@ -192,7 +222,7 @@ await tx.wait(); console.log("Transfer complete! (Gas paid by Cartridge)"); ``` -## User Flow +## User Flow (web) 1. **User clicks "Connect with Cartridge"** 2. **Cartridge popup appears** with social login options diff --git a/build/starkzap/lending.mdx b/build/starkzap/lending.mdx new file mode 100644 index 0000000000..c40560af7a --- /dev/null +++ b/build/starkzap/lending.mdx @@ -0,0 +1,283 @@ +--- +title: "Lending & Borrowing" +description: "Supply, borrow, withdraw, and repay with Vesu—discover markets, manage positions, and check collateral health" +icon: "landmark" +--- + +![Lending and Borrowing hero](/assets/starkzap/lending-borrowing.png) + +## Overview + +Starkzap supports lending and borrowing through [**Vesu**](https://vesu.xyz/lite/markets). Users can supply assets (deposit), borrow against collateral, repay debt, and withdraw supplied assets. + +**What users can do with lending:** + +- 💰 **Supply assets** - Deposit tokens into lending pools and earn interest (supply APY) +- 💳 **Borrow** - Use supplied collateral to borrow other assets +- 💵 **Repay** - Pay down debt; optionally withdraw collateral in the same flow +- 📤 **Withdraw** - Withdraw supplied tokens (or max withdraw in one call) +- 📊 **Monitor positions** - Query position size, debt, and collateralization health + + + The default lending provider is [Vesu](https://vesu.xyz/lite/markets). It is registered automatically when the wallet is created. You can register additional providers or set a different default via `wallet.lending().registerProvider()` and `setDefaultProvider()`. + + +## Configuration + +No extra configuration is required for [Vesu](https://vesu.xyz/lite/markets) on mainnet or Sepolia. The wallet's `lending()` client uses the connected chain: + +```typescript +import { StarkZap } from "starkzap"; + +const sdk = new StarkZap({ network: "mainnet" }); +const wallet = await sdk.connectWallet({ account: { signer, accountClass } }); + +// Lending client uses wallet chain and address +const lending = wallet.lending(); +``` + +Optional: register another provider or set default: + +```typescript +lending.registerProvider(myLendingProvider, true); // true = make default +lending.setDefaultProvider("vesu"); +``` + +## Discovering markets + +Fetch available lending markets for the wallet's chain: + +```typescript +const markets = await wallet.lending().getMarkets(); + +for (const market of markets) { + console.log(market.asset.symbol, market.poolAddress, market.vTokenAddress); + console.log("Can be borrowed:", market.canBeBorrowed); +} +``` + +### LendingMarket shape + +```typescript +interface LendingMarket { + protocol: string; + poolAddress: Address; + asset: Token; + vTokenAddress: Address; + vTokenSymbol?: string; + canBeBorrowed?: boolean; +} +``` + +Use these markets (and their `poolAddress` / `asset` / `vTokenAddress`) when calling deposit, withdraw, borrow, and repay with the same token/pool. + +## Depositing + +Supply tokens into a lending pool. The provider includes the approval call when building the transaction. + +```typescript +const tx = await wallet.lending().deposit({ + token: USDC, + amount: Amount.parse("1000", USDC), + // receiver?: Address — defaults to wallet address +}); +await tx.wait(); +``` + +With execution options (e.g. sponsored fees): + +```typescript +const tx = await wallet.lending().deposit( + { token: USDC, amount: Amount.parse("1000", USDC) }, + { feeMode: "sponsored" } +); +await tx.wait(); +``` + +## Withdrawing + +Withdraw a specific amount of supplied tokens: + +```typescript +const tx = await wallet.lending().withdraw({ + token: USDC, + amount: Amount.parse("200", USDC), + receiver: wallet.address, // optional +}); +await tx.wait(); +``` + +Withdraw the maximum allowed (e.g. full supplied balance) in one call: + +```typescript +const tx = await wallet.lending().withdrawMax({ + token: USDC, + receiver: wallet.address, +}); +await tx.wait(); +``` + + + Max withdraw may not be supported by all providers. [Vesu](https://vesu.xyz/lite/markets) supports `withdrawMax`. Check `provider.prepareWithdrawMax` or catch the error if you need to support multiple providers. + + +## Borrowing + +Borrow against collateral. You specify the collateral pair (collateral token + debt token) and the amount to borrow (or collateral amount, depending on denomination). + +```typescript +const tx = await wallet.lending().borrow({ + collateralToken: ETH, + debtToken: USDC, + amount: Amount.parse("500", USDC), // amount of debt to borrow +}); +await tx.wait(); +``` + +Optional: pass `poolAddress` if you have a specific pool, or `provider: "vesu"` to force the provider. `user` defaults to the wallet address. + +## Repaying + +Repay borrowed debt. You can optionally withdraw collateral in the same action (provider-dependent). + +```typescript +const tx = await wallet.lending().repay({ + collateralToken: ETH, + debtToken: USDC, + amount: Amount.parse("100", USDC), + // withdrawCollateral?: boolean +}); +await tx.wait(); +``` + +## Position and health + +### Get position + +Retrieve the user's lending position for a collateral/debt pair: + +```typescript +const position = await wallet.lending().getPosition({ + collateralToken: ETH, + debtToken: USDC, +}); + +console.log(position.collateralShares); +console.log(position.nominalDebt); +console.log(position.collateralAmount, position.debtAmount); +console.log("Collateralized:", position.isCollateralized); +console.log("Collateral value:", position.collateralValue, "Debt value:", position.debtValue); +``` + +### LendingPosition shape + +```typescript +interface LendingPosition { + collateralShares: bigint; + nominalDebt: bigint; + collateralAmount?: bigint; + debtAmount?: bigint; + collateralValue: bigint; // USD value [SCALE] + debtValue: bigint; // USD value [SCALE] + isCollateralized: boolean; +} +``` + +### Get health + +Check if the position is collateralized (above liquidation threshold): + +```typescript +const health = await wallet.lending().getHealth({ + collateralToken: ETH, + debtToken: USDC, +}); + +console.log("Collateralized:", health.isCollateralized); +console.log("Collateral value:", health.collateralValue, "Debt value:", health.debtValue); +``` + +### Quote projected health + +Simulate an action (e.g. borrow or repay) and get the projected health after the action, plus the prepared calls and fee simulation: + +```typescript +const quote = await wallet.lending().quoteHealth({ + action: { action: "borrow", request: { collateralToken: ETH, debtToken: USDC, amount } }, + health: { collateralToken: ETH, debtToken: USDC }, + feeMode: "sponsored", +}); + +console.log("Current health:", quote.current); +console.log("Projected health after action:", quote.projected); +console.log("Prepared calls:", quote.prepared.calls); +console.log("Simulation:", quote.simulation); +``` + +Use this to show users how a borrow or repay would affect their collateralization before they confirm. + +## Using the transaction builder + +Batch lending actions with transfers, staking, or other operations using the tx builder. Methods are prefixed with `lend`: + +- `.lendDeposit(request)` — add a deposit +- `.lendWithdraw(request)` — add a withdraw +- `.lendWithdrawMax(request)` — add a max withdraw +- `.lendBorrow(request)` — add a borrow +- `.lendRepay(request)` — add a repay + +**Example: deposit and then transfer in one tx** + +```typescript +const tx = await wallet + .tx() + .lendDeposit({ token: USDC, amount: Amount.parse("500", USDC) }) + .transfer(USDC, [{ to: recipient, amount: Amount.parse("100", USDC) }]) + .send(); +await tx.wait(); +``` + +**Example: repay and withdraw collateral** + +```typescript +const tx = await wallet + .tx() + .lendRepay({ + collateralToken: ETH, + debtToken: USDC, + amount: Amount.parse("200", USDC), + withdrawCollateral: true, + }) + .send(); +await tx.wait(); +``` + +See [Tx Builder](/build/consumer-app-sdk/tx-builder) for the full list of builder methods. + +## Best practices + +1. **Check health before and after** borrow/repay so users understand liquidation risk. +2. **`Use quoteHealth()`** to show projected health after an action before the user confirms. +3. **Discover markets once** (e.g. on load) and cache `getMarkets()` if you list markets in the UI. +4. **Use token presets** for `token`, `collateralToken`, and `debtToken` so addresses match the chain. + +## Troubleshooting + +### "Lending provider returned no calls" + +The provider could not build calls for the given request (e.g. wrong 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 \ No newline at end of file diff --git a/build/starkzap/overview.mdx b/build/starkzap/overview.mdx index ef122acc10..ce4fc3bf6b 100644 --- a/build/starkzap/overview.mdx +++ b/build/starkzap/overview.mdx @@ -8,30 +8,54 @@ icon: "book-open" ## 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, send tokens, enable staking, and execute transactions—without requiring users to manage seed phrases or understand blockchain complexity. +**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 - + Complete SDK with web, mobile, and server support, production-ready codebase, and minimal configuration - + Independent modules that allow you to use only what you need while maintaining clean code separation - - Ready-to-use integrations with major Starknet services including AVNU Paymaster, Privy, and Cartridge Controller + + Ready-to-use integrations with major Starknet services including AVNU Paymaster, Privy, AVNU, EKUBO, Vesu, Tongo Cash and Cartridge Controller - + Works seamlessly in Node.js, browsers, and React Native with the same API - + Social login, email authentication, and biometrics—no seed phrases required - - Built-in support for gasless transactions, staking, swapping, and borrowing for smooth user experiences + + Paymaster and Cartridge policy-based sponsorship where configured, plus staking, swapping, and borrowing for smooth user experiences @@ -40,31 +64,39 @@ icon: "book-open" 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 Controller** - Perfect for games: users sign in with Google/Twitter or Face ID/Touch ID, and Cartridge automatically pays all transaction fees so users never see gas costs +- **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** (incoming) - Let users exchange one token for another (like currency exchange) -- **Borrowing** (incoming) - Enable users to borrow and lend tokens (like a lending platform) -- **Cross-chain Bridge** (incoming) - Enable users to move assets between different blockchains +- **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 +- **Confidential** - Privacy-preserving transfers with Tongo Cash +- **Cross-chain Bridge** - Bridge assets from Ethereum or Solana into Starknet ## Who Is This For? - + Jump into blockchain development without learning everything from scratch. Leverage familiar patterns (REST APIs, OAuth) and focus on user experience. - + Extend your reach to consumer applications using pre-built integrations without learning mobile/web frameworks from scratch. - + Rapidly prototype and launch blockchain-based applications, reducing development time from months to weeks. @@ -74,70 +106,62 @@ The SDK includes ready-to-use integrations with major Starknet services: 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) 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) 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) 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) @@ -170,6 +194,14 @@ Starkzap │ └── ERC20 transfers, balances, approvals ├── Staking & Delegation │ └── Pool management, rewards, exits + ├── Bridge + │ └── Deposit, quotes + ├── Swap & DCA + │ └── Swapping, quotes, dca + ├── Borrowing & Lending + │ └── Borrow, lend, withdraw + ├── Confidential + │ └── Fund, transfer, withdraw ├── Transaction Builder │ └── Batching, preflight, fee estimation └── Type-Safe Primitives @@ -188,27 +220,30 @@ Starkzap 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/dca) - Recurring buys (Dollar-Cost Averaging) with AVNU or Ekubo + +- [Lending](/build/starkzap/lending) - Supply, borrow, and repay with Vesu +- [Confidential Transfers](/build/starkzap/confidential) - Privacy-preserving balances with Tongo - [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 +**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 @@ -221,13 +256,11 @@ Ready to start building? Here's your roadmap: 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 +- **[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** - [Starkzap Repo](https://github.com/keep-starknet-strange/starkzap) - Report issues, contribute, and explore the codebase \ No newline at end of file +- **GitHub** - Report issues, contribute, and explore the codebase diff --git a/build/starkzap/paymasters.mdx b/build/starkzap/paymasters.mdx index 34442188f6..35aa66bd26 100644 --- a/build/starkzap/paymasters.mdx +++ b/build/starkzap/paymasters.mdx @@ -150,37 +150,37 @@ Paymasters allow you to sponsor (pay for) transaction fees so users don't have t - Use Cartridge's built-in paymaster when using the **Cartridge Controller** strategy. Cartridge automatically sponsors all transactions—no configuration needed. + Use Cartridge's paymaster when using the **Cartridge** wallet strategy (**web:** Controller; **React Native:** native session via `@starkzap/native` when supported). Sponsorship is **policy-bound** — calls that match approved policies (and eligible session / SNIP-9 paths) can be paymastered; other calls may require user fees. ## When to Use Cartridge Paymaster - - ✅ Using **Cartridge Controller** strategy for wallet connection - - ✅ Building gaming applications - - ✅ Want automatic gasless transactions without setup - - ✅ Want seamless, uninterrupted user experience + - ✅ Using **Cartridge** for wallet connection (web or native) + - ✅ Building gaming applications with explicit **policies** for contract calls + - ✅ Want paymastered execution for **matching** session calls after policy approval + - ✅ Want minimal extra paymaster configuration compared with AVNU for those paths ## How It Works - Cartridge includes a built-in paymaster that automatically sponsors (pays for) all transactions. When you use Cartridge Controller, all transactions are gasless by default—no configuration required. + Cartridge combines sessions with a paymaster service so **approved** execution paths can be sponsored. This is not a guarantee that every arbitrary `execute()` is gasless — scope your **policies** to the calls you intend to sponsor. ### Session-Based Paymastered Transactions According to the [Cartridge Controller architecture](https://docs.cartridge.gg/controller/architecture#how-paymastered-transactions-work), Cartridge uses session-based transactions with the paymaster: 1. **User approves policies once** - Defines what contracts/methods can be called - 2. **Session is registered** - Can be registered without signature for paymastered transactions - 3. **Transactions execute automatically** - When you call `account.execute()`: + 2. **Session is registered** - Can be registered without signature for eligible paymastered transactions + 3. **Matching transactions** - When you call `account.execute()` for calls that fit the session / SNIP-9 flow: - SDK validates the session is active - - Constructs an `OutsideExecution` message (meta-transaction via SNIP-9) + - Constructs an `OutsideExecution` message (meta-transaction via SNIP-9) where applicable - Signs the message with the session key - Sends the signed payload to Cartridge's paymaster service - - The paymaster submits the transaction on-chain and pays gas fees + - The paymaster may submit the transaction on-chain and pay gas fees - All of this happens automatically—you don't need to configure anything. + **React Native:** use [React Native Integration](/build/starkzap/react-native): Metro `withStarkzap`, optional polyfills entry, and **register** the native Cartridge adapter before connecting. Sponsored execution on native is often tied to **`feeMode: "sponsored"`** on the session wallet. ### Policies for Paymaster - Policies define what contracts and methods can be called in paymastered transactions. Users approve these policies once when connecting, and then all transactions matching those policies are automatically sponsored: + Policies define what contracts and methods can be called in paymastered transactions. Users approve these policies once when connecting; **calls that match** those policies can be sponsored: ```typescript const policies = [ @@ -190,14 +190,13 @@ Paymasters allow you to sponsor (pay for) transaction fees so users don't have t ]; ``` - Transactions that match these policies are automatically paymastered. Transactions outside these policies require user approval. + Calls outside those policies are not guaranteed to be paymastered and may need user-paid fees or additional approval. ### Register Session Without Signature - For paymastered transactions, sessions can be registered without requiring a signature from the user. The session is automatically registered when policies are approved, allowing seamless transaction execution: + For eligible paymastered transactions, sessions can sometimes be registered with reduced friction once policies are approved. Behavior can differ between **web** and **native** builds — follow [Cartridge Controller](/build/starkzap/integrations/cartridge-controller) and [React Native Integration](/build/starkzap/react-native). ```typescript - // When user connects and approves policies, session is automatically registered const onboard = await sdk.onboard({ strategy: OnboardStrategy.Cartridge, cartridge: { @@ -205,22 +204,21 @@ Paymasters allow you to sponsor (pay for) transaction fees so users don't have t { target: "0xTOKEN_CONTRACT", method: "transfer" }, ], }, + // Native flows may default to deploy: "never"; pass deploy: "if_needed" if you need deployment checks }); - // Session is now active and registered - // All transactions matching policies are automatically paymastered + const wallet = onboard.wallet; ``` ## Integration - Simply connect with Cartridge Controller and define policies. All transactions matching those policies are automatically sponsored: + Connect with Cartridge and define policies. **Matching** calls can be sponsored per Cartridge rules; on **native**, you may pass **`feeMode: "sponsored"`** where your wallet/session supports it. ```typescript import { StarkZap, OnboardStrategy } from "starkzap"; const sdk = new StarkZap({ network: "mainnet" }); - // Connect with Cartridge and define policies const onboard = await sdk.onboard({ strategy: OnboardStrategy.Cartridge, cartridge: { @@ -233,28 +231,26 @@ Paymasters allow you to sponsor (pay for) transaction fees so users don't have t const wallet = onboard.wallet; - // All transactions matching policies are automatically gasless! const tx = await wallet.execute([call]); - // No need to specify feeMode: "sponsored" - it's automatic await tx.wait(); ``` ## Key Advantages - - ✅ **Zero Configuration** - No API keys, no setup, just works - - ✅ **Automatic** - All transactions are sponsored by default - - ✅ **Perfect for Gaming** - Seamless, uninterrupted gameplay - - ✅ **Session-Based** - Users approve policies once, then transactions happen automatically + - ✅ **Low friction for games** - Policy-first flows after user approval + - ✅ **Session-based** - Approved paths can execute without a popup per tx + - ✅ **No AVNU key** for Cartridge-native sponsorship paths + - ✅ **Web and (when supported) React Native** - Same policy concepts; native needs adapter registration ## Comparison with AVNU Paymaster | Feature | Cartridge Paymaster | AVNU Paymaster | |---------|-------------------|----------------| - | **Setup** | Automatic (built-in) | Requires configuration | - | **API Key** | Not needed | Required for gasfree mode | - | **Use Case** | Gaming applications | General consumer apps | - | **Strategy** | Cartridge Controller only | Privy or Private Key | - | **Configuration** | None | SDK + optional backend proxy | + | **Setup** | Policies + Cartridge session | SDK `paymaster` config (+ API key for gasfree) | + | **API Key** | Not used for Cartridge path | Required for AVNU gasfree mode | + | **Use Case** | Gaming / session UX | Privy, private key, general sponsorship | + | **Strategy** | Cartridge (web or native) | Privy or Private Key (typical) | + | **Sponsorship scope** | Policy-matching session calls | Configured paymaster modes | ## Resources @@ -272,9 +268,9 @@ Paymasters allow you to sponsor (pay for) transaction fees so users don't have t - You need gasless mode (user pays in tokens) **Use Cartridge Paymaster if:** -- You're using Cartridge Controller strategy -- You're building gaming applications -- You want automatic gasless transactions with zero setup +- You're using **Cartridge** (web Controller or native session) +- You're building gaming applications with **explicit policies** +- You want paymastered execution for **matching** session calls after policy approval ## Next Steps diff --git a/build/starkzap/quick-start.mdx b/build/starkzap/quick-start.mdx index 5cd3b8a8b9..9a07c38568 100644 --- a/build/starkzap/quick-start.mdx +++ b/build/starkzap/quick-start.mdx @@ -158,7 +158,9 @@ The `sdk.onboard()` method lets you choose how users authenticate and connect th ``` - Best for gaming applications where users sign in with social accounts (Google, Twitter) or biometrics (Face ID, Touch ID). **Key advantage:** Cartridge includes a built-in paymaster that automatically sponsors (pays for) all transactions, so users never pay gas fees: + Best for gaming applications where users sign in with social accounts (Google, Twitter) or biometrics (Face ID, Touch ID). **Web:** uses `@cartridge/controller`. **React Native / Expo:** use `@starkzap/native`, Metro `withStarkzap`, optional `import "@starkzap/native/polyfills"`, and **register** the native Cartridge adapter before connecting — see [React Native Integration](/build/starkzap/react-native) and [Cartridge Controller](/build/starkzap/integrations/cartridge-controller). + + Cartridge can sponsor **policy-matching** calls via its paymaster/session stack; arbitrary transactions are not guaranteed to be gasless. ```typescript import { OnboardStrategy } from "starkzap"; @@ -168,6 +170,8 @@ The `sdk.onboard()` method lets you choose how users authenticate and connect th cartridge: { policies: [{ target: "0xCONTRACT", method: "transfer" }], }, + // On native Cartridge, you may want deploy: "never" (default in some flows) or "if_needed" explicitly + // deploy: "if_needed", }); ``` @@ -191,3 +195,4 @@ Now that you have a basic example working: 1. Learn about [Configuration](/build/starkzap/configuration) options 2. Explore different [Wallet Connection](/build/starkzap/connecting-wallets) methods 3. See how to [Execute Transactions](/build/starkzap/transactions) +4. Explore [Bridging](/build/starkzap/bridging) for Ethereum/Solana deposits into Starknet diff --git a/build/starkzap/react-native.mdx b/build/starkzap/react-native.mdx new file mode 100644 index 0000000000..b101134b07 --- /dev/null +++ b/build/starkzap/react-native.mdx @@ -0,0 +1,100 @@ +--- +title: React Native Integration +description: "Set up StarkZap in React Native/Expo projects with @starkzap/native and Metro configuration" +icon: mobile-screen-button +--- + +## Overview + +Use `@starkzap/native` when integrating StarkZap in React Native/Expo apps. +It re-exports the SDK API and adds a Metro helper (`@starkzap/native/metro`) for runtime polyfills and resolver compatibility. + +## 1) Install Packages + +Install the React Native package and required runtime peers: + +```bash +npm install @starkzap/native +npm install react-native-get-random-values fast-text-encoding buffer @ethersproject/shims +``` + +Optional dependencies by feature: + +```bash +# Ethereum bridge routes +npm install ethers + +# Solana bridge routes +npm install @solana/web3.js @hyperlane-xyz/sdk @hyperlane-xyz/registry @hyperlane-xyz/utils +``` + +## 2) Configure Metro + +Set up Metro once and wrap your config with `withStarkzap`: + +```javascript +// metro.config.js +const { getDefaultConfig } = require("expo/metro-config"); +const { withStarkzap } = require("@starkzap/native/metro"); + +const config = getDefaultConfig(__dirname); + +// Optional: add your own resolver overrides before wrapping. +module.exports = withStarkzap(config); +``` + + + `withStarkzap` injects required polyfills and resolver handling for StarkZap dependencies. You can rely on Metro alone, or add `import "@starkzap/native/polyfills"` as the **first** line in your entry file if you need explicit polyfills before other imports. + + +## 3) Initialize the SDK + +Import from `@starkzap/native` and use the same onboarding APIs as web: + +```typescript +import { StarkZap, OnboardStrategy, StarkSigner } from "@starkzap/native"; + +const sdk = new StarkZap({ network: "sepolia" }); + +const { wallet } = await sdk.onboard({ + strategy: OnboardStrategy.Signer, + account: { signer: new StarkSigner("0xYOUR_PRIVATE_KEY") }, + deploy: "if_needed", +}); +``` + +For Privy-based onboarding, see [Privy Integration](/build/starkzap/integrations/privy). + +## 4) Cartridge (native session) + +When your `@starkzap/native` version supports it, you can onboard with **Cartridge** using an in-app browser / deep-link **session** flow (not the web `@cartridge/controller` popup). + +1. **Register** the native Cartridge adapter **once** at app startup, before `connectCartridge()` or `onboard({ strategy: OnboardStrategy.Cartridge })`. Exact export names depend on your SDK version (for example `registerCartridgeTsAdapter` / `registerCartridgeNativeAdapter`). +2. Pass **policies** and/or a Cartridge **preset** that resolves policies for your chain (same concepts as [Cartridge Controller](/build/starkzap/integrations/cartridge-controller)). +3. Align `rpcUrl` / `chainId` (or `network`) on `new StarkZap({ ... })` with the session and paymaster you target. +4. **Deploy:** native Cartridge flows often default to **`deploy: "never"`** or recommend it when deployment semantics differ from the browser Controller. Pass **`deploy: "if_needed"`** explicitly if you need core-style deployment checks. +5. **Fees:** sponsored execution on native is tied to the session wallet (commonly **`feeMode: "sponsored"`** only for matching policy paths). + +See [Cartridge Controller](/build/starkzap/integrations/cartridge-controller) for policy and paymaster behavior, and the `examples/tic-tac-toe` app in the [Starkzap repository](https://github.com/keep-starknet-strange/starkzap) when available for a full Expo reference. + +## 5) External Wallet Providers (Optional) + +If your app uses WalletConnect/Reown for external wallets, initialize its RN compatibility layer at app startup: + +```typescript +import "@walletconnect/react-native-compat"; +``` + +Then pass the resulting providers into StarkZap external wallet adapters as described in [Bridging](/build/starkzap/bridging#connect-external-wallets). + + + If `connectCartridge` or Cartridge onboarding throws **not implemented**, your installed `@starkzap/native` build does not ship the native adapter yet — upgrade to a version that documents native Cartridge, or use **Signer** / **Privy** until then. + + +## Next Steps + +- [Quick Start](/build/starkzap/quick-start) +- [Connecting Wallets](/build/starkzap/connecting-wallets) +- [Bridging](/build/starkzap/bridging) +- [Troubleshooting](/build/starkzap/troubleshooting) +- [Examples](/build/starkzap/examples) diff --git a/build/starkzap/staking.mdx b/build/starkzap/staking.mdx index 14f7c8a7f2..05f8bd85cb 100644 --- a/build/starkzap/staking.mdx +++ b/build/starkzap/staking.mdx @@ -1,7 +1,7 @@ --- -title: Staking and Delegation +title: "Staking" description: "Enable users to stake tokens, earn passive income, and grow their holdings while supporting network security" -icon: chart-line +icon: "chart-line" --- ![Staking and Delegation hero](/assets/starkzap/staking-delegation.png) @@ -11,6 +11,7 @@ icon: chart-line Starkzap supports Starknet's native staking protocol. Validators run pools where delegators can stake tokens and earn rewards. **What users can do with staking:** + - 💰 **Earn passive income** - Stake tokens (like STRK) and earn rewards over time, similar to a savings account with interest - 🏦 **Support network security** - Stake tokens to help secure the Starknet network while earning rewards - 📈 **Grow their holdings** - Rewards compound over time, allowing users to increase their token holdings without additional purchases @@ -90,6 +91,7 @@ await tx.wait(); ``` This will: + 1. Approve the staking contract to spend your tokens (if needed) 2. Call `enter_delegation_pool` on the staking contract 3. Return a transaction you can track @@ -104,6 +106,7 @@ await tx.wait(); ``` `wallet.stake()` automatically: + - calls `enter_delegation_pool` for first-time stakers - calls `add_to_delegation_pool` for existing members @@ -131,6 +134,7 @@ if (position && !position.rewards.isZero()) { ``` **What users get:** Rewards are paid in the same token they staked (e.g., if you stake STRK, you earn STRK rewards). Users can claim rewards and either: + - Withdraw them to their wallet - Re-stake them to compound earnings (add them back to the pool) @@ -181,6 +185,7 @@ if (position) { ``` **What this shows users:** + - How much they've staked (their original investment) - How much they've earned in rewards (their passive income) - Their total position value (staked + rewards) @@ -232,6 +237,7 @@ await tx.wait(); ``` The `.stake()` method automatically: + - Calls `enter_delegation_pool` for new members - Calls `add_to_delegation_pool` for existing members @@ -305,6 +311,7 @@ async function checkRewards(wallet, poolAddress) { ## User Benefits Summary **What users can do with staking in your app:** + - 💰 **Earn passive income** - Stake tokens and earn rewards automatically, like interest on a savings account - 📈 **Grow their holdings** - Rewards accumulate over time, increasing their total token balance - 🔄 **Flexible management** - Add more tokens anytime, claim rewards when ready, exit when needed @@ -312,6 +319,7 @@ async function checkRewards(wallet, poolAddress) { - ⏱️ **Set and forget** - Once staked, tokens earn rewards in the background without daily management **Real-world use cases:** + - **Savings feature** - Let users "save" their tokens and earn interest - **Investment tool** - Enable users to grow their crypto holdings over time - **Rewards program** - Users can stake tokens to earn additional rewards @@ -330,8 +338,7 @@ async function checkRewards(wallet, poolAddress) { ### "Staking contract address is wrong in the config." -If you override `staking.contract`, ensure it matches the selected chain and pool. -If unsure, remove the override and use the built-in preset for your chain. +If you override `staking.contract`, ensure it matches the selected chain and pool. If unsure, remove the override and use the built-in preset for your chain. ### Pool Not Found @@ -341,4 +348,4 @@ Ensure you're using the correct pool contract address. Use `getStakerPools()` to - Learn about [Transaction Builder](/build/starkzap/transactions#transaction-builder) for batching operations - Explore [ERC20 Token Operations](/build/starkzap/erc20) -- Check the [API Reference](/build/starkzap/api-reference) for detailed method signatures +- Check the [API Reference](/build/starkzap/api-reference) for detailed method signatures \ No newline at end of file diff --git a/build/starkzap/swap.mdx b/build/starkzap/swap.mdx new file mode 100644 index 0000000000..ce87c27747 --- /dev/null +++ b/build/starkzap/swap.mdx @@ -0,0 +1,215 @@ +--- +title: Swaps +description: "Exchange one token for another using AVNU or Ekubo swap providers—get quotes, set slippage, and execute swaps" +icon: arrows-left-right +--- + +![Swapping hero](/assets/starkzap/swapping.png) + +## Overview + +Starkzap lets users swap one token for another through pluggable **swap providers**. The SDK supports **[AVNU](https://app.avnu.fi/en)** (DEX aggregator) and **[Ekubo](https://ekubo.org/starknet/swap)** (concentrated liquidity AMM). You get a quote, optionally set slippage tolerance, and execute the swap in one call. + +**What users can do with swaps:** +- 📊 **Get quotes** - See how much they will receive before swapping (amount out, price impact) +- 🔄 **Execute swaps** - Exchange tokens in a single transaction with optional slippage protection +- 🏪 **Choose providers** - Use [AVNU](https://app.avnu.fi/en) for aggregated routes or [Ekubo](https://ekubo.org/starknet/swap) for concentrated liquidity +- 📦 **Batch with other actions** - Run a swap then use the transaction builder for follow-up operations + +For **recurring buys (Dollar-Cost Averaging)**, see [DCA](/build/consumer-app-sdk/dca). + + + The wallet fills `chainId` and `takerAddress` from the connected wallet when you call `getQuote()` or `swap()`. You only need to pass `tokenIn`, `tokenOut`, and `amountIn` (and optionally `slippageBps` or `provider`). + + +## Configuration + +### Registering swap providers + +Register one or more swap providers when connecting the wallet (or at runtime). If you register multiple providers, set a default so `getQuote()` and `swap()` work without specifying `provider` on each request. + +**At connect / onboard:** + +```typescript +import { StarkZap, AvnuSwapProvider, EkuboSwapProvider } from "starkzap"; + +const sdk = new StarkZap({ network: "mainnet" }); + +const wallet = await sdk.connectWallet({ + account: { signer, accountClass: ArgentPreset }, + swapProviders: [ + new AvnuSwapProvider(), + new EkuboSwapProvider(), + ], + defaultSwapProviderId: "avnu", +}); +``` + +**At runtime (e.g. after Cartridge onboard):** + +```typescript +wallet.registerSwapProvider(new AvnuSwapProvider()); +wallet.registerSwapProvider(new EkuboSwapProvider()); +wallet.setDefaultSwapProvider("avnu"); +``` + +### Token presets + +Use the SDK token presets for `tokenIn` and `tokenOut` so addresses and decimals match the chain: + +```typescript +import { getPresets, mainnetTokens } from "starkzap"; + +const tokens = getPresets(wallet.getChainId()); +const STRK = tokens.STRK ?? mainnetTokens.STRK; +const USDC = tokens.USDC ?? mainnetTokens.USDC; +``` + +See [Bitcoin, Stablecoins, and Tokens](/build/consumer-app-sdk/erc20#token-presets) for more on token presets. + +## Getting a quote + +Call `wallet.getQuote()` with the swap input. The wallet uses the default swap provider unless you pass `provider`: + +```typescript +import { Amount } from "starkzap"; + +const quote = await wallet.getQuote({ + tokenIn: STRK, + tokenOut: USDC, + amountIn: Amount.parse("100", STRK), +}); + +console.log(quote.amountInBase); // input in base units +console.log(quote.amountOutBase); // expected output in base units +console.log(quote.priceImpactBps); // optional price impact (basis points) +console.log(quote.provider); // e.g. "avnu" +``` + +**With slippage and a specific provider:** + +```typescript +const quote = await wallet.getQuote({ + tokenIn: STRK, + tokenOut: USDC, + amountIn: Amount.parse("100", STRK), + slippageBps: 50n, // 0.5% + provider: "ekubo", +}); +``` + +### Quote shape + +```typescript +interface SwapQuote { + amountInBase: bigint; + amountOutBase: bigint; + routeCallCount?: number; + priceImpactBps?: bigint | null; + provider?: string; +} +``` + +## Executing a swap + +Use the same request shape as the quote. The wallet resolves the provider and builds the swap calls, then executes them. + +**Minimal swap:** + +```typescript +const tx = await wallet.swap({ + tokenIn: STRK, + tokenOut: USDC, + amountIn: Amount.parse("100", STRK), +}); +await tx.wait(); +``` + +**With slippage:** + +```typescript +const tx = await wallet.swap( + { + tokenIn: STRK, + tokenOut: USDC, + amountIn: Amount.parse("100", STRK), + slippageBps: 100n, // 1% + }, + { feeMode: "sponsored" } // optional execution options +); +await tx.wait(); +``` + +## Providers + +| Provider | Id | Description | +| -------- | ----- | ------------------------------------ | +| **[AVNU](https://app.avnu.fi/en)** | `avnu` | DEX aggregator; finds best route across liquidity sources | +| **[Ekubo](https://ekubo.org/starknet/swap)** | `ekubo` | Concentrated liquidity AMM; single-protocol routes | + +**List and switch providers:** + +```typescript +const ids = wallet.listSwapProviders(); +console.log(ids); // ["avnu", "ekubo"] + +// Use a specific provider for one request +const quote = await wallet.getQuote({ + tokenIn: STRK, + tokenOut: USDC, + amountIn: Amount.parse("100", STRK), + provider: "ekubo", +}); +``` + +## Batching with other operations + +There is no `.swap()` on the transaction builder; swaps are executed via `wallet.swap()`. You can run a swap and then batch follow-up actions in one transaction: + +```typescript +// 1. Execute swap +const txSwap = await wallet.swap({ + tokenIn: STRK, + tokenOut: USDC, + amountIn: Amount.parse("100", STRK), +}); +await txSwap.wait(); + +// 2. Then e.g. transfer or stake the received tokens in one batch +const tx = await wallet + .tx() + .transfer(USDC, [{ to: recipient, amount: Amount.parse("50", USDC) }]) + .send(); +await tx.wait(); +``` + +For **Dollar-Cost Averaging (recurring buys)** with AVNU or Ekubo, see [DCA](/build/consumer-app-sdk/dca). + +## Best practices + +1. **Always get a quote first** and show users the expected amount out and price impact before executing. +2. **Set slippage** (`slippageBps`) for volatile pairs or large sizes to avoid failed transactions. +3. **Use token presets** from `getPresets(chainId)` or `mainnetTokens` / `sepoliaTokens` so token addresses and decimals match the chain. +4. **Handle chain mismatch** — ensure the wallet's chain matches the swap provider's supported chains (AVNU and Ekubo support mainnet and Sepolia). + +## Troubleshooting + +### "No default swap provider configured" + +Register at least one swap provider and call `setDefaultSwapProvider(providerId)` (or pass `defaultSwapProviderId` when connecting). Alternatively, pass `provider: "avnu"` or `provider: "ekubo"` on every `getQuote()` / `swap()` call. + +### Chain or provider mismatch + +Ensure the wallet is on a chain supported by the chosen provider (e.g. `SN_MAIN` or `SN_SEPOLIA`). If you see a chain mismatch error, align the SDK network config with the RPC/wallet chain. + +### Swap returned no calls + +The provider could not build a route for the pair or amount. Try a different provider, a smaller amount, or another token pair. + +## Next steps + +- [DCA](/build/starkzap/dca) — Recurring buys (Dollar-Cost Averaging) with AVNU or Ekubo +- [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 transfers and other operations +- [API Reference](/build/starkzap/api-reference) — Full method signatures diff --git a/build/starkzap/transactions.mdx b/build/starkzap/transactions.mdx index ff7378f8f3..0ecffc4584 100644 --- a/build/starkzap/transactions.mdx +++ b/build/starkzap/transactions.mdx @@ -107,7 +107,7 @@ const tx = await wallet.execute([call]); // sponsored automatically - **Cartridge Controller:** If you're using Cartridge Controller as your wallet strategy, transactions are automatically sponsored by Cartridge's built-in paymaster. You don't need to configure AVNU Paymaster separately or set `feeMode: "sponsored"`—Cartridge handles all gas fees automatically when users approve policies. See the [Cartridge Controller Integration](/build/starkzap/integrations/cartridge-controller) guide for more details. + **Cartridge:** On **web** Controller and **native** session flows, matching calls can be paymastered per Cartridge's session / SNIP-9 rules after users approve **policies**. You typically do **not** configure AVNU for those paths. Arbitrary calls outside approved policies are not guaranteed to be sponsored. On React Native, sponsored execution is commonly tied to **`feeMode: "sponsored"`** on the session wallet. See [Cartridge Controller](/build/starkzap/integrations/cartridge-controller) and [React Native Integration](/build/starkzap/react-native). ## Preflight Simulation @@ -166,7 +166,7 @@ const tx = await wallet.execute(calls, { feeMode: "sponsored" }); The paymaster covers transaction fees. Requires paymaster configuration in SDK. - **Cartridge Controller users:** If you're using Cartridge Controller as your wallet strategy, transactions are automatically sponsored by Cartridge's built-in paymaster. You don't need to configure AVNU Paymaster separately—Cartridge handles all gas fees automatically when users approve policies. See the [Cartridge Controller Integration](/build/starkzap/integrations/cartridge-controller) guide for more details. + **Cartridge:** Policy-matching calls can be paymastered per Cartridge session rules; arbitrary calls are not guaranteed sponsored. You typically do not configure AVNU for Cartridge paths. See [Cartridge Controller](/build/starkzap/integrations/cartridge-controller) and [React Native Integration](/build/starkzap/react-native). ## Transaction Status diff --git a/build/starkzap/troubleshooting.mdx b/build/starkzap/troubleshooting.mdx index 183d8a5c8c..5c3eb712e3 100644 --- a/build/starkzap/troubleshooting.mdx +++ b/build/starkzap/troubleshooting.mdx @@ -36,17 +36,24 @@ const sdk = new StarkZap({ **Problem:** Errors related to random value generation or text encoding in React Native. -**Solution:** Install and import required polyfills in your app entrypoint: +**Solution:** Use the React Native setup guide and Metro wrapper, which handles required polyfills and resolver compatibility. + +1. Follow [React Native Integration](/build/starkzap/react-native) +2. Ensure your `metro.config.js` is wrapped with `withStarkzap(...)` +3. Clear Metro cache after dependency changes (`npx expo start -c`) + +If you still need manual installation checks, make sure these packages are present: ```bash -npm install react-native-get-random-values fast-text-encoding @ethersproject/shims +npm install react-native-get-random-values fast-text-encoding buffer @ethersproject/shims ``` -Then in your entrypoint (e.g., `index.js` or `App.tsx`): +If not using `withStarkzap`, import polyfills in your entrypoint (e.g. `index.js` or `App.tsx`): ```typescript import "react-native-get-random-values"; import "fast-text-encoding"; +import "@ethersproject/shims"; ``` ### Account Not Deployed Error @@ -105,6 +112,48 @@ app.post("/api/wallet/sign", async (req, res) => { 3. Verify network configuration matches Cartridge's supported networks 4. Check browser console for Cartridge-specific errors +### Bridge Token Loading Fails + +**Problem:** `sdk.getBridgingTokens()` throws an error or returns no tokens. + +**Solution:** +1. Verify the SDK chain config is correct (`SN_MAIN` vs `SN_SEPOLIA`) and matches your intended environment +2. Confirm network access to the token API endpoint used by the SDK +3. Install required optional deps for the chains you use: + - Ethereum routes: `ethers` + - Solana routes: `@solana/web3.js` (and Hyperlane packages for Solana bridge operations) + +```bash +npm install ethers @solana/web3.js @hyperlane-xyz/sdk @hyperlane-xyz/registry @hyperlane-xyz/utils +``` + +### OFT Bridge Fails with LayerZero API Key Error + +**Problem:** You see an error like: +`OFT bridging requires a LayerZero API key. Set "bridging.layerZeroApiKey"...` + +**Solution:** +1. Set `bridging.layerZeroApiKey` in `new StarkZap({ ... })` +2. Use a mainnet route for OFT/OFT-migrated bridge flows + +```typescript +const sdk = new StarkZap({ + network: "mainnet", + bridging: { + layerZeroApiKey: "YOUR_LAYERZERO_API_KEY", + }, +}); +``` + +### Bridge Deposit Fails with Chain Mismatch + +**Problem:** Deposit fails with errors indicating token chain and external wallet chain do not match. + +**Solution:** +1. Ensure the selected `BridgeToken.chain` matches the connected external wallet type +2. Ensure external wallet network and Starknet network pairing is valid (mainnet with mainnet, testnet with testnet) +3. Recreate connected external wallets with `ConnectedEthereumWallet.from(...)` / `ConnectedSolanaWallet.from(...)` after network switch + ### Amount Arithmetic Errors **Problem:** Getting errors when performing arithmetic on amounts. diff --git a/build/starkzap/tx-builder.mdx b/build/starkzap/tx-builder.mdx index f083d0adea..b8b0d968b2 100644 --- a/build/starkzap/tx-builder.mdx +++ b/build/starkzap/tx-builder.mdx @@ -94,21 +94,31 @@ console.log(`${calls.length} calls in this transaction`); ## Available Builder Methods -| Method | Description | -| ---------------------------------- | ---------------------------------------------- | -| `.add(...calls)` | Add raw `Call` objects | -| `.approve(token, spender, amount)` | ERC20 approval | -| `.transfer(token, transfers)` | ERC20 transfer(s) | -| `.stake(pool, amount)` | Smart stake (enter or add based on membership) | -| `.enterPool(pool, amount)` | Enter pool as new member | -| `.addToPool(pool, amount)` | Add to existing pool position | -| `.claimPoolRewards(pool)` | Claim staking rewards | -| `.exitPoolIntent(pool, amount)` | Start exit process | -| `.exitPool(pool)` | Complete exit after window | -| `.calls()` | Resolve all calls without sending | -| `.estimateFee()` | Estimate gas cost | -| `.preflight()` | Simulate the transaction | -| `.send(options?)` | Execute all calls atomically | +| Method | Description | +| -------------------------------------------------- | ---------------------------------------------- | +| `.add(...calls)` | Add raw `Call` objects | +| `.approve(token, spender, amount)` | ERC20 approval | +| `.transfer(token, transfers)` | ERC20 transfer(s) | +| `.stake(pool, amount)` | Smart stake (enter or add based on membership) | +| `.enterPool(pool, amount)` | Enter pool as new member | +| `.addToPool(pool, amount)` | Add to existing pool position | +| `.claimPoolRewards(pool)` | Claim staking rewards | +| `.exitPoolIntent(pool, amount)` | Start exit process | +| `.exitPool(pool)` | Complete exit after window | +| `.lendDeposit(request)` | Lending deposit (supply) — see [Lending](/build/consumer-app-sdk/lending) | +| `.lendWithdraw(request)` | Lending withdraw | +| `.lendWithdrawMax(request)` | Lending max withdraw | +| `.lendBorrow(request)` | Lending borrow | +| `.lendRepay(request)` | Lending repay | +| `.dcaCreate(request)` | Create a DCA (recurring buy) order — see [DCA](/build/consumer-app-sdk/dca) | +| `.dcaCancel(request)` | Cancel a DCA order | +| `.confidentialFund(confidential, details)` | Fund confidential account — see [Confidential](/build/consumer-app-sdk/confidential) | +| `.confidentialTransfer(confidential, details)` | Confidential transfer | +| `.confidentialWithdraw(confidential, details)` | Withdraw from confidential to public address | +| `.calls()` | Resolve all calls without sending | +| `.estimateFee()` | Estimate gas cost | +| `.preflight()` | Simulate the transaction | +| `.send(options?)` | Execute all calls atomically | ## Best Practices @@ -119,6 +129,9 @@ console.log(`${calls.length} calls in this transaction`); ## Next Steps -- Learn about [Transaction Execution](/build/starkzap/transactions) for direct execution methods -- Explore [Staking and Delegation](/build/starkzap/staking) for staking operations -- Check the [Bitcoin, Stablecoins, and Token](/build/starkzap/erc20) module for token operations +- Learn about [Transaction Execution](/build/consumer-app-sdk/transactions) for direct execution methods +- Explore [Staking and Delegation](/build/consumer-app-sdk/staking) for staking operations +- Check the [Bitcoin, Stablecoins, and Token](/build/consumer-app-sdk/erc20) module for token operations +- [Lending](/build/consumer-app-sdk/lending) — Batch deposit, withdraw, borrow, and repay with Vesu +- [Confidential Transfers](/build/consumer-app-sdk/confidential) — Fund, transfer, and withdraw with Tongo + diff --git a/docs.json b/docs.json index 1cdb470829..87e3b36a78 100644 --- a/docs.json +++ b/docs.json @@ -57,7 +57,6 @@ }, { "dropdown": "Cairo ↗", - "href": "https://www.starknet.io/cairo-book", "icon": "crow" }, { @@ -70,6 +69,7 @@ "pages": [ "build/starkzap/overview", "build/starkzap/installation", + "build/starkzap/react-native", "build/starkzap/quick-start" ] }, @@ -95,6 +95,11 @@ "build/starkzap/connecting-wallets", "build/starkzap/erc20", "build/starkzap/staking", + "build/starkzap/bridging", + "build/starkzap/swap", + "build/starkzap/dollar-cost-average", + "build/starkzap/lending", + "build/starkzap/confidential", "build/starkzap/transactions", "build/starkzap/tx-builder" ] @@ -919,8 +924,7 @@ }, { "dropdown": "Node API ↗", - "icon": "circle-nodes", - "href": "https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json" + "icon": "circle-nodes" } ] }, @@ -931,7 +935,6 @@ { "group": "Protocol", "pages": [ - "learn/protocol/intro", { "group": "Concepts", @@ -945,13 +948,12 @@ "learn/protocol/staking", "learn/protocol/state", "learn/protocol/strk", - "learn/protocol/transactions" + "learn/protocol/transactions" ] }, { "group": "Components", "pages": [ - "learn/protocol/sharp", "learn/protocol/snos", "learn/protocol/starkgate" @@ -959,7 +961,6 @@ } ] }, - { "group": "S-two book", "pages": [