### Run Token Example Script Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/04_token.md Execute the bash script to run the token program locally. Ensure you have followed the Leo Installation Instructions. ```bash cd leo/examples/token ./run.sh ``` -------------------------------- ### Install and Start Local Devnet Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/07_devnet.md If snarkOS is not installed, use the `--install` flag to have the Leo CLI automatically download, compile, and store the binary. Ensure `` is the desired installation path. ```bash leo devnet --snarkos --snarkos-features test_network --install ``` -------------------------------- ### Console Output: Installed Plugins Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/18_plugins.md This is an example of the console output when Leo plugins are found on your PATH. ```bash Installed plugins: fmt /usr/local/bin/leo-fmt ``` -------------------------------- ### Run Basic Bank Example Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/02_basic_bank.md Execute the basic bank program locally using this bash script. Ensure you have followed the Leo Installation Instructions. ```bash cd leo/examples/basic_bank ./run.sh ``` -------------------------------- ### Leo Module Structure Example Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/01_layout.md Illustrates a typical project structure with main modules and submodules. ```text src ├── common.leo ├── main.leo ├── outer.leo └── outer └── inner.leo ``` -------------------------------- ### Run Leo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/01_installation.md Execute the Leo compiler after installation. ```bash leo ``` -------------------------------- ### Install Leo Plugins with Cargo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/18_plugins.md Use `cargo install` to install Leo plugins like `leo-fmt` and `leo-lsp`. ```bash cargo install leo-fmt leo-lsp ``` -------------------------------- ### Start Local Devnet Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/07_devnet.md Use this command to start a local devnet. Replace `` with the path to your snarkOS binary. The `--snarkos-features test_network` flag is required for devnet operation. ```bash leo devnet --snarkos --snarkos-features test_network ``` -------------------------------- ### Build Leo from Source Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/01_installation.md Clone the Leo repository, navigate into the directory, and then build and install Leo and its formatter plugin using Cargo. ```bash # Download the source code git clone https://github.com/ProvableHQ/leo cd leo # Build and install Leo cargo install --path . # Build and install the formatter plugin cargo install --path crates/fmt ``` -------------------------------- ### Install leo-fmt Plugin Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/17_fmt.md Install the `leo-fmt` plugin using Cargo. Pre-built binaries are also available in Leo release archives. ```bash cargo install leo-fmt ``` -------------------------------- ### List Installed Leo Plugins Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/18_plugins.md Run this command to see all CLI plugins currently installed and visible to Leo. ```bash leo plugins ``` -------------------------------- ### Install Leo with Cargo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/01_installation.md Use Cargo to install the Leo compiler and formatter. This command installs the `leo` and `leo-fmt` executables. ```bash cargo install leo-lang leo-fmt ``` -------------------------------- ### Install SnarkOS during Devnet Initialization Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/07_devnet.md If snarkOS is not installed, use the `--install` flag to install it at the specified path. This flag can be combined with `--snarkos-features` to specify desired features. ```bash leo devnet --snarkos --install ``` -------------------------------- ### Verify Git Installation Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/01_installation.md Check if Git is installed correctly by running the version command. This is a prerequisite for cloning the Leo source code. ```bash git --version ``` -------------------------------- ### Leo CLI: Sign and Verify Example Source: https://context7.com/provablehq/leo-docs-source/llms.txt Demonstrates an end-to-end workflow for signing a message off-chain using the Leo CLI and then verifying that signature on-chain within a Leo program. ```bash # Step 1: Sign a message with Alice's private key leo account sign \ --message 42field \ --private-key APrivateKey1zkp1w8PTxrRgGfAtfKUSq43iQyVbdQHfhGbiNPEg2LVSEXR # → sign195m229jvzr0wmnshj6f8gwplhkrkhjumgjmad553r997u7pjfgpfz4j2w0c9lp53mcqqdsmut2g3a2zuvgst85w38hv273mwjec3sqjsv9w6uglcy58gjh7x3l55z68zsf24kx7a73ctp8x8klhuw7l2p4s3aq8um5jp304js7qcnwdqj56q5r5088tyvxsgektun0rnmvtsuxpe6sj # Step 2: Verify off-chain via CLI leo account verify \ --address aleo13ssze66adjjkt795z9u5wpq8h6kn0y2657726h4h3e3wfnez4vqsm3008q \ --signature sign195m... \ --message 42field # → ✅ Verified ``` -------------------------------- ### Leo Deploy JSON Output Example Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/06_deploy.md An example of the JSON output generated by the `leo deploy --json-output` command, containing deployment details like program ID and transaction ID. ```json { "deployments": [ { "program_id": "my_program.aleo", "transaction_id": "at1..." } ] } ``` -------------------------------- ### List Available Leo Versions Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/14_update.md Use the `--list` or `-l` flag to display all available versions of Leo that can be installed. ```bash leo update --list ``` -------------------------------- ### Initialize Local Devnet Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/07_devnet.md Use this command to initialize a local devnet. Ensure you provide the path to an installed snarkOS binary. ```bash leo devnet --snarkos ``` -------------------------------- ### Outputs of Starting the Battleship Game Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md The outputs confirm the game has started, showing updated records for both players. Player 1 receives a move record, and Player 2's board state reflects `game_started: true`. ```bash ➡️ Outputs • { owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, hits_and_misses: 0u64.private, played_tiles: 0u64.private, ships: 9044591273705727u64.private, player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, game_started: true.private, _nonce: 499506036017893504519951074816367233238764881167148207158107765834843789278group.public } • { owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, incoming_fire_coordinate: 0u64.private, player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, prev_hit_or_miss: 0u64.private, _nonce: 7551593771072417773015833444631669906818701068612998340960968556531564726874group.public } ✅ Executed 'battleship.aleo::start_battleship' ``` -------------------------------- ### Player 1 Starts the Battleship Game with Leo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md Player 1 initiates the game by calling `start_battleship`, passing their board state and a dummy move record. This transitions the game to a started state. ```bash leo run start_battleship "{ owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, hits_and_misses: 0u64.private, played_tiles: 0u64.private, ships: 9044591273705727u64.private, player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, game_started: false.private, _nonce: 677929557867990662961068737825412945684193990901139603462104629310061710321group.public }" "{ owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, incoming_fire_coordinate: 0u64.private, player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, prev_hit_or_miss: 0u64.private, _nonce: 6306786918362462465996698473371289503655844751914031374264794338640697795225group.public }" ``` -------------------------------- ### Creating and Accessing Leo Structs Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/08_cheatsheet.md Provides an example of instantiating a Leo struct and accessing its fields. ```leo let msg: Message = Message { sender: aleo1ezamst4pjgj9zfxqq0fwfj8a4cjuqndmasgata3hggzqygggnyfq6kmyd4, object: 42u64, }; let sender_address: address = msg.sender; let object_value: u64 = msg.object; ``` -------------------------------- ### Leo Program Structure Example Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/02_structure.md Demonstrates the typical layout of a Leo program, including imports, constants, structs, functions, program definitions, mappings, and records. ```leo import foo.aleo; const FOO: u64 = 1u64; struct Message { sender: address, object: u64, } fn compute(a: u64, b: u64) -> u64 { return a + b + FOO; } program hello.aleo { mapping account: address => u64; record Token { owner: address, amount: u64, } fn mint_public( public receiver: address, public amount: u64, ) -> (Token, Final) { let token: Token = Token { owner: receiver, amount }; return (token, final { let current_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); Mapping::set(account, receiver, current_amount + amount); }); } } ``` -------------------------------- ### Leo Program Entry Point (main.leo) Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/03_hello.md The main.leo file contains the core logic of the Leo program, starting with the 'main' function. ```leo // The 'hello' program. program hello.aleo { @noupgrade constructor() {} fn main(public a: u32, b: u32) -> u32 { let c: u32 = a + b; return c; } } ``` -------------------------------- ### Leo Update Console Output Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/14_update.md Example output when running `leo update` when Leo is already on the latest version. ```bash Checking target-arch... aarch64-apple-darwin Checking current version... v3.1.0 Checking latest released version... v3.1.0 Leo Leo is already on the latest version ``` -------------------------------- ### Start Local Devnet with Tmux Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/07_devnet.md Enable tmux integration for managing multiple nodes in your local devnet by passing the `--tmux` flag. This feature is only available on Unix-based systems. ```bash leo devnet --snarkos --snarkos-features test_network --tmux ``` -------------------------------- ### Initialize a new Leo project Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/03_hello.md Use the Leo CLI to create a new project directory and navigate into it. ```bash leo new hello cd hello ``` -------------------------------- ### Player 2 Initializes Board with Leo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md Configure the environment for Player 2 and execute the `initialize_board` function. This sets up Player 2's game board and private key for the testnet. ```bash echo " NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH " > .env leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy ``` -------------------------------- ### Initialize Player 1's Board with Ships Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md Use this command to initialize Player 1's board with ship placements and the opponent's public address. Ensure your .env file is correctly configured with your private key. ```bash echo " NETWORK=testnet PRIVATE_KEY=APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm " > .env leo run initialize_board 34084860461056u64 551911718912u64 7u64 1157425104234217472u64 aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry ``` -------------------------------- ### Run Auction Script Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/01_auction.md Execute the auction program locally using this bash script. Ensure Leo is installed and follow the setup instructions for the `.env` file. ```bash cd leo/examples/auction ./run.sh ``` -------------------------------- ### Print Help Information Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/00_overview.md Run `leo --help` to display a list of available commands and flags. ```bash leo --help ``` -------------------------------- ### Create a Leo Library Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/06_libraries.md Use the `leo new` command with the `--library` flag to initialize a new library project. This sets up the standard project structure with `lib.leo` as the main source file. ```bash leo new math_utils --library ``` -------------------------------- ### Verify Cargo Installation Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/getting_started/01_installation.md Check if Cargo is installed correctly by running the version command. This is a prerequisite for installing Rust packages. ```bash cargo --version ``` -------------------------------- ### Configure Bidder 1 Environment Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/01_auction.md Set up the `.env` file with Bidder 1's private key and address to sign transactions. This is necessary before calling the `place_bid` function for Bidder 1. ```bash echo " NETWORK=testnet PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK ENDPOINT=https://localhost:3030 " > .env ``` -------------------------------- ### Install Tmux on MacOS Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/07_devnet.md Install the tmux package on macOS using the Homebrew package manager. Ensure Homebrew is installed first. ```bash brew install tmux ``` -------------------------------- ### Verify Leo Installation Source: https://context7.com/provablehq/leo-docs-source/llms.txt Checks the installed version of the Leo compiler. ```bash leo --version ``` -------------------------------- ### Install Tmux on Ubuntu Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/07_devnet.md Install the tmux package on Ubuntu and other Debian-based systems using the apt package manager. ```bash sudo apt update sudo apt install tmux ``` -------------------------------- ### Output of Player 2 Board Initialization Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md The output shows the initial state of Player 2's board, including their public key, ship configuration, and game status, before the game officially starts. ```bash ➡️ Output • { owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, hits_and_misses: 0u64.private, played_tiles: 0u64.private, ships: 9044591273705727u64.private, player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, game_started: false.private, _nonce: 677929557867990662961068737825412945684193990901139603462104629310061710321group.public } ✅ Executed 'battleship.aleo::initialize_board' ``` -------------------------------- ### Install Specific Leo Version Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/14_update.md Use the `--name` flag to install a specific version of Leo. Replace `v3.0.0` with the desired version tag. ```bash leo update --name v3.0.0 ``` -------------------------------- ### Execute with Additional Programs Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/08_execute.md Use the `--with` flag to load additional Aleo programs into the VM at runtime. Provide paths to local `.aleo` files or names of remote programs. Local files must be in topological order. ```bash leo execute --with ./extra_prog.aleo ``` ```bash leo execute --with program1.aleo,program2.aleo ``` -------------------------------- ### Valid Board Configuration Example 3 in Leo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md A third example of a valid board state, showcasing a complex arrangement of ships within the u64 bitstring representation. ```leo 2157505700798988545u64 ``` -------------------------------- ### Leo Test Function Examples Source: https://context7.com/provablehq/leo-docs-source/llms.txt Examples of Leo test functions demonstrating assertions, expected failures, record minting, and on-chain state interactions like mapping updates. ```leo // tests/test_my_program.leo program test_my_program.aleo { // Simple assertion test @test fn test_addition() { let result: u32 = my_program.aleo::simple_addition(2u32, 3u32); assert_eq(result, 5u32); } // Test expected to fail @test @should_fail fn test_addition_fail() { let result: u32 = my_program.aleo::simple_addition(2u32, 3u32); assert_eq(result, 999u32); // wrong expected value } // Test record fields @test fn test_record_mint() { let r: my_program.aleo::Example = my_program.aleo::mint_record(42field); assert_eq(r.x, 42field); } // Test on-chain state (mappings work natively) @test fn test_mapping_update() { my_program.aleo::deposit(aleo1..., 100u64); // finalization executes as part of the test } @noupgrade constructor() {} } ``` -------------------------------- ### Output of Board Initialization Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md This is the expected output after initializing Player 1's board. It shows the initial state of the board record, including ship configurations and player addresses. The `game_started` flag is initially false. ```json { owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, hits_and_misses: 0u64.private, played_tiles: 0u64.private, ships: 1157459741006397447u64.private, player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, game_started: false.private, _nonce: 605849623036268790365773177565562473735086364071033205649960161942593750353group.public } ``` -------------------------------- ### Configure Auction Environment Variables Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/01_auction.md Set up the .env file with network, private key, and endpoint for running Leo commands. Ensure the PRIVATE_KEY is for the auctioneer. ```bash echo " NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc ENDPOINT=https://localhost:3030 " > .env ``` -------------------------------- ### Valid Board Configuration Example 2 in Leo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md Another example of a valid Battleship board configuration represented by a u64. This highlights different ship placements adhering to game rules. ```leo 16383u64 ``` -------------------------------- ### Display `leo deploy` Help Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/03_deploying.md Run this command from the root of your Leo program directory to see all available options for the `leo deploy` command. ```bash leo deploy --help ``` -------------------------------- ### Configure Bidder 2 Environment Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/01_auction.md Update the `.env` file with Bidder 2's private key and address. This prepares the environment for Bidder 2 to place their bid. ```bash echo " NETWORK=testnet PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug ENDPOINT=https://localhost:3030 " > .env ``` -------------------------------- ### Configure Deployment via .env File Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/03_deploying.md Set network, private key, and node API endpoint in a `.env` file for deployment or upgrade. This method has lower precedence than CLI options or environment variables. ```bash NETWORK=testnet PRIVATE_KEY=APrivateKey1z...GPWH ENDPOINT=https://api.explorer.provable.com/v1 ``` -------------------------------- ### Upgrade Program with Private Key and Network Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/15_upgrade.md Specifies the private key and network for upgrading a program. Overrides environment variables. ```bash --private-key --network ``` -------------------------------- ### Build Leo from Source Source: https://context7.com/provablehq/leo-docs-source/llms.txt Clones the Leo repository and builds the compiler and formatter from source using Cargo. ```bash git clone https://github.com/ProvableHQ/leo cd leo cargo install --path . cargo install --path crates/fmt ``` -------------------------------- ### Sample Output of `leo execute` Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/08_execute.md This output details the execution plan, configuration, target program, fee information, and the final cost breakdown. It also shows the transaction actions and any resulting outputs. ```bash Leo ... statements before dead code elimination. Leo ... statements after dead code elimination. Leo The program checksum is: '[...]'. Leo ✅ Compiled '{PROGRAM_NAME}.aleo' into Aleo instructions. 📢 Using the following consensus heights: 0,2950000,4800000,6625000,6765000,7600000,8365000,9173000,9800000 To override, pass in `--consensus-heights` or override the environment variable `CONSENSUS_VERSION_HEIGHTS`. Attempting to determine the consensus version from the latest block height at {ENDPOINT}... 🚀 Execution Plan Summary ────────────────────────────────────────────── 🔧 Configuration: Private Key: {PRIVATE_KEY} Address: {ADDRESS} Endpoint: {ENDPOINT} Network: {NETWORK} Consensus Version: {CONSENSUS_VERSION} 🎯 Execution Target: Program: {PROGRAM_NAME}.aleo Function: {FUNCTION_NAME} Source: remote 💸 Fee Info: Priority Fee: {PRIORITY_FEE} μcredits Fee Record: no (public fee) | {FEE RECORD} ⚙️ Actions: - Program and its dependencies will be downloaded from the network. - Transaction will NOT be printed to the console. - Transaction will NOT be saved to a file. - Transaction will NOT be broadcast to the network. 📊 Execution Summary for {PROGRAM_NAME}.aleo ────────────────────────────────────────────── 💰 Cost Breakdown (credits) Transaction Storage: ... On‑chain Execution: ... Priority Fee: ... Total Fee: ... ────────────────────────────────────────────── ➡️ Outputs • {OUTPUT_0} • {OUTPUT_1} ... ``` -------------------------------- ### Constant Declarations in Leo Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/02_structure.md Shows examples of declaring constants in different scopes: global, program, and local. ```leo const MAX: u64 = 100u64; // global constant program foo.aleo { const MULTIPLIER: u64 = 2u64; // program-scope constant fn compute(x: u64) -> u64 { const OFFSET: u64 = 5u64; // local constant return x * MULTIPLIER + OFFSET; } } ``` -------------------------------- ### Leo Deploy Command Sample Output Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/06_deploy.md This is a sample output of the `leo deploy` command, showing compilation details, consensus heights, deployment plan summary, actions, and a cost breakdown for the program deployment. ```bash Leo ... statements before dead code elimination. Leo ... statements after dead code elimination. Leo The program checksum is: '[...]'. Leo ✅ Compiled '{PROGRAM_NAME}.aleo' into Aleo instructions. 📢 Using the following consensus heights: 0,2950000,4800000,6625000,6765000,7600000,8365000,9173000,9800000 To override, pass in `--consensus-heights` or override the environment variable `CONSENSUS_VERSION_HEIGHTS`. Attempting to determine the consensus version from the latest block height at {ENDPOINT}... 🛠️ Deployment Plan Summary ────────────────────────────────────────────── 🔧 Configuration: Private Key: {PRIVATE_KEY} Address: {ADDRESS} Endpoint: {ENDPOINT} Network: {NETWORK} Consensus Version: {CONSENSUS_VERSION} 📦 Deployment Tasks: • {PROGRAM_NAME}.aleo │ priority fee: 0 │ fee record: no (public fee) ⚙️ Actions: • Transaction(s) will NOT be printed to the console. • Transaction(s) will NOT be saved to a file. • Transaction(s) will be broadcast to {ENDPOINT} 🔧 Your program '{PROGRAM_NAME}.aleo' has the following constructor. ────────────────────────────────────────────── constructor: ... ────────────────────────────────────────────── Once it is deployed, it CANNOT be changed. 📦 Creating deployment transaction for '{PROGRAM_NAME}.aleo'... 📊 Deployment Summary for '{PROGRAM_NAME}.aleo' ────────────────────────────────────────────── Total Variables: ... Total Constraints: ... Max Variables: 2,097,152 Max Constraints: 2,097,152 💰 Cost Breakdown (credits) Transaction Storage: ... Program Synthesis: ... Namespace: ... Constructor: ... Priority Fee: ... Total Fee: ... ────────────────────────────────────────────── ``` -------------------------------- ### Leo Program Compilation Output Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/04_executing.md This is an example of the console output when a local Leo program is compiled before execution. ```bash Leo 2 statements before dead code elimination. Leo 2 statements after dead code elimination. Leo The program checksum is: '[212u8, 91u8, ... , 107u8]'. Leo ✅ Compiled 'hello.aleo' into Aleo instructions. ``` -------------------------------- ### Get Program Address (`self.address`) Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/operators/standard_operators.md Returns the Aleo address of the program that calls it. This operator does not take any parameters. ```leo program example.aleo { fn get_program_address() -> address { return self.address; } } ``` -------------------------------- ### Get Group Generator Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/03_data_types.md The generator point for the group can be obtained via a constant associated to the `group` type. ```leo let g: group = group::GEN; // the group generator ``` -------------------------------- ### Format Leo Project Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/17_fmt.md Run `leo fmt` to format all `.leo` files in the `src/` directory by default. No output is produced on success. ```bash leo fmt ``` -------------------------------- ### Create a New Leo Library Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/09_new.md Use this command with the `--library` flag to create a new Leo library. Libraries provide reusable logic and include a starter test file. ```bash leo new --library ``` -------------------------------- ### Example Usage of _dynamic_contains Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/programs_in_practice/intrinsics.md Demonstrates the usage of `_dynamic_contains` within a Leo program to check for the existence of a key in a remote mapping. ```leo program checker.aleo { mapping seen: address => bool; fn check(prog: field, net: field, map: field, key: address) -> Final { return final { finalize_check(prog, net, map, key); }; } @noupgrade constructor() {} } final fn finalize_check(prog: field, net: field, map: field, key: address) { let exists: bool = _dynamic_contains(prog, net, map, key); Mapping::set(seen, key, exists); } ``` -------------------------------- ### Leo Nested Optional Example Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/10_abi.md Illustrates the lowering of a nested optional type '[u64?; 2]' into an array of Aleo structs. ```leo let arr: [u64?; 2] = [1u64, none]; ``` -------------------------------- ### Get External Program Checksum Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/operators/standard_operators.md Retrieves the checksum of another imported program. Ensure the program is imported before referencing its checksum. ```leo import credits.aleo; ... let ext_checksum: [u8, 32] = Program::checksum(credits.aleo); ``` -------------------------------- ### Player 1's 3rd Turn Execution Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md This snippet demonstrates Player 1 taking their third turn by running the `play` function. It shows the environment variable setup and the arguments passed to the `play` function, including game state and move details. The output shows the updated board state and the new move record. ```bash echo " NETWORK=testnet PRIVATE_KEY=APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm " > .env leo run play "{ owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, hits_and_misses: 0u64.private, played_tiles: 1u64.private, ships: 1157459741006397447u64.private, player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, game_started: true.private, _nonce: 1962122153746742645258971561783872712461616481157617568489391338473028502271group.public }" "{ owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, incoming_fire_coordinate: 2048u64.private, player_1: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, prev_hit_or_miss: 1u64.private, _nonce: 1204008848449868423802652577996848559012797694551224583683080100053831915439group.public }" 2u64 ``` ```stdout ➡️ Outputs • { owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, hits_and_misses: 1u64.private, played_tiles: 3u64.private, ships: 1157459741006397447u64.private, player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, player_2: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, game_started: true.private, _nonce: 5338125050531864311985370830280952305688629865354830939402745656578990650505group.public } • { owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private, incoming_fire_coordinate: 2u64.private, player_1: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, player_2: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private, prev_hit_or_miss: 0u64.private, _nonce: 7971995563631235472540847437984726419106193784727086463494463811056252801811group.public } ✅ Executed 'battleship.aleo::play' ``` -------------------------------- ### Query Peer Count Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/10_query.md Get the total count of active peers connected to a node on the network. This requires a custom endpoint. ```bash leo query peers --count --network ``` -------------------------------- ### Build Tests with Program Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/15_upgrade.md Builds tests along with the main program and its dependencies. ```bash --build-tests ``` -------------------------------- ### Leo Program Structure with Tests Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/08_testing.md Illustrates the directory structure for a Leo project including the main program files and the dedicated tests directory. ```bash example_program ├── build │ ├── imports │ │ └── test_example_program.aleo │ ├── main.aleo │ └── program.json ├── outputs ├── src │ └── main.leo ├── tests │ └── test_example_program.leo └── program.json ``` -------------------------------- ### Get External Program Owner Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/operators/standard_operators.md Retrieves the owner address of another imported program. Ensure the program is imported before referencing its owner. ```leo import credits.aleo; ... let ext_owner: u16 = Program::owner(credits.aleo); ``` -------------------------------- ### Enable All AST Snapshots Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/15_upgrade.md Captures Abstract Syntax Tree (AST) snapshots for all compiler phases. ```bash --enable-all-ast-snapshots ``` -------------------------------- ### Get External Program Edition Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/language/operators/standard_operators.md Retrieves the edition (version number) of another imported program. The program must be imported first. ```leo import credits.aleo; ... let ext_edition: u16 = Program::edition(credits.aleo); ``` -------------------------------- ### Enable Initial AST Snapshot Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/15_upgrade.md Writes an Abstract Syntax Tree (AST) snapshot immediately after the parsing phase of compilation. ```bash --enable-initial-ast-snapshot ``` -------------------------------- ### Vertical Ship Placement Example (257u64) Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md Represents a vertical ship of length 2 placed at the bottom right corner of an 8x8 board. ```text 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 ``` -------------------------------- ### Sample `leo run` Output Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/cli/12_run.md This is a sample output from the `leo run` command, showing compilation details, constraint counts, and program outputs. ```bash Leo ... statements before dead code elimination. Leo ... statements after dead code elimination. Leo The program checksum is: '[...]'. Leo ✅ Compiled '{PROGRAM_NAME}.aleo' into Aleo instructions. ⛓ Constraints • '{PROGRAM_NAME}.aleo::{FUNCTION_NAME}' - ... constraints (called 1 time) ➡️ Outputs • {OUTPUT_0} • {OUTPUT_1} ... ``` -------------------------------- ### Horizontal Ship Placement Example (3u64) Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/leo_by_example/06_battleship.md Represents a horizontal ship of length 2 placed at the bottom right corner of an 8x8 board. ```text 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 ``` -------------------------------- ### Leo Tuple Expansion Example Source: https://github.com/provablehq/leo-docs-source/blob/master/documentation/guides/10_abi.md Demonstrates how a Leo function returning a tuple '(u32, u32)' is expanded into multiple registers in Aleo bytecode. ```leo program example.aleo { fn swap(a: u32, b: u32) -> (u32, u32) { return (b, a); } } ```