### Leo Setup Console Output Example
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/06_setup.md
An example of the console output when 'leo setup' is executed, showing the progress and completion of key generation.
```bash
Setup Starting...
Setup Saving proving key ("${NAME}/outputs/${NAME}.lpk")
Setup Complete
Setup Saving verification key ("${NAME}/outputs/${NAME}.lvk")
Setup Complete
Done Finished in 10 milliseconds
```
--------------------------------
### Complete Wallet Provider Setup Example (JavaScript)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Demonstrates a full example of setting up the WalletProvider and WalletModalProvider in a React application. It includes initializing multiple wallet adapters (Leo, Puzzle, Fox, Soter) with their respective configurations and setting global provider options like decryptPermission and network.
```javascript
import React from "react"; // Import React
import { WalletModalProvider } from "@demox-labs/aleo-wallet-adapter-reactui";
import { WalletProvider } from "@demox-labs/aleo-wallet-adapter-react";
import { DecryptPermission, WalletAdapterNetwork } from "@demox-labs/aleo-wallet-adapter-base";
import { useMemo } from "react";
import {
PuzzleWalletAdapter,
LeoWalletAdapter,
FoxWalletAdapter,
SoterWalletAdapter
} from 'aleo-adapters'; // Assuming 'aleo-adapters' exports these correctly
export default function Providers({ children }: { children: React.ReactNode }) {
const wallets = useMemo(
() => [
new LeoWalletAdapter({
appName: 'Aleo app',
}),
new PuzzleWalletAdapter({
programIdPermissions: {
// Example permissions, adjust program IDs as needed
[WalletAdapterNetwork.MainnetBeta]: ['dApp_1.aleo', 'dApp_1_import.aleo', 'dApp_1_import_2.aleo'],
[WalletAdapterNetwork.TestnetBeta]: ['dApp_1_test.aleo', 'dApp_1_test_import.aleo', 'dApp_1_test_import_2.aleo']
},
appName: 'Aleo app',
appDescription: 'A privacy-focused DeFi app',
appIconUrl: '' // Provide a URL to your app's icon
}),
new FoxWalletAdapter({
appName: 'Aleo app',
}),
new SoterWalletAdapter({
appName: 'Aleo app',
})
],
[]
);
return (
{children}
);
}
```
--------------------------------
### Set Up Aleo Project Dependencies
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_6/6.2_Create_an_empty_Aleo_dApp.md
Navigates to the created project directory, installs project dependencies, installs the Leo compiler, and starts the development server.
```bash
cd aleo-project
npm install
npm run install-leo
npm run dev
```
--------------------------------
### snarkOS CLI Examples
Source: https://github.com/authentiquo/leo_mcp/blob/main/testnet/getting_started/01_installation.md
Provides practical examples of using snarkOS command-line flags. These examples demonstrate how to secure RPC endpoints with username and password, and how to manually connect to a specific peer on the network.
```bash
# Guard RPC endpoints
snarkos --rpc-username --rpc-password
# Manually connect to a peer on the network
snarkos --connect ""
```
--------------------------------
### Install Leo for Ubuntu
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/01_installation.md
Download the pre-compiled release of Leo for Ubuntu. This is a direct download from the official GitHub releases page.
```bash
curl -LO https://github.com/AleoHQ/leo/releases/download/v1.0.3/leo-v1.0.3-x86_64-unknown-linux-gnu.zip
```
--------------------------------
### Run Leo Project and Observe Output
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/02_hello_world.md
Compiles, generates keys, fetches inputs, generates a proof, and verifies a Leo program. The output shows the stages of compilation, setup, proving, and verification.
```bash
leo run
```
```console output
Compiling Starting...
Compiling Compiling main program... ("hello-world/src/main.leo")
Compiling Complete
Done Finished in 10 milliseconds
Setup Starting...
Setup Saving proving key ("hello-world/outputs/hello-world.lpk")
Setup Complete
Setup Saving verification key ("hello-world/outputs/hello-world.lvk")
Setup Complete
Done Finished in 10 milliseconds
Proving Starting...
Proving Saving proof... ("hello-world/outputs/hello-world.proof")
Done Finished in 10 milliseconds
Verifying Starting...
Verifying Proof is valid
Done Finished in 10 milliseconds
```
--------------------------------
### Navigate to Project Directory
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_2/01_hello_world.md
Changes the current working directory to the newly created Leo project. This is a standard command-line operation to access the project files.
```bash
cd hello_world
```
--------------------------------
### Install Wallet Adapter Packages (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_6/6.4_Wallet_Adapter.md
Installs the necessary packages for the universal wallet adapter, including base, React, and UI components, along with aleo-adapters.
```bash
npm install --save \
@demox-labs/aleo-wallet-adapter-base \
@demox-labs/aleo-wallet-adapter-react \
@demox-labs/aleo-wallet-adapter-reactui \
aleo-adapters
```
--------------------------------
### Create New Leo Project
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_2/01_hello_world.md
Initializes a new Leo project with a specified name. This command generates the basic file structure and configuration files required for a new Aleo program. It creates a new directory for the project.
```bash
leo new hello_world
```
--------------------------------
### Install Rustup for macOS/Linux
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/01_installation.md
Installs Rust and the Rust package manager (rustup) using a script from the official Rust website. This is a prerequisite for installing Leo via Cargo.
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
--------------------------------
### Install Leo from Crates.io
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/01_installation.md
Installs the Leo programming language using Cargo, the Rust package manager. This is the recommended installation method.
```bash
cargo install leo-lang
```
--------------------------------
### Leo Run Console Output Example
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/08_run.md
Provides an example of the console output when running the `leo run` command. It details the compilation, setup, proving, and verification stages, along with their respective timings and outcomes.
```bash
Compiling Starting...
Compiling Compiling main program... ("${NAME}/src/main.leo")
Compiling Complete
Done Finished in 10 milliseconds
Setup Detected saved setup
Setup Loading proving key...
Setup Complete
Setup Loading verification key...
Setup Complete
Done Finished in 10 milliseconds
Proving Starting...
Proving Saving proof... ("${NAME}/outputs/${NAME}.proof")
Done Finished in 10 milliseconds
Verifying Starting...
Verifying Proof is valid
Done Finished in 10 milliseconds
```
--------------------------------
### Leo 'Hello World' Program Structure
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_2/01_hello_world.md
Defines a basic 'Hello World' program in Leo, demonstrating a simple addition transition. It includes comments, program definition, and a transition function with public inputs and a single output. Leo syntax is similar to Rust.
```rust
// The 'hello_world' program.
program hello_world.aleo {
transition main(public a: u32, b: u32) -> u32 {
let c: u32 = a + b;
return c;
}
}
```
--------------------------------
### Install Leo for macOS
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/01_installation.md
Download the pre-compiled release of Leo for macOS. This is a direct download from the official GitHub releases page.
```bash
curl -LO https://github.com/AleoHQ/leo/releases/download/v1.0.3/leo-v1.0.3-x86_64-apple-darwin.zip
```
--------------------------------
### Leo Project Manifest Configuration
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_2/01_hello_world.md
The program.json file serves as the manifest for a Leo project, containing metadata such as the program name, version, description, license, and dependencies. This file is crucial for managing and deploying Aleo programs.
```json
{
"program": "hello_world.aleo",
"version": "0.1.0",
"description": "",
"license": "MIT",
"dependencies": null
}
```
--------------------------------
### Execute Leo Program Transition
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_2/01_hello_world.md
Runs a specific transition of a Leo program locally off-chain. This command compiles the Leo code into Aleo instructions and then into AVM bytecode for execution, displaying the constraints and output. It requires the transition name and input values.
```bash
leo run main 1u32 2u32
```
--------------------------------
### Leo Setup Command Usage with Flags
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/06_setup.md
Illustrates the general usage of the 'leo setup' command, including the availability of flags to modify its behavior.
```bash
leo setup [FLAGS]
```
--------------------------------
### Install snarkOS from Crates.io
Source: https://github.com/authentiquo/leo_mcp/blob/main/testnet/getting_started/01_installation.md
Installs the snarkOS binary using the Cargo package manager. This is the recommended installation method for users who want to quickly start using snarkOS. It fetches the latest stable version from crates.io.
```bash
cargo install snarkos
```
--------------------------------
### Run Leo Program Setup
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/06_setup.md
Executes the 'leo setup' command to generate a proving key and a verification key for the Leo program. The keys are stored in the 'outputs' directory.
```bash
leo setup
```
--------------------------------
### snarkOS - Node Installation and Setup
Source: https://context7.com/authentiquo/leo_mcp/llms.txt
Install and run an Aleo network node using snarkOS.
```APIDOC
## snarkOS - Node Installation and Setup
Install and run an Aleo network node using snarkOS.
### Installation
**Via Cargo:**
```bash
cargo install snarkos
```
**Build from source:**
```bash
git clone https://github.com/AleoHQ/snarkOS
cd snarkOS
cargo build --release
./target/release/snarkos
```
**Using Docker:**
```bash
docker build -t snarkos:latest .
docker run -d -p 4131:4131 --name snarkos snarkos
```
### Running a Node
**Start a client node:**
```bash
snarkos
```
**Start a mining node:**
```bash
snarkos --is-miner
```
**Start with custom settings:**
```bash
snarkos --ip 0.0.0.0 --port 4131 --rpc-port 3030
```
**Secure RPC endpoints:**
```bash
snarkos --rpc-username admin --rpc-password secretpassword
```
**Connect to a specific peer:**
```bash
snarkos --connect "192.168.1.100:4131"
```
```
--------------------------------
### Execute Function and Generate Proof (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_2/01_hello_world.md
The 'leo execute' command runs a specified function with given inputs and generates a JSON output containing a proof of execution. This proof can be sent to any verifier for on-chain verification. It does not reveal private inputs or outputs.
```bash
leo execute main 1u32 2u32
```
--------------------------------
### Leo Setup Output Files
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/06_setup.md
Specifies the default file names and locations for the generated proving key (.lpk) and verification key (.lvk) after running 'leo setup'.
```bash
outputs/{$NAME}.lpk
outputs/{$NAME}.lvk
```
--------------------------------
### Build Leo from Source
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/01_installation.md
Clones the Leo source code repository from GitHub and builds the project in release mode using Cargo. This method generates an executable in the target directory.
```bash
# Download the source code
git clone https://github.com/AleoHQ/leo
cd leo
# Build in release mode
cargo build --release
```
--------------------------------
### snarkOS: Install and Run Node
Source: https://context7.com/authentiquo/leo_mcp/llms.txt
Provides instructions for installing and running an Aleo network node using snarkOS. Covers installation via Cargo, building from source, using Docker, and starting different node types (client, miner) with various configuration options.
```bash
# Install via Cargo
cargo install snarkos
# Or build from source
git clone https://github.com/AleoHQ/snarkOS
cd snarkOS
cargo build --release
./target/release/snarkos
# Or use Docker
docker build -t snarkos:latest .
docker run -d -p 4131:4131 --name snarkos snarkos
# Start a client node
snarkos
# Start a mining node
snarkos --is-miner
# Start with custom settings
snarkos --ip 0.0.0.0 --port 4131 --rpc-port 3030
# Secure RPC endpoints with authentication
snarkos --rpc-username admin --rpc-password secretpassword
# Connect to specific peer
snarkos --connect "192.168.1.100:4131"
```
--------------------------------
### Leo Setup Command Flags
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/06_setup.md
Details the available flags for the 'leo setup' command, such as '--skip-key-check' to bypass key validation and '-h' or '--help' for assistance.
```bash
* --skip-key-check - Skips key checks
* -h, --help - Prints help information
```
--------------------------------
### Leo Logout Console Output Example
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/10_logout.md
This example demonstrates the expected console output upon successful execution of the 'leo logout' command.
```bash
Logout success
```
--------------------------------
### API Key Example (Base64)
Source: https://github.com/authentiquo/leo_mcp/blob/main/explorer/authentication/00_authentication_api.md
This snippet shows an example of the Base64 encoded API key used for authentication. The API key is a unique token generated for accessing protected resources.
```text
MWRkMWMxMWEtMzUzMC00YTRmLTg5NDQtZjdkZDMwN2YwMjIy
```
--------------------------------
### Leo Test Console Output Example
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/language/12_tests.md
Example console output after running Leo tests. It indicates the number of tests run, the status of each test (e.g., 'ok'), and a summary of the test execution time and results.
```bash
Test Running 1 tests
Test testing::test_add_one_production ... ok
Done Tests passed in 10 milliseconds. 1 passed; 0 failed;
```
--------------------------------
### Create and Navigate Leo Project
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/getting_started/02_hello_world.md
Initializes a new Leo project named 'hello-world' and navigates into its directory. This sets up the basic file structure for a Leo application.
```bash
leo new hello-world
cd hello-world
```
--------------------------------
### Get Connection Count using curl
Source: https://github.com/authentiquo/leo_mcp/blob/main/autogen/testnet/public_endpoints/06_getconnectioncount.md
This example demonstrates how to call the `getconnectioncount` method using curl. It sends a JSON-RPC request to the node's API endpoint and expects a JSON response containing the number of connected nodes.
```shell
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getconnectioncount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
```
--------------------------------
### Get Transaction Info Example (curl)
Source: https://github.com/authentiquo/leo_mcp/blob/main/autogen/testnet/public_endpoints/10_gettransactioninfo.md
This snippet demonstrates how to call the `gettransactioninfo` method using curl. It sends a JSON-RPC request with the transaction ID to a local server endpoint. The request includes the method name, parameters, and an ID for the request.
```curl
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "gettransactioninfo", "params": ["83fc73b8a104d7cdabe514ec4ddfeb7fd6284ff8e0a757d25d8479ed0ffe608b"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
```
--------------------------------
### Initialize and Commit Aleo Application to Git (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Commands to initialize a Git repository, add all project files, and make the first commit for a new Aleo application.
```bash
cd aleo-project
git init -b main
git add .
git commit -m "first commit, new aleo app"
```
--------------------------------
### Deploy Program to Aleo Network using JavaScript
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
This snippet demonstrates how to deploy an Aleo program to the Aleo network using the Provable SDK in JavaScript. It covers setting up account credentials, initializing network clients and program managers, defining the program to deploy, and initiating the deployment transaction with a specified fee. Ensure you replace 'YOUR_PRIVATE_KEY_HERE' with your actual private key.
```javascript
import { Account, AleoNetworkClient, NetworkRecordProvider, ProgramManager, AleoKeyProvider, PrivateKey } from '@provablehq/sdk';
// Create a key provider to find proving and verification public keys
const keyProvider = new AleoKeyProvider();
keyProvider.useCache = true;
// Define an account that will execute the transaction on the chain
const private_key = "YOUR_PRIVATE_KEY_HERE"; // Replace with your actual private key
const account = new Account({ privateKey: private_key });
// Create a record provider
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1/testnet");
const recordProvider = new NetworkRecordProvider(account, networkClient);
// Initialize a program manager
const programManager = new ProgramManager("https://api.explorer.provable.com/v1/testnet", keyProvider, recordProvider);
programManager.setAccount(account);
// Define an Aleo program to deploy
const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
const programName = "hello_hello.aleo";
// Define a fee to pay for deploying the program
const fee = 1.8; // 1.8 Aleo credits
// Deploy the program to the Aleo network
const tx_id = await programManager.deploy(program, fee);
console.log("Deployment Transaction ID:", tx_id);
// Optional: Check transaction status after a delay
// await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
// const transaction = await networkClient.getTransaction(tx_id); // Use networkClient directly
// console.log("Transaction Status:", transaction.status);
```
--------------------------------
### Retrieve Record Commitments (cURL)
Source: https://github.com/authentiquo/leo_mcp/blob/main/autogen/testnet/private_endpoints/08_getrecordcommitments.md
This example demonstrates how to call the getrecordcommitments API using cURL. It shows the necessary JSON-RPC request format, including authentication and the endpoint URL. The response is expected to be an array of record commitments.
```ignore
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getrecordcommitments", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
```
--------------------------------
### Leo Code Layout: Indentation and Blank Lines
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/additional_material/00_style.md
Demonstrates correct indentation (4 spaces) and the use of blank lines to separate circuits, functions, and tests in Leo code. It shows examples of both correct and incorrect blank line usage.
```leo
import std.io.Write;
import std.math.Add;
circuit A {
// ...
}
function foo() {
// ...
}
@test
function test_foo() {
// ...
}
```
```leo
import std.io.Write;
import std.math.Add;
circuit A {
// ...
}
function foo() {
// ...
}
@test
function test_foo() {
// ...
}
```
--------------------------------
### Aleo Instructions: Hello World Program
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
A basic 'Hello World' program written in Aleo Instructions, a low-level language for zero-knowledge programs. This code defines a function 'hello' that takes two unsigned 32-bit integers (one public, one private), adds them, and outputs the private result.
```aleo
program helloworld.aleo;
// The Leo code above compiles to the following Aleo instructions
function hello:
input r0 as u32.public;
input r1 as u32.private;
add r0 r1 into r2;
output r2 as u32.private;
```
--------------------------------
### Execute Leo Program and Generate Proof (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/07_prove.md
This command executes a Leo program and generates a cryptographic proof. It first checks for a program key (`.lpk`) and runs `leo setup` if it's missing. Then, it parses input files from the `inputs` directory and uses cryptographic randomness to create the proof, saving it as a `.proof` file in the `outputs` directory.
```bash
leo prove
```
--------------------------------
### Local Aleo Program Execution in Browser
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Demonstrates executing an Aleo program ('hello world') entirely client-side in a web browser using the ProgramManager. It compiles the Aleo program source, sets up a temporary account, executes the program with given inputs, and retrieves the outputs.
```javascript
import { Account, Program, ProgramManager } from '@provablehq/sdk'; // Note: Program might not be needed directly here, ProgramManager is used.
/// Create the source for the "hello world" program
const programSource = "program helloworld.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;";
const programManager = new ProgramManager();
/// Create a temporary account for program execution
const account = new Account();
// You might need to set the account on the program manager if it's required for local execution context,
// although the example doesn't explicitly show it being used for this specific local run.
// programManager.setAccount(account); // Check SDK docs if needed for local execution
/// Get the response and ensure the program executed correctly
// Note: The original example uses programManager.run(), which implies ProgramManager handles parsing and execution.
const executionResponse = await programManager.execute(programSource, "hello", ["5u32", "5u32"]);
const result = executionResponse.getOutputs();
console.log(result); // Assuming assert functionality or similar check needed
// assert(result.toString() === ["10u32"].toString()); // Example assertion
```
--------------------------------
### Create Aleo dApp Project with NPM
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_6/6.2_Create_an_empty_Aleo_dApp.md
Initializes a new Aleo dApp project using the 'create-leo-app' package. This command prompts the user for project name and framework selection (React, Node.js, Vanilla).
```bash
npm create leo-app@latest
```
--------------------------------
### Run snarkOS Node
Source: https://github.com/authentiquo/leo_mcp/blob/main/testnet/getting_started/01_installation.md
Commands to run snarkOS as a client node, a mining node, or a node with custom settings. The basic command starts a client node, while adding the `--is-miner` flag enables mining. Customization is possible via CLI flags or configuration files.
```bash
# Start a client node
snarkos
# Start a mining node
snarkos --is-miner
```
--------------------------------
### Link Local Project to GitHub Repository (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Steps to add a remote origin to your local Git repository and push your application to GitHub. This requires creating a repository on GitHub first.
```bash
git remote add origin
git remote -v
git push -u origin main
```
--------------------------------
### Initialize WebAssembly for Provable SDK
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Initializes the WebAssembly environment required for the Provable SDK. This is a prerequisite for calling any SDK functions, including account creation and program execution. It uses top-level await for asynchronous initialization.
```javascript
import { Account, initializeWasm } from '@provablehq/sdk';
// Assuming top-level await is enabled.
// This can also be initialized within a promise.
await initializeWasm();
/// Create a new Aleo account
const account = new Account();
```
--------------------------------
### Create New Leo Project with CLI
Source: https://context7.com/authentiquo/leo_mcp/llms.txt
Initializes a new Leo project, setting up the standard directory structure required for Aleo applications. This includes the project manifest (Leo.toml), input files, and the main program source file.
```bash
# Create a new Leo project
leo new hello-world
cd hello-world
# Project structure created:
# hello-world/
#
```
--------------------------------
### More Array Examples in Leo
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/language/04_arrays_and_tuples.md
Provides additional examples of array initialization, element modification, and array creation using spreads and slices. Includes examples for integer, field, and boolean arrays.
```leo
// initialize an integer array with integer values
let a: [u32; 3] = [1, 2, 3];
// set an element to a value
a[2] = 4;
// initialize an array of 4 values all equal to 42
let b = [42u32; 4];
// initialize an array of 5 values copying all elements of b using a spread
let c = [1u32, ...b];
// initialize an array copying a slice from `c`
let d = c[1..3];
// initialize a field array
let e = [5field; 2];
// initialize a boolean array
let f = [true, false || true, true];
```
--------------------------------
### Leo Circuits: Define and Instantiate Structs
Source: https://context7.com/authentiquo/leo_mcp/llms.txt
Illustrates the definition and usage of circuits in Leo, which function similarly to structs. Shows how to declare member variables, define static constructor functions (`new`), instance methods, and mutable instance methods. Also includes an example of a Pedersen hash circuit.
```leo
// Define a circuit with member variables and functions
circuit Rectangle {
width: u32;
height: u32;
// Static constructor function
function new(w: u32, h: u32) -> Self {
return Self { width: w, height: h };
}
// Instance method using self
function area(self) -> u32 {
return self.width * self.height;
}
// Mutable instance method
function scale(mut self, factor: u32) {
self.width *= factor;
self.height *= factor;
}
}
// Define a Pedersen hash circuit
circuit PedersenHash {
parameters: [group; 256];
function new(parameters: [group; 256]) -> Self {
return Self { parameters: parameters };
}
function hash(self, bits: [bool; 256]) -> group {
let digest: group = 0group;
for i in 0..256 {
if bits[i] {
digest += self.parameters[i];
}
}
return digest;
}
}
function main() {
// Initialize circuit
let rect = Rectangle::new(25u32, 50u32);
let area = rect.area();
console.log("Area: {} square pixels", area);
// Static function call
let r2 = Rectangle { width: 10u32, height: 20u32 };
}
```
--------------------------------
### Get Record Commitments
Source: https://github.com/authentiquo/leo_mcp/blob/main/autogen/testnet/private_endpoints/08_getrecordcommitments.md
Retrieves a list of record commitments stored on the full node.
```APIDOC
## GET /getrecordcommitments
### Description
Returns a list of record commitments that are stored on the full node.
### Method
GET
### Endpoint
/getrecordcommitments
### Parameters
#### Query Parameters
None
#### Request Body
None
### Request Example
```json
{
"jsonrpc": "2.0",
"id": "documentation",
"method": "getrecordcommitments",
"params": []
}
```
### Response
#### Success Response (200)
- **result** (array) - The list of stored record commitments
#### Response Example
```json
{
"result": [
{
"commitment": "exampleCommitment1",
"blockHeight": 100
},
{
"commitment": "exampleCommitment2",
"blockHeight": 101
}
]
}
```
```
--------------------------------
### Test Aleo Program Execution with Arguments (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Demonstrates how to test Leo program execution with specific input arguments. This allows for verifying program logic with different values.
```bash
leo run main 1u32 2u32
leo execute main 1u32 2u32
```
--------------------------------
### GET /getConnectionCount
Source: https://github.com/authentiquo/leo_mcp/blob/main/autogen/testnet/public_endpoints/06_getconnectioncount.md
Retrieves the number of connected peers this node has. This is useful for monitoring network connectivity.
```APIDOC
## GET /getConnectionCount
### Description
Returns the number of connected peers this node has.
### Method
GET
### Endpoint
/getConnectionCount
### Parameters
#### Query Parameters
None
#### Request Body
None
### Request Example
```ignore
curl -X GET http://127.0.0.1:3030/getConnectionCount
```
### Response
#### Success Response (200)
- **result** (number) - The number of connected nodes
#### Response Example
```json
{
"result": 15
}
```
```
--------------------------------
### Run and Execute Aleo Programs Locally (Bash)
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/modulo_7.md
Commands to compile, run, and execute Leo programs locally. 'leo run' compiles and executes, while 'leo execute' also synthesizes circuits and generates keys. 'leo help' provides further assistance.
```bash
leo run
leo execute
leo help
```
--------------------------------
### Create New Leo Package (`leo new`)
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/cli/01_new.md
Initializes a new Leo package by creating a directory with the specified name. Package names must be in kebab-case. The command generates a standard project structure including manifest, README, inputs, and source files.
```bash
leo new {$NAME}
```
--------------------------------
### GET /node/info
Source: https://github.com/authentiquo/leo_mcp/blob/main/autogen/testnet/public_endpoints/07_getnodeinfo.md
Retrieves information about the node's current status, such as whether it is acting as a miner or is in the process of syncing.
```APIDOC
## GET /node/info
### Description
Returns information about the node, including its mining and syncing status.
### Method
GET
### Endpoint
/node/info
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```ignore
curl http://127.0.0.1:3030/node/info
```
### Response
#### Success Response (200)
- **is_miner** (boolean) - Flag indicating if the node is a miner
- **is_snycing** (boolean) - Flag indicating if the node currently syncing
#### Response Example
```json
{
"is_miner": true,
"is_snycing": false
}
```
```
--------------------------------
### snarkOS CLI Help Information
Source: https://github.com/authentiquo/leo_mcp/blob/main/testnet/getting_started/01_installation.md
Displays the comprehensive help information for the snarkOS command-line interface. This includes all available flags and options for configuring node behavior, networking, and mining.
```bash
snarkos --help
```
--------------------------------
### Increment Counter Example in Leo
Source: https://github.com/authentiquo/leo_mcp/blob/main/modules/module_3/06_mappings.md
Provides a complete Leo program example demonstrating a counter that increments its value stored in a mapping. It includes the `finalize` block for updating the count and a `transition` to trigger the increment. The example utilizes `Mapping::get_or_use` and `Mapping::set`.
```leo
program mappings_counter.aleo {
mapping accumulator: u8 => u64; // key: counter_id, value: count
// Finalize logic: Increments the counter at key 0u8
finalize increment_state(public counter_key: u8) {
// Get current count for the key, default to 0 if not present
let current_count: u64 = Mapping::get_or_use(accumulator, counter_key, 0u64);
// Calculate the new count
let new_count: u64 = current_count + 1u64;
// Store the new count back into the mapping
Mapping::set(accumulator, counter_key, new_count);
}
// Transition: Called by the user off-chain
transition increment() {
// Perform any necessary off-chain checks or logic here.
// For this simple counter, we just need to trigger the finalize.
// Call the finalize block, passing the key 0u8 as a public argument
finalize(0u8);
}
}
```
--------------------------------
### Install Rusty Hook
Source: https://github.com/authentiquo/leo_mcp/blob/main/developer/additional_material/03_contributing.md
Installs the Rusty Hook tool using Cargo, a package manager for Rust. This tool is required for building Leo from source.
```bash
cargo install rusty-hook
```