### Install @ponziland/account Package Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/EXAMPLE.md This command installs the necessary @ponziland/account package using npm. Ensure you have Node.js and npm installed on your system. ```bash npm install @ponziland/account ``` -------------------------------- ### Quick Start: Clone and Run PonziLand Client (Bash) Source: https://github.com/runelabsxyz/ponziland/blob/main/readme.md This snippet shows how to clone the PonziLand repository, navigate to the client directory, install dependencies using Bun, and start the mainnet client locally. It's intended for developers who want to quickly set up and play the game. ```bash git clone git@github.com:RuneLabsxyz/PonziLand.git cd PonziLand/client bun install bun dev:mainnet ``` -------------------------------- ### Develop Svelte Project with npm Source: https://github.com/runelabsxyz/ponziland/blob/main/client/README.md This snippet shows how to start a development server for a Svelte project after installing dependencies. The `npm run dev` command starts the server, and the `-- --open` flag can be added to automatically open the application in a new browser tab. This assumes Node.js and npm are installed. ```bash npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### Install Project Dependencies using Bun Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Installs all necessary project dependencies using the Bun package manager. This command should be run after cloning the repository and navigating into the client directory. It ensures all required libraries are available for development. ```bash bun install ``` -------------------------------- ### Setup @ponziland/account in SvelteKit Root Layout Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/EXAMPLE.md This Svelte code snippet shows how to initialize the @ponziland/account setup in the root layout of a SvelteKit application. It utilizes the `setupAccount` function from the package and the `onMount` lifecycle hook to ensure the setup runs when the component is mounted. ```svelte ``` -------------------------------- ### Clone PonziLand Repository using Bash Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Clones the PonziLand repository from GitHub and navigates into the client directory. This is the first step to set up the project locally. No specific inputs are required beyond having git installed. ```bash git clone git@github.com:RuneLabsxyz/PonziLand.git cd PonziLand/client ``` -------------------------------- ### Dojo Project Build and Deployment Commands Source: https://github.com/runelabsxyz/ponziland/blob/main/contracts/README.md A sequence of commands to build the Dojo project, inspect the game world's state, migrate the world's schema and data, and finally start the Torii client to interact with the deployed world. The Torii command requires the world address obtained from the migration step. ```bash sozo build sozo inspect sozo migrate torii --world --http.cors_origins "*" ``` -------------------------------- ### Run Katana for Local Development Source: https://github.com/runelabsxyz/ponziland/blob/main/contracts/README.md Starts the Katana, a Starknet development network, in development mode with fees disabled. This is the first terminal to run for local development. ```bash katana --dev --dev.no-fee ``` -------------------------------- ### Setup Nix Development Environment Source: https://github.com/runelabsxyz/ponziland/blob/main/CLAUDE.md Commands to enter the Nix development shell and manage database migrations. This ensures all necessary tools are available for development. ```bash nix develop nix run .#migrate nix run .#new-migration ``` -------------------------------- ### Run PonziLand Front End Locally using Bun Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Starts the PonziLand front-end development server for the mainnet environment. After running this command, the application will be accessible at https://localhost:3000. This is crucial for local testing and development. ```bash bun dev:mainnet ``` -------------------------------- ### CSS Example of Non-Working Relative Paths Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/ASSETS.md Demonstrates CSS usage of relative paths for background images and fonts that will break when the package is installed via npm. This is an example of what NOT to do. ```css /* This will NOT work in npm packages */ background-image: url('../static/image.png'); @font-face { src: url('../static/fonts/font.ttf'); } ``` -------------------------------- ### Subscribe to All Lands Data (Svelte) Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Shows how to subscribe to updates from the `landStore` in Svelte to retrieve all land data. It includes lifecycle methods `onMount` and `onDestroy` to manage the subscription. ```typescript import { landStore } from '$lib/stores/store.svelte'; ``` ```svelte ``` -------------------------------- ### Use @ponziland/account Interface in Svelte Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/EXAMPLE.md This Svelte code demonstrates how to obtain the account manager using the `useAccount` hook from '@ponziland/account'. It then shows how to get the provider and account instances to potentially perform transactions. The `account.execute(...)` line is a placeholder for actual transaction logic. ```svelte ``` -------------------------------- ### Smart Contract Development Commands (Cairo/Dojo) Source: https://github.com/runelabsxyz/ponziland/blob/main/CLAUDE.md Commands for local development of Cairo smart contracts using the Dojo framework. Includes starting a local blockchain, building, testing, and running the Torii indexer. Also covers code formatting. ```bash cd contracts katana --dev --dev.fee # Start local blockchain sozo build # Build contracts sozo test # Run tests torii --world --http.cors_origins "*" scarb fmt # Format Cairo code scarb fmt --check # Check formatting ``` -------------------------------- ### Build Svelte Project for Production Source: https://github.com/runelabsxyz/ponziland/blob/main/client/README.md This command generates a production-ready build of the Svelte application. After running this, you can preview the production build using `npm run preview`. Deployment may require installing a Svelte adapter. ```bash npm run build ``` -------------------------------- ### Set Default State for New Widget in TypeScript Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Defines the default state for a new widget in the `widget.store.ts` file. This includes setting the initial position, dimensions, and open/minimized status of the widget when it's first registered or loaded. This ensures a consistent starting point for the widget's UI elements. ```typescript export const DEFAULT_WIDGETS_STATE: Record = { 'your-widget': { id: 'your-widget', type: 'your-widget', position: { x: 100, y: 100 }, dimensions: { width: 400, height: 300 }, isMinimized: false, isOpen: false, }, }; ``` -------------------------------- ### Create Svelte Library Project with 'sv' Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/README.md These commands are used to initialize a new Svelte library project. The 'npx sv create' command can be used to create a project in the current directory or a specified new directory. Ensure you have Node.js and npm installed. ```shell npx sv create # create a new project in my-app npx sv create my-app ``` -------------------------------- ### Use @ponziland/account Components in SvelteKit Pages Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/EXAMPLE.md This Svelte code demonstrates using various components and hooks from the @ponziland/account package within a SvelteKit page. It includes importing components like `SelectWalletModal` and `OnboardingWalletInfo`, using reactive declarations for wallet state (`address`, `isConnected`), and implementing functions for connecting and disconnecting the wallet. ```svelte {#if isConnected && address}

Connected: {shortenHex(padAddress(address), 4)}

{:else} {/if} ``` -------------------------------- ### JavaScript Example of Non-Working Direct Asset Imports Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/ASSETS.md Shows a JavaScript import statement using '?url' for an image asset. This method does not resolve correctly when the package is distributed via npm. ```javascript /* This will NOT work when distributed */ import imageUrl from '../../static/image.png?url'; ``` -------------------------------- ### Fetch On-Chain Land Data (Svelte) Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Provides a list of methods available on a land object obtained from `selectedLandWithActions`. These methods allow fetching various on-chain data points related to taxes, claims, auctions, yield, and land status. ```plaintext | Method | Description | | -------------------------- | ------------------------------ | | `getPendingTaxes()` | Fetch pending taxes | | `getNextClaim()` | Get information on next claim | | `getNukable()` | Time until land can be nuked | | `getCurrentAuctionPrice()` | Current auction price | | `getYieldInfo()` | Yield information for the land | | `getEstimatedNukeTime()` | Estimated time to nuke | | `getNeighbors()` | Neighboring land data | | `getLevelInfo()` | Details on current land level | ``` -------------------------------- ### Configure Account After Initialization (TypeScript) Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/README.md Updates the account configuration, such as the chain ID and RPC URL, after the initial setup. This function allows for dynamic changes to the connection parameters without re-initializing the entire account manager. ```typescript import { configureAccount } from '@ponziland/account'; configureAccount({ chainId: 'sepolia', rpcUrl: 'https://your-rpc-url.com' }); ``` -------------------------------- ### Access Selected Land Data and Actions (Svelte) Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Demonstrates how to import and use the `selectedLandWithActions` store in Svelte components. It shows how to derive owner status and access land details, and lists available on-chain methods for modifying land properties and claiming rewards. ```typescript import { selectedLandWithActions } from '$lib/stores/store.svelte'; ``` ```svelte
Pending taxes: {$land.getPendingTaxes()}
``` -------------------------------- ### Initialize Account Manager (Svelte) Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/README.md Initializes the account manager for Starknet wallet connection. It can be configured with a specific chain ID (mainnet or sepolia) and an RPC URL. This setup function must be called once before utilizing other library features. ```svelte ``` -------------------------------- ### Embedded Base64 Font Assets in JavaScript Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/ASSETS.md Illustrates how to embed font assets as base64 strings within JavaScript files. This approach ensures assets are self-contained and work across different project setups after npm installation. It includes the font data and CSS styles for its usage. ```javascript // src/lib/assets/fonts-embedded.js export const fonts = { myFont: 'data:font/truetype;base64,AAEAAAALAIAAAwAwR1NVQrD+...' }; export const fontStyles = " @font-face { font-family: 'MyFont'; src: url('${fonts.myFont}'); } "; ``` -------------------------------- ### GET /tokens Source: https://context7.com/runelabsxyz/ponziland/llms.txt Lists all authorized tokens that can be used for land purchases and staking. ```APIDOC ## GET /tokens ### Description Lists all authorized tokens that can be used for land purchases and staking. ### Method GET ### Endpoint `/tokens` ### Parameters #### Query Parameters None ### Request Example ```bash curl http://localhost:3000/tokens ``` ### Response #### Success Response (200) - An array of token objects. - **symbol** (string) - The symbol of the token (e.g., ETH, STRK). - **address** (string) - The contract address of the token. #### Response Example ```json [ { "symbol": "ETH", "address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" }, { "symbol": "STRK", "address": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d" }, { "symbol": "USDC", "address": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8" } ] ``` ``` -------------------------------- ### Registering a New Widget in Svelte Provider Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Demonstrates how to register a new widget within the main widget provider component in Svelte. It involves importing the widget component and conditionally rendering it based on its type. This code snippet is part of the `widget-provider.svelte` file. ```svelte {#each Object.entries($widgetsStore) as [id, widget]} {#if widget.isOpen} {#if widget.type === 'your-widget'} {/if} {/if} {/each} ``` -------------------------------- ### Svelte Component Structure for PonziLand Widgets Source: https://github.com/runelabsxyz/ponziland/blob/main/GAMEJAM.md Defines the basic structure of a Svelte component for a PonziLand widget. It includes a script section for TypeScript logic, a div for the widget's UI markup, and a style section for scoped CSS. This serves as a template for creating new custom widgets. ```svelte
``` -------------------------------- ### Query Neighbor Information Source: https://context7.com/runelabsxyz/ponziland/llms.txt Get information about adjacent lands for tax and yield calculations. ```APIDOC ## Query Neighbor Information ### Description Get information about adjacent lands for tax and yield calculations. ### Method (Implied action within smart contract, not a direct HTTP endpoint) ### Endpoint (N/A - Smart Contract Action) ### Parameters (N/A - Smart Contract Action) ### Request Example ```cairo // Get all 8 potential neighbors (or fewer for edge positions) let neighbors = actions.get_neighbors(100_u16); ``` ### Response #### Neighbors Response Returns Array: - LandOrAuction::Land(land) - neighbor is owned - LandOrAuction::Auction(auction) - neighbor in auction - LandOrAuction::None - no neighbor at position #### Unclaimed Taxes ```cairo // Calculate total unclaimed taxes from all neighbors let total_unclaimed = actions.get_unclaimed_taxes_per_neighbors_total(100_u16); // Get unclaimed taxes from specific neighbor let unclaimed_from_101 = actions.get_unclaimed_taxes_per_neighbor( claimer_location: 100_u16, payer_location: 101_u16 ); ``` ``` -------------------------------- ### Svelte Example of Overriding Default Image Prop Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/ASSETS.md Demonstrates how a consuming project can override default image assets in a Svelte component by passing a custom image URL via a prop. This provides flexibility for consumers of the npm package. ```svelte {/if} ``` -------------------------------- ### Publish Svelte Library to npm Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/README.md Steps to publish a Svelte library to npm. This involves updating the 'name' and potentially adding a 'license' field in 'package.json'. The 'npm publish' command then uploads the library. Ensure your package is correctly configured and versioned. ```shell # Go into the package.json and give your package the desired name through the "name" option. # Also consider adding a "license" field and point it to a LICENSE file. # To publish your library to [npm](https://www.npmjs.com): npm publish ``` -------------------------------- ### Manage Phantom Wallet State (Svelte) Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/README.md Provides access to reactive state variables for the Phantom (Solana) wallet, such as connection status and wallet address. It also exposes methods for connecting to and disconnecting from the Phantom wallet. ```svelte ``` -------------------------------- ### SQL Schema for Consumer Cursor Tracking Source: https://github.com/runelabsxyz/ponziland/blob/main/scraps/EVENT_STREAM.md Defines the unlogged table 'consumer_cursors' in SQL for tracking the last processed event ID by each consumer. This table is crucial for crash recovery and ensures event ordering. An index on 'updated_at' is included for optimization. ```sql CREATE UNLOGGED TABLE consumer_cursors ( consumer_id UUID PRIMARY KEY, last_event_id UUID NOT NULL, updated_at TIMESTAMP NOT NULL ); -- Index for faster lookups CREATE INDEX consumer_cursors_updated_at_idx ON consumer_cursors(updated_at); ``` -------------------------------- ### List Authorized Tokens - Rust Indexer API Source: https://context7.com/runelabsxyz/ponziland/llms.txt Provides a list of all tokens that are authorized for use in land purchases and staking within the Ponziland ecosystem. Includes the symbol and contract address for each token. ```bash curl http://localhost:3000/tokens # Response: [ { "symbol": "ETH", "address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" }, { "symbol": "STRK", "address": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d" }, { "symbol": "USDC", "address": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8" } ] ``` -------------------------------- ### BuildingLand Class for State Management Source: https://context7.com/runelabsxyz/ponziland/llms.txt Represents an owned land with full state management, providing typed access to land properties and stake information. It includes methods for creating land instances, updating stake information, and accessing properties like owner, level, sellPrice, stakeAmount, and token. It also offers a static `is` method for type checking. ```typescript // client/src/lib/api/land/building_land.ts import { BuildingLand } from '$lib/api/land/building_land'; import type { Land, LandStake } from '$lib/models.gen'; // Create from Dojo model const land: Land = { location: 100, owner: '0x123...', sell_price: 1000n, token_used: '0xabc...', block_date_bought: 1697500000n, level: { Zero: {} } }; const buildingLand = new BuildingLand(land); // Update stake information const landStake: LandStake = { location: 100, amount: 500n, neighbors_info_packed: 0n, accumulated_taxes_fee: 0n }; buildingLand.updateStake(landStake); // Access typed properties console.log(buildingLand.owner); // '0x123...' console.log(buildingLand.level); // 'Zero' | 'First' | 'Second' console.log(buildingLand.sellPrice); // CurrencyAmount instance console.log(buildingLand.stakeAmount); // CurrencyAmount instance console.log(buildingLand.token); // Token { symbol, address, decimals } // Check land type if (BuildingLand.is(someLand)) { // TypeScript knows someLand is BuildingLand const owner = someLand.owner; } ``` -------------------------------- ### Query Land Information Source: https://context7.com/runelabsxyz/ponziland/llms.txt Retrieve comprehensive land and stake data for gameplay calculations. ```APIDOC ## Query Land Information ### Description Retrieve comprehensive land and stake data for gameplay calculations. ### Method (Implied action within smart contract, not a direct HTTP endpoint) ### Endpoint (N/A - Smart Contract Action) ### Parameters (N/A - Smart Contract Action) ### Request Example ```cairo // Get complete land details let (land, land_stake) = actions.get_land(100_u16); ``` ### Response #### Land Properties - **location** (u16) - grid position - **owner** (ContractAddress) - **sell_price** (u256) - **token_used** (ContractAddress) - stake/sale token - **block_date_bought** (u64) - timestamp - **level** (Level enum) #### LandStake Properties - **amount** (u256) - staked tokens - **neighbors_info_packed** (u128) - packed neighbor data - **accumulated_taxes_fee** (u128) #### Yield Information ```cairo // Get yield information let yield_info = actions.get_neighbors_yield(100_u16); // Returns LandYieldInfo with per-neighbor yield rates and remaining stake time ``` ``` -------------------------------- ### TypeScript Currency Amount Handling and Operations Source: https://context7.com/runelabsxyz/ponziland/llms.txt Demonstrates the creation and manipulation of currency amounts using the CurrencyAmount utility. It covers creating amounts from unscaled and scaled values, performing arithmetic operations like addition, subtraction, multiplication, and division, and conducting comparisons between amounts. Dependencies include the CurrencyAmount class itself. ```typescript // client/src/lib/utils/CurrencyAmount.ts import { CurrencyAmount } from '$lib/utils/CurrencyAmount'; const token = { symbol: 'ETH', address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', decimals: 18 }; // Create from unscaled (wei) amount const amount = CurrencyAmount.fromUnscaled(1000000000000000000n, token); console.log(amount.toFixed(4)); // "1.0000" console.log(amount.toSignificant(3)); // "1.00" // Create from scaled (human) amount const amount2 = CurrencyAmount.fromScaled('1.5', token); console.log(amount2.unscaled); // 1500000000000000000n // Arithmetic operations const sum = amount.add(amount2); const diff = amount.subtract(amount2); const product = amount.multiply(2); const quotient = amount.divide(2); // Comparisons if (amount.greaterThan(amount2)) { console.log('Amount 1 is larger'); } ``` -------------------------------- ### Wrapped Contract Actions with Auto Approval Source: https://context7.com/runelabsxyz/ponziland/llms.txt Provides utility functions to execute game actions (buy, bid, increaseStake) with automatic ERC20 token approval. It simplifies contract interactions by handling the 'approve' call before executing the main action, ensuring tokens are approved for the required amounts. All methods return a transaction hash and wait for confirmation. ```typescript // client/src/lib/api/contracts/approve.ts import { wrappedActions } from '$lib/api/contracts/approve'; import { DojoProvider } from '@dojoengine/core'; const provider = new DojoProvider(/* ... */); const { actions } = await wrappedActions(provider); // Buy land with automatic token approval // Approves currentToken for buy price and tokenForSale for stake await actions.buy( account, 100n, // land_location '0xabc...', // tokenForSale 1000n, // sellPrice 500n, // amountToStake '0xdef...', // currentToken (token to pay with) 1000n // buyPrice (current price of land) ); // Bid on auction with automatic approval await actions.bid( account, 50n, // land_location '0xabc...', // tokenForSale 2000n, 800n, // amountToStake '0xdef...', // buyingToken 1500n // currentPrice (auction price) ); // Increase stake with automatic approval await actions.increaseStake( account, 100n, // land_location '0xabc...', // stakingToken 300n // amountToStake ); // All methods return transaction hash and wait for confirmation ``` -------------------------------- ### Proxy Paymaster Requests - Rust API Source: https://context7.com/runelabsxyz/ponziland/llms.txt This API endpoint proxies paymaster requests to the AVNU paymaster service using an API key. It forwards requests for gasless transactions and returns proxied responses or handles errors. ```bash curl -X POST http://localhost:3000/api/paymaster \ -H "Content-Type: application/json" \ -d '{ \ "method": "pm_getPaymasterData", \ "params": { \ "calls": [{ \ "to": "0x...", \ "selector": "0x...", \ "calldata": ["0x1", "0x2"] \ }] \ } \ }' # Response proxied from AVNU paymaster: { "paymasterData": { "paymaster": "0x...", "paymasterDataLength": 2, "paymasterData": ["0x...", "0x..."] } } # Error handling: # - 500 if proxy request fails # - Preserves original status codes from paymaster ```