### Install Dependencies and Configure .env Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/plinko.mdx Install Node.js dependencies for the app and setup directories, then copy the example .env file and populate it with the necessary values obtained from the package publishing step and external services. ```bash cd ../app pnpm install cd ../setup pnpm install cp .env.example .env ``` -------------------------------- ### Clone the OnlyFins Example App Repository Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/walrus/only-fins.mdx Clone the repository and navigate to the frontend directory to begin the setup process. ```bash $ git clone https://github.com/MystenLabs/onlyfins-example-app.git $ cd onlyfins-example-app/frontend ``` -------------------------------- ### Postgres Connection String Example Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-indexer-alt/README.md Example of a connection string for a PostgreSQL database installed via Homebrew. ```sh postgresql://$(whoami):postgres@localhost:5432/postgres ``` -------------------------------- ### ClickHouse Example README Source: https://github.com/mystenlabs/sui/blob/main/docs/content/develop/accessing-data/custom-indexer/bring-your-own-store.mdx The README file for the ClickHouse BYOS example project. It outlines the setup and functionality of the custom indexer. ```markdown # ClickHouse Sui Indexer Example This example demonstrates how to implement a custom data store for the Sui indexer using ClickHouse. ## Setup 1. **Install ClickHouse:** Follow the official ClickHouse installation guide. 2. **Run ClickHouse:** Ensure a ClickHouse instance is running. 3. **Create Database and Table:** ```sql CREATE DATABASE sui_indexer; USE sui_indexer; CREATE TABLE transactions ( tx_digest String, sequence_number UInt64, timestamp UInt64, sender String, gas_used UInt64, success Bool, move_event_type String, move_event_content String ); ``` ## Running the Indexer 1. **Clone the Sui repository:** ```bash git clone https://github.com/MystenLabs/sui.git cd sui ``` 2. **Build the indexer:** ```bash cargo build --release --package clickhouse-sui-indexer ``` 3. **Configure the indexer:** Create a `config.yaml` file with your ClickHouse connection details: ```yaml clickhouse: host: "localhost" port: 9000 database: "sui_indexer" user: "default" password: "" ``` 4. **Run the indexer:** ```bash ./target/release/clickhouse-sui-indexer --config config.yaml ``` ## Example Usage Once the indexer is running, you can query the `transactions` table in ClickHouse to retrieve indexed transaction data. ## Project Structure - `src/main.rs`: Main entry point for the indexer. - `src/store.rs`: Implementation of the custom store and connection traits. - `src/handlers.rs`: Handlers for processing checkpoint data. ``` -------------------------------- ### Configure Backend Environment Variables Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/event-indexer.mdx Install backend dependencies, copy the example environment file, and update it with your Package ID, Module Name, Private Key, and Users Counter Object ID obtained from the publish step. ```bash cd ../backend npm install cp env.example .env ``` -------------------------------- ### Configure Frontend Environment Variables Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/nft-app.mdx Navigate to the frontend application directory, install dependencies, copy the example environment file, and edit it with the published contract details. ```bash cd ../../app/my-first-sui-dapp pnpm install cp .env.example .env ``` -------------------------------- ### Install libpq-dev on Linux Source: https://github.com/mystenlabs/sui/blob/main/docs/content/snippets/install-prereqs.mdx Install the development package for libpq using the apt package manager. This is required for specific Sui start options. If libpq-dev is not available, find an equivalent package. ```sh $ sudo apt-get install libpq-dev ``` -------------------------------- ### Install site-builder CLI Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/walrus/sui-stack-walrus-sites.mdx Installs the `site-builder` CLI using `suiup`. Ensure `$HOME/.local/bin` is in your PATH after installation. ```bash $ curl -sSfL https://raw.githubusercontent.com/Mystenlabs/suiup/main/install.sh | sh $ suiup install site-builder@mainnet ``` -------------------------------- ### Configure and Start Relayer Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/messaging/chat-app.mdx Navigate to the relayer directory, copy the example environment file, and fill in the SUI_RPC_URL and GROUPS_PACKAGE_ID. Then, run the relayer using 'cargo run'. The relayer defaults to http://localhost:3000. ```bash $ cd relayer $ cp .env.example .env # fill in SUI_RPC_URL (https://fullnode.testnet.sui.io:443 for testnet) and GROUPS_PACKAGE_ID (Deployed Groups SDK package ID) $ cargo run ``` -------------------------------- ### Setup Sui Indexer Database and Migrations Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-indexer-alt/README.md Installs the Diesel CLI for PostgreSQL and sets up the database with migrations for the sui-indexer-alt. Ensure you are in the correct directory. ```sh # Install the CLI (if not already installed) car go install diesel_cli --no-default-features --features postgres # Use it to create the database and run migrations on it. diesel setup \ --database-url="postgres://postgres:postgrespw@localhost:5432/sui_indexer_alt" \ --migration-dir ../sui-indexer-alt-schema/migrations ``` -------------------------------- ### Clone Asset Tokenization Repository Source: https://github.com/mystenlabs/sui/blob/main/docs/content/onchain-finance/tokenized-assets/deploy-tokenized-asset.mdx Clone the asset-tokenization repository and navigate to the setup directory. Then, copy the environment template and install dependencies. ```sh git clone https://github.com/MystenLabs/asset-tokenization.git cd asset-tokenization cp setup/.env.template setup/.env cd setup && npm install ``` -------------------------------- ### Configure Chat App Frontend Environment Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/messaging/chat-app.mdx Install dependencies, copy the example environment file, and configure frontend settings by editing the .env file. This includes network, RPC, GraphQL, and relayer URLs. ```bash $ cd ../chat-app $ pnpm install $ cp .env.example .env ``` -------------------------------- ### Install Sui CLI and Testnet Toolchain Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/onboarding/sui-install.mdx Use this command to install the Sui CLI and the Testnet-compatible toolchain. It first downloads and executes an installation script, then installs the specified Sui version. ```bash curl -sSfL https://raw.githubusercontent.com/MystenLabs/sui/main/install.sh | sh suiup install sui@testnet ``` -------------------------------- ### Install site-builder CLI Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/walrus/sui-stack-walrus-sites.mdx Installs the site-builder CLI for managing Walrus Sites. Ensure you have suiup installed and your PATH is configured. ```bash suiup install site-builder@mainnet ``` -------------------------------- ### Clone Nautilus Bootcamp Repo Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/nautilus/nautilus-weather-oracle.mdx Clone the specified branch of the sui-move-bootcamp repository to get started with the Nautilus example. ```bash git clone -b solution https://github.com/MystenLabs/sui-move-bootcamp.git cd sui-move-bootcamp/K4 ``` -------------------------------- ### Setup Database Source: https://github.com/mystenlabs/sui/blob/main/examples/trading/api/README.md Execute this command to set up the project's database. ```bash pnpm db:setup:dev ``` -------------------------------- ### Inline Link to Sui Documentation Section Source: https://github.com/mystenlabs/sui/blob/main/docs/content/references/contribute/style-guide.mdx Use keywords from the target topic title for inline links. This example shows linking to the prerequisites section of the Sui installation guide. ```markdown Before you install Sui, make sure to install the [prerequisites](/getting-started/onboarding/sui-install#prerequisites). ``` -------------------------------- ### Start Development Preview Source: https://github.com/mystenlabs/sui/blob/main/docs/README.md Use this command to start a local development server for previewing documentation changes. The server watches for file changes and updates the UI automatically. ```shell pnpm start ``` -------------------------------- ### Initialize Diesel Project Source: https://github.com/mystenlabs/sui/blob/main/docs/content/develop/accessing-data/custom-indexer/build.mdx Set up the necessary directory structure for Diesel migrations by running the 'diesel setup' command with your database URL. ```bash $ diesel setup --database-url $PSQL_URL ``` -------------------------------- ### Get Native Epoch Timestamp (ms) - Sui Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui/tx_context.md A native function to get the epoch start time in milliseconds. This is an internal implementation detail. ```move fun native_epoch_timestamp_ms(): u64 ``` ```move native fun native_epoch_timestamp_ms(): u64; ``` -------------------------------- ### Initialize DeepBookClient with Extensions Source: https://github.com/mystenlabs/sui/blob/main/docs/content/onchain-finance/deepbook-margin-sdk/deepbook-margin-sdk.mdx Set up a DeepBook client by extending a Sui client with DeepBook functionality. This example demonstrates initializing the client with a private key and environment configuration. ```tsx import { deepbook, type DeepBookClient } from '@mysten/deepbook-v3'; import type { ClientWithExtensions } from '@mysten/sui/client'; import { decodeSuiPrivateKey } from '@mysten/sui/cryptography'; import { SuiGrpcClient } from '@mysten/sui/grpc'; import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'; class DeepBookMarginTrader { client: ClientWithExtensions<{ deepbook: DeepBookClient }>; keypair: Ed25519Keypair; constructor(privateKey: string, env: 'testnet' | 'mainnet') { this.keypair = this.getSignerFromPK(privateKey); this.client = new SuiGrpcClient({ network: env, baseUrl: env === 'mainnet' ? 'https://fullnode.mainnet.sui.io:443' : 'https://fullnode.testnet.sui.io:443', }).$extend( deepbook({ address: this.getActiveAddress(), }), ); } getSignerFromPK = (privateKey: string): Ed25519Keypair => { const { scheme, secretKey } = decodeSuiPrivateKey(privateKey); if (scheme === 'ED25519') return Ed25519Keypair.fromSecretKey(secretKey); throw new Error(`Unsupported scheme: ${scheme}`); }; getActiveAddress() { return this.keypair.toSuiAddress(); } } ``` -------------------------------- ### Reset and Setup Database Source: https://github.com/mystenlabs/sui/blob/main/examples/trading/api/README.md Reset the database to its initial state and then set it up. ```bash pnpm db:reset:dev && pnpm db:setup:dev ``` -------------------------------- ### Get Epoch Start Timestamp (ms) - Sui Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui/tx_context.md Returns the start time of the current epoch as a Unix timestamp in milliseconds. Requires a transaction context. ```move public fun epoch_timestamp_ms(_self: &sui::tx_context::TxContext): u64 ``` ```move public fun epoch_timestamp_ms(_self: &TxContext): u64 { native_epoch_timestamp_ms() } ``` -------------------------------- ### Start the Development Server Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/dapp-kit-frontend.mdx Start the DApp development server using pnpm. ```bash pnpm dev ``` -------------------------------- ### Get Withdrawal Limit Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui/funds_accumulator.md Returns the remaining limit of a withdrawal. No setup is required. ```move public fun withdrawal_limit<T: store>(withdrawal: &sui::funds_accumulator::Withdrawal<T>): u256 ``` ```move public fun withdrawal_limit<T: store>(withdrawal: &Withdrawal<T>): u256 { withdrawal.limit } ``` -------------------------------- ### Manual Indexer Setup (`main.rs`) Source: https://github.com/mystenlabs/sui/blob/main/docs/content/develop/accessing-data/custom-indexer/bring-your-own-store.mdx Sets up the manual indexer with a ClickHouse backend. This file demonstrates how to initialize and run the custom indexer. ```rust use anyhow::Result; use clap::Parser; use clickhouse_sui_indexer::store::ClickHouseStore; use sui_indexer::cli::Args; use sui_indexer::indexer::Indexer; #[derive(Parser, Debug)] #[clap(name = "ClickHouse Sui Indexer", version = "0.1.0", author = "Mysten Labs")] struct CliArgs { #[clap(flatten)] args: Args, #[clap(long, env = "CLICKHOUSE_HOST", default_value = "localhost")] clickhouse_host: String, #[clap(long, env = "CLICKHOUSE_PORT", default_value = "9000")] clickhouse_port: u16, #[clap(long, env = "CLICKHOUSE_DATABASE", default_value = "sui_indexer")] clickhouse_database: String, #[clap(long, env = "CLICKHOUSE_USER", default_value = "default")] clickhouse_user: String, #[clap(long, env = "CLICKHOUSE_PASSWORD", default_value = "")] clickhouse_password: String, } #[tokio::main] async fn main() -> Result<()> { let cli_args = CliArgs::parse(); let store = ClickHouseStore::new( &cli_args.clickhouse_host, cli_args.clickhouse_port, &cli_args.clickhouse_database, &cli_args.clickhouse_user, &cli_args.clickhouse_password, ) .await; let indexer = Indexer::new(cli_args.args.network, Box::new(store)); indexer.start().await } ``` -------------------------------- ### Get Withdrawal Owner Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui/funds_accumulator.md Returns the owner's address of a withdrawal. No setup is required. ```move public fun withdrawal_owner<T: store>(withdrawal: &sui::funds_accumulator::Withdrawal<T>): address ``` ```move public fun withdrawal_owner<T: store>(withdrawal: &Withdrawal<T>): address { withdrawal.owner } ``` -------------------------------- ### Get Epoch Start Timestamp (epoch_timestamp_ms) Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/on-chain-primitives/access-time.mdx Retrieve the Unix timestamp in milliseconds for the start of the current epoch. This function from the `sui::tx_context` module is suitable for all transactions, including those not using consensus. ```move /// Returns the timestamp of the start of the current epoch in milliseconds. public fun epoch_timestamp_ms(ctx: &TxContext): u64 { ctx.epoch_timestamp_ms } ``` -------------------------------- ### Main Function Setup Source: https://github.com/mystenlabs/sui/blob/main/docs/content/develop/accessing-data/custom-indexer/build.mdx Sets up the main function to initialize and run the custom Sui indexer, integrating the handler and database connection. ```rust use dotenv::dotenv;\nuse std::sync::Arc;\nuse sui_indexer_alt_framework::run_indexer;\n\nmod models;\nmod handlers;\n\n#[tokio::main]\nasync fn main() {\n dotenv().ok();\n\n let handler = Arc::new(handlers::TransactionDigestHandler);\n run_indexer(handler).await.expect("Indexer failed to run");\n}\n ``` -------------------------------- ### Example JSON Span Log Output Source: https://github.com/mystenlabs/sui/blob/main/docs/content/operators/observability.mdx This example shows the JSON format for detailed span logs, including start, end, and event annotations for transaction processing. It is generated when the SUI_JSON_SPAN_LOGS environment variable is defined. ```sh {"v":0,"name":"sui","msg":"[PROCESS_CERT - START]","level":20,"hostname":"Evan-MLbook.lan","pid":51425,"time":"2022-03-08T22:48:11.241421Z","target":"sui_core::authority_server","line":67,"file":"sui_core/src/authority_server.rs","tx_digest":"t#d1385064287c2ad67e4019dd118d487a39ca91a40e0fd8e678dbc32e112a1493"} {"v":0,"name":"sui","msg":"[PROCESS_CERT - EVENT] Read inputs for transaction from DB","level":20,"hostname":"Evan-MLbook.lan","pid":51425,"time":"2022-03-08T22:48:11.246688Z","target":"sui_core::authority","line":393,"file":"sui_core/src/authority.rs","num_inputs":2,"tx_digest":"t#d1385064287c2ad67e4019dd118d487a39ca91a40e0fd8e678dbc32e112a1493"} {"v":0,"name":"sui","msg":"[PROCESS_CERT - EVENT] Finished execution of transaction with status Success { gas_used: 18 }","level":20,"hostname":"Evan-MLbook.lan","pid":51425,"time":"2022-03-08T22:48:11.246759Z","target":"sui_core::authority","line":409,"file":"sui_core/src/authority.rs","gas_used":18,"tx_digest":"t#d1385064287c2ad67e4019dd118d487a39ca91a40e0fd8e678dbc32e112a1493"} {"v":0,"name":"sui","msg":"[DB_UPDATE_STATE - START]","level":20,"hostname":"Evan-MLbook.lan","pid":51425,"time":"2022-03-08T22:48:11.247888Z","target":"sui_core::authority","line":430,"file":"sui_core/src/authority.rs","tx_digest":"t#d1385064287c2ad67e4019dd118d487a39ca91a40e0fd8e678dbc32e112a1493"} {"v":0,"name":"sui","msg":"[DB_UPDATE_STATE - END]","level":20,"hostname":"Evan-MLbook.lan","pid":51425,"time":"2022-03-08T22:48:11.248114Z","target":"sui_core::authority","line":430,"file":"sui_core/src/authority.rs","tx_digest":"t#d1385064287c2ad67e4019dd118d487a39ca91a40e0fd8e678dbc32e112a1493","elapsed_milliseconds":0} {"v":0,"name":"sui","msg":"[PROCESS_CERT - END]","level":20,"hostname":"Evan-MLbook.lan","pid":51425,"time":"2022-03-08T22:48:11.248688Z","target":"sui_core::authority_server","line":67,"file":"sui_core/src/authority_server.rs","tx_digest":"t#d1385064287c2ad67e4019dd118d487a39ca91a40e0fd8e678dbc32e112a1493","elapsed_milliseconds":2} ``` -------------------------------- ### Install Script Dependencies Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/lootbox-ctf.mdx Navigate to the scripts directory, install dependencies using pnpm, and initialize a keypair. ```bash cd scripts pnpm install pnpm init-keypair ``` -------------------------------- ### Example `a::cup` Module Source: https://github.com/mystenlabs/sui/blob/main/external-crates/move/documentation/book/src/method-syntax.md Defines a generic `Cup` struct and associated functions for borrowing, getting, and swapping its value. ```move module a::cup { public struct Cup(T) has copy, drop, store; public fun cup_borrow(c: &Cup): &T { &c.0 } public fun cup_value(c: Cup): T { let Cup(t) = c; t } public fun cup_swap(c: &mut Cup, t: T) { c.0 = t; } } ``` -------------------------------- ### Run Development Server Source: https://github.com/mystenlabs/sui/blob/main/dapps/kiosk/README.md Starts the development server using pnpm turbo. This command is used after installing dependencies. ```sh pnpm turbo dev ``` -------------------------------- ### Configure Backend Environment Variables Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/walrus/only-fins.mdx Copy the example environment file and edit it to include author private keys and the published package ID. ```bash $ cd ../../../backend/ $ cp .env.example .env ``` ```dotenv AUTHOR_1_PRIVATE_KEY=YOUR_ED25519_PRIVATE_KEY AUTHOR_2_PRIVATE_KEY=YOUR_ED25519_PRIVATE_KEY AUTHOR_3_PRIVATE_KEY=YOUR_ED25519_PRIVATE_KEY PACKAGE_ID=PACKAGE_ID_FROM_STEP_4 ``` -------------------------------- ### Mermaid Diagram Example Source: https://github.com/mystenlabs/sui/blob/main/docs/content/references/contribute/diagram-standards.mdx A basic flowchart example using Mermaid syntax. This diagram illustrates a simple transaction submission and validation process. No setup is required as the Sui documentation site automatically applies the brand theme. ```mermaid flowchart LR A[SUBMIT TRANSACTION] --> B{Valid?} B -->|Yes| C[EXECUTE TRANSACTION] B -->|No| D[REJECT TRANSACTION] ``` -------------------------------- ### Install Sui Replay Tool Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-replay-2/README.md Install the replay tool binary to ~/.cargo/bin. This command clones the repository and builds the tool. ```bash cargo install --git https://github.com/MystenLabs/sui sui-replay-2 ``` -------------------------------- ### Run Remote Reader Example Source: https://github.com/mystenlabs/sui/blob/main/examples/custom-indexer/rust/README.md Execute the remote reader binary using Cargo to start the remote indexing process. ```bash cargo run --bin remote_reader ``` -------------------------------- ### Example: Set up a take profit order Source: https://github.com/mystenlabs/sui/blob/main/docs/content/onchain-finance/deepbook-margin-sdk/tpsl.mdx Example code for setting up a take profit order using the `addConditionalOrder` function. ```APIDOC ## Example: Set up a take profit order ### Description This example demonstrates how to create a take profit order that sells when the price rises above a specified threshold. ### Method POST (Implied by `addConditionalOrder` usage within a transaction) ### Endpoint (Not directly specified, part of a transaction) ### Parameters (Refer to `addConditionalOrder` and `newPendingMarketOrder` for detailed parameters) ### Request Example ```typescript // Example: Create a take profit order that sells when price rises above 5.0 const setTakeProfit = (tx: Transaction) => { const managerKey = 'MARGIN_MANAGER_1'; traderClient.marginTPSL.addConditionalOrder({ marginManagerKey: managerKey, conditionalOrderId: 2, triggerBelowPrice: false, // Trigger when price rises above triggerPrice: 5.0, pendingOrder: { clientOrderId: 101, price: 5.0, // Limit order at 5.0 quantity: 50, isBid: false, // Sell order payWithDeep: true, }, })(tx); }; ``` ### Response (Modifies the transaction object) ``` -------------------------------- ### EVM Contracts Quick Start Source: https://github.com/mystenlabs/sui/blob/main/bridge/SUI_NATIVE_BRIDGE_PRIMER.md Commands to navigate to the EVM contracts directory, update Solidity, build, and run tests. ```bash cd bridge/evm && forge soldeer update && forge build && forge test ``` -------------------------------- ### Run React Development Server Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/onboarding/app-frontends.mdx Start the React application in your local development environment. Ensure you have the necessary dependencies installed. ```sh $ pnpm dev ``` -------------------------------- ### Run AlloyDB Omni in Docker Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-indexer-alt/README.md Starts an AlloyDB Omni instance in a Docker container. Requires Docker to be installed and running. ```sh docker run --detach --publish 5433:5432 --env POSTGRES_PASSWORD=postgres_pw google/alloydbomni ``` -------------------------------- ### Clone Hello, World! Project Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/onboarding/hello-world.mdx Clone the 'sui-stack-hello-world' repository and navigate to the 'hello-world' Move package directory. ```bash $ git clone \ https://github.com/MystenLabs/sui-stack-hello-world.git $ cd sui-stack-hello-world/move/hello-world ``` -------------------------------- ### Get Maximum u32 Value Source: https://github.com/mystenlabs/sui/blob/main/external-crates/move/crates/move-stdlib/docs/std/u32.md Use this macro to retrieve the maximum possible value for a u32 type. No setup is required. ```move public macro fun max_value(): u32 { 0xFFFF_FFFF } ``` -------------------------------- ### Run Sui Client Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/onboarding/configure-sui-client.mdx Initiate the Sui CLI. If a client.yaml file exists, it will display help output. Otherwise, it prompts to create a new configuration file. ```bash $ sui client ``` -------------------------------- ### Obtain Private Key Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/enoki/ticketing-poc.mdx Commands to get your Sui address and convert it to a private key format for use in the setup script. ```bash $ sui client active-address $ sui keytool convert
``` -------------------------------- ### Start the Frontend Development Server Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/enoki/ticketing-poc.mdx Command to start the local development server for the frontend application. ```bash $ pnpm dev ``` -------------------------------- ### Get Immutable Kiosk Extension Storage Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui/kiosk_extension.md Provides immutable access to the extension's storage. This can only be called by the extension itself, provided it is installed. ```move public fun storage<Ext: drop>(_ext: Ext, self: &sui::kiosk::Kiosk): &sui::bag::Bag ``` ```move public fun storage<Ext: drop>(_ext: Ext, self: &Kiosk): &Bag { assert!(is_installed<Ext>(self), EExtensionNotInstalled); &extension<Ext>(self).storage } ``` -------------------------------- ### Configure Environment Variables for zkLogin Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/zklogin-integration/zklogin-demo.mdx Copy the example environment file and configure network, RPC URL, salt, and OAuth details. ```bash cp .env.example .env ``` -------------------------------- ### Example Consistent Store Run Command Source: https://github.com/mystenlabs/sui/blob/main/docs/content/operators/data-management/indexer-stack-setup.mdx An example of the run command with specific values for configuration file, database path, and remote store URL. ```sh $ sui-indexer-alt-consistent-store run \ --config consistent-store.toml \ --database-path /path/to/rocksdb \ --remote-store-url https://checkpoints.mainnet.sui.io ``` -------------------------------- ### Valid Variable Name Examples Source: https://github.com/mystenlabs/sui/blob/main/external-crates/move/documentation/book/src/variables.md Move variable names can include underscores, letters, and digits, but must start with an underscore or a lowercase letter. ```move // all valid let x = e; let _x = e; let _A = e; let x0 = e; let xA = e; let foobar_123 = e; // all invalid let X = e; // ERROR! let Foo = e; // ERROR! ``` -------------------------------- ### Start Development Server (Bash) Source: https://github.com/mystenlabs/sui/blob/main/examples/trading/frontend/README.md Command to start the dApp in development mode. This command is typically used during the development phase to see changes live. ```bash pnpm dev ``` -------------------------------- ### Get Epoch Start Timestamp Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui_system/sui_system_state_inner.md Returns the Unix timestamp marking the beginning of the current epoch. This is accessed directly from the system state object. ```move public(package) fun epoch_start_timestamp_ms(self: &SuiSystemStateInnerV2): u64 { self.epoch_start_timestamp_ms } ``` -------------------------------- ### Start Sui Full Node Source: https://github.com/mystenlabs/sui/blob/main/docker/fullnode/README.md Initiate the Sui fullnode service using Docker Compose. Assumes Docker Compose V2 is installed. ```shell docker compose up ``` -------------------------------- ### Run Benchmark Server Source: https://github.com/mystenlabs/sui/blob/main/crates/anemo-benchmark/README.md Starts the benchmark server on the specified port. This is the first step before running client invocations. ```bash target/debug/anemo-benchmark --port 5556 ``` -------------------------------- ### Clone Sui Move Bootcamp Repository Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/event-indexer.mdx Clone the Sui Move bootcamp repository and navigate to the K1 directory to start the setup process. ```bash git clone https://github.com/MystenLabs/sui-move-bootcamp.git cd sui-move-bootcamp/K1 ``` -------------------------------- ### Start Sui Full Node Source: https://github.com/mystenlabs/sui/blob/main/docs/content/operators/full-node/sui-full-node.mdx Run the sui-node binary with your fullnode.yaml configuration file to start a full node. It is recommended to use a recent snapshot instead of syncing from genesis. ```bash sui-node --config-path fullnode.yaml ``` -------------------------------- ### Build Output Example Source: https://github.com/mystenlabs/sui/blob/main/docs/content/references/cli/move.mdx Example output from the 'sui move build' command, indicating the inclusion of dependencies and the build process. ```sh INCLUDING DEPENDENCY Sui INCLUDING DEPENDENCY MoveStdlib BUILDING smart_contract_test ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/walrus/only-fins.mdx Install the necessary frontend dependencies using pnpm. ```bash $ pnpm install ``` -------------------------------- ### Build Twitter Example and Get PCRs Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/nautilus/using-nautilus.mdx Build the 'twitter-example' application within Nautilus and then display the generated PCR values. These PCRs are crucial for enclave registration. ```sh cd nautilus/ make ENCLAVE_APP=twitter-example cat out/nitro.pcrs ``` -------------------------------- ### Create Margin Pool Example Source: https://github.com/mystenlabs/sui/blob/main/docs/content/onchain-finance/deepbook-margin-sdk/maintainer.mdx Example demonstrating how to create a margin pool. ```APIDOC ## Example: Create a Margin Pool ### Description This example shows how to create a new margin pool for a given asset, configuring its supply cap, utilization rates, and interest rate parameters. ### Method POST (or relevant transaction submission method) ### Endpoint (Not applicable for client-side transaction building) ### Parameters (These are parameters for building the transaction, not API request parameters) ### Request Example ```typescript // Example: Create a USDC margin pool createUsdcMarginPool = (tx: Transaction) => { const coinKey = 'USDC'; // Create pool configuration const poolConfig = tx.add( this.maintainerContract.newProtocolConfig( coinKey, { supplyCap: 10_000_000, // 10M USDC maxUtilizationRate: 0.8, // 80% referralSpread: 0.1, // 10% protocol spread minBorrow: 100, // 100 USDC minimum }, { baseRate: 0.02, // 2% base rate baseSlope: 0.1, // 10% slope before kink optimalUtilization: 0.8, // 80% kink point excessSlope: 1.0, // 100% slope after kink }, ), ); // Create the pool tx.add(this.maintainerContract.createMarginPool(coinKey, poolConfig)); }; ``` ### Response (Transaction object is returned, not a direct API response) #### Success Response (200) (N/A) #### Response Example (N/A) ``` -------------------------------- ### Clone and Deploy Walrus Example Site Source: https://github.com/mystenlabs/sui/blob/main/docs/content/sui-stack/walrus/sui-stack-walrus-sites.mdx Clone the Walrus sites repository and deploy the example snake site to Testnet using the `site-builder` tool. Specify the number of epochs to determine the site's availability duration. ```bash git clone https://github.com/MystenLabs/walrus-sites.git && cd walrus-sites site-builder --context=testnet deploy examples/snake --epochs 1 ``` -------------------------------- ### Run Local Jaeger Container Source: https://github.com/mystenlabs/sui/blob/main/docs/content/operators/observability.mdx This command starts a local Jaeger container, which is necessary for visualizing distributed traces from Sui. Ensure Docker is installed and running. ```sh $ docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest ``` -------------------------------- ### Get Historical Volume for All Pools Source: https://github.com/mystenlabs/sui/blob/main/docs/content/onchain-finance/deepbookv3/deepbookv3-indexer.mdx This endpoint retrieves the historical trading volume for all available pools. Optional start and end times can be provided to specify a time range. ```http /all_historical_volume?start_time=&end_time=&volume_in_base= ``` -------------------------------- ### Example GraphQL RPC Server Run Command Source: https://github.com/mystenlabs/sui/blob/main/docs/content/operators/data-management/indexer-stack-setup.mdx An example of the command to run the GraphQL RPC server with specific configuration files and service URLs for a mainnet deployment. ```sh sui-indexer-alt-graphql rpc \ --config graphql.toml \ --indexer-config events.toml \ --indexer-config obj_versions.toml \ --indexer-config tx_affected_addresses.toml \ --indexer-config tx_affected_objects.toml \ --indexer-config tx_calls.toml \ --indexer-config tx_kinds.toml \ --indexer-config unpruned.toml \ --ledger-grpc-url https://archive.mainnet.sui.io:443 \ --consistent-store-url https://localhost:7001 \ --database-url postgres://username:password@localhost:5432/database \ --fullnode-rpc-url https://localhost:9000 ``` -------------------------------- ### Run Benchmark Client Source: https://github.com/mystenlabs/sui/blob/main/crates/anemo-benchmark/README.md Initiates the benchmark client, connecting to the server and specifying various parameters for the test. Ensure the server is running before executing this command. ```bash target/debug/anemo-benchmark --port 5555 --addrs 127.0.0.1:5556 --requests-up 10 --requests-down 10 --size-up 5000 --size-down 5000 ``` -------------------------------- ### GET /sui/authenticator_state/get_active_jwks Source: https://github.com/mystenlabs/sui/blob/main/crates/sui-framework/docs/sui/authenticator_state.md Retrieves the current active JSON Web Key Set (JWKS) from the chain. This function is typically called when a node starts up to load the JWK state. ```APIDOC ## GET /sui/authenticator_state/get_active_jwks ### Description Retrieves the current active JSON Web Key Set (JWKS) from the chain. This function is typically called when a node starts up to load the JWK state. ### Method GET ### Endpoint /sui/authenticator_state/get_active_jwks ### Parameters #### Query Parameters - **ctx** (TxContext) - Required - Transaction context. ### Response #### Success Response (200) - **active_jwks** (vector) - A vector containing the active JWK objects. #### Response Example ```json { "active_jwks": [ { "kid": "key-id-1", "n": "public-key-n1", "e": "public-key-e1", "alg": "RS256" }, { "kid": "key-id-2", "n": "public-key-n2", "e": "public-key-e2", "alg": "ES256" } ] } ``` ``` -------------------------------- ### Clone Sui Move Bootcamp Repository Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/scenario-testing.mdx Clone the specified branch of the Sui Move Bootcamp repository and navigate into the scenario directory. This is the initial setup step for the examples. ```bash git clone -b solution https://github.com/MystenLabs/sui-move-bootcamp.git cd sui-move-bootcamp/G1/scenario ``` -------------------------------- ### Start the frontend development server Source: https://github.com/mystenlabs/sui/blob/main/docs/content/getting-started/examples/nft-app.mdx Run this command in your terminal to start the frontend application. Open http://localhost:5173 in your browser. ```bash $ pnpm dev ``` -------------------------------- ### Create Demo Escrows Source: https://github.com/mystenlabs/sui/blob/main/examples/trading/api/README.md Produce demo escrow objects for testing. ```bash npx ts-node helpers/create-demo-escrows.ts ``` -------------------------------- ### Get Trade Count Source: https://github.com/mystenlabs/sui/blob/main/docs/content/onchain-finance/deepbookv3/deepbookv3-indexer.mdx Returns the total number of trades executed across all pools within a specified time range. Requires start and end Unix timestamps in seconds. ```http /trade_count?start_time=&end_time= ```