### Install project dependencies Source: https://github.com/abdelstark/madara/blob/main/cairo-contracts/README.md Run this command to install the project dependencies using Poetry. ```bash poetry install ``` -------------------------------- ### Install Starkli Source: https://github.com/abdelstark/madara/blob/main/cairo-contracts/README.md Commands to download and install the Starkli toolchain. ```bash curl https://get.starkli.sh | sh starkliup ``` -------------------------------- ### Setup Madara Instance Source: https://github.com/abdelstark/madara/blob/main/starknet-rpc-test/README.md Set up a Madara instance for development. This command should be run once. ```bash ./target/release/madara setup --dev --from-local=./configs ``` -------------------------------- ### Run Madara Setup and Benchmarking Source: https://github.com/abdelstark/madara/blob/main/README.md Execute the Madara setup command and then run flamegraph to generate performance flamegraphs. This is useful for identifying performance bottlenecks. Ensure you have a transaction benchmarker running in parallel. ```bash ./target/release/madara setup flamegraph --root --open -- ./target/release/madara --dev ``` -------------------------------- ### Install Taplo CLI with Yarn Source: https://github.com/abdelstark/madara/blob/main/taplo/README.md Installs the Taplo CLI globally using Yarn. This is an alternative installation method. ```bash yarn global add @taplo/cli ``` -------------------------------- ### Install Taplo CLI with NPM Source: https://github.com/abdelstark/madara/blob/main/taplo/README.md Installs the Taplo CLI globally using NPM. This is another alternative installation method. ```bash npm install -g @taplo/cli ``` -------------------------------- ### Install Rust Toolchain Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Installs the Rust toolchain using rustup. This is a prerequisite for building and running Madara. ```bash rustup show ``` -------------------------------- ### Genesis Configuration Example Source: https://context7.com/abdelstark/madara/llms.txt A JSON example of a genesis configuration for Madara, defining initial chain state including contracts, classes, and storage. ```json { "contract_classes": [ { "class_hash": "0x0279d77db761fba82e0054125a6fdb5f6baa6286fa3fb73450cc44d193c2d37f", "class": { "path": "cairo-contracts/NoValidateAccount.json", "version": 0 } } ], "contracts": [ { "address": "0x1", "class_hash": "0x0279d77db761fba82e0054125a6fdb5f6baa6286fa3fb73450cc44d193c2d37f" } ], "storage": [ { "key": ["0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", "0x341c1bdfd89f69748aa00b5742b03adbffd79b8e80cab5c50d91cd8c2a79be1"], "value": "0x4574686572" } ], "fee_token_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", "chain_id": "0x534e5f474f45524c49" } ``` -------------------------------- ### Deploy Faucet via Docker Source: https://github.com/abdelstark/madara/blob/main/docs/faucet-setup.md Commands to clone the infrastructure repository and start the Starkcet faucet containers. ```bash git clone https://github.com/keep-starknet-strange/madara-infra cd madara-infra/starknet-stack/ docker-compose up -d starkcet-front starkcet-back ``` -------------------------------- ### Start Development Node Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Starts the Madara node in development mode after the chain has been set up. ```bash cargo run --release -- --dev ``` -------------------------------- ### Install Taplo CLI with Cargo Source: https://github.com/abdelstark/madara/blob/main/taplo/README.md Installs the Taplo CLI using Cargo. Ensure you have Rust and Cargo installed. ```bash cargo install taplo-cli --locked ``` -------------------------------- ### Clone and Test Repository Source: https://github.com/abdelstark/madara/blob/main/docs/CONTRIBUTING.md Initial setup commands to clone the Madara repository and verify the build with tests. ```sh git clone https://github.com/keep-starknet-strange/madara cd madara cargo test ``` -------------------------------- ### Run Madara Node Source: https://github.com/abdelstark/madara/blob/main/docs/faucet-setup.md Commands to initialize and start a local Madara node instance. ```bash cargo run --release -- setup cargo run --release -- run --dev ``` -------------------------------- ### Setup Single-Node Development Chain Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Builds and launches a template node for a single-node development chain. This command loads the genesis state into the file system. ```bash cargo run --release -- setup --chain=dev --from-remote ``` -------------------------------- ### Integration Test Example Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md An example of an integration test using rstest and starknet-rs to verify RPC behavior. ```rust #[rstest] #[tokio::test] async fn fail_non_existing_block(#[future] madara: MadaraClient) -> Result<(), anyhow::Error> { // We retrieve the madara client let madara = madara.await; // We get the RPC Provider to interact with the madara node let rpc = madara.get_starknet_client(); // Expected values let test_contract_class_hash = FieldElement::from_hex_be(TEST_CONTRACT_CLASS_HASH).expect("Invalid Contract Address"); // Assertions assert_matches!( rpc .get_class( BlockId::Number(100), test_contract_class_hash, ) .await, Err(StarknetProviderError(StarknetErrorWithMessage { code: MaybeUnknownErrorCode::Known(code), .. })) if code == StarknetError::BlockNotFound ); Ok(()) } ``` -------------------------------- ### Start a single node development chain Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Initializes a local development network using the specified Docker tag. ```bash docker run --rm [TAG] --dev ``` -------------------------------- ### Run Madara Node Source: https://github.com/abdelstark/madara/blob/main/starknet-rpc-test/README.md Start the Madara node in development mode with manual sealing. ```bash ./target/release/madara --dev --sealing=manual ``` -------------------------------- ### Start DA Devnet Node Source: https://github.com/abdelstark/madara/blob/main/docs/da-contribution.md Execute this script to start the Data Availability development network node. Replace `` with the specific DA layer you are using. ```bash bash scripts/da_devnet.sh ``` -------------------------------- ### Run Compiled Madara Node Source: https://github.com/abdelstark/madara/blob/main/docs/sharingan-starter-pack.md Commands to initialize and start the locally compiled Madara binary. ```bash ./target/release/madara setup ./target/release/madara --testnet sharingan --telemetry-url 'wss://telemetry.madara.zone/submit 0' ``` -------------------------------- ### Run Madara Fullnode with Docker Source: https://github.com/abdelstark/madara/blob/main/docs/sharingan-starter-pack.md Starts the Madara fullnode container with the necessary port mappings and telemetry configuration. ```bash docker run --rm -d \ -p 9944:9944 -p 30333:30333 \ --name sharingan-fullnode \ -v sharingan-volume:/root/.madara \ ghcr.io/keep-starknet-strange/madara:v0.1.0-testnet-sharingan-beta.7.1 \ --testnet sharingan \ --telemetry-url 'wss://telemetry.madara.zone/submit 0' ``` -------------------------------- ### Transfer Tokens with starknet.js Source: https://github.com/abdelstark/madara/blob/main/docs/faucet-setup.md Example of programmatically transferring tokens from a genesis account using the starknet.js library. ```javascript import * as starknet from "starknet"; import ERC20 from "./ERC20.json" assert { type: "json" }; const eth_address = "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; const provider = new starknet.RpcProvider({ nodeUrl: "http://localhost:9944", }); const account = new starknet.Account( provider, "0x0000000000000000000000000000000000000000000000000000000000000004", "0x00c1cf1490de1352865301bb8705143f3ef938f97fdf892f1090dcb5ac7bcd1d", "1", ); async function transfer(to) { const contract = new starknet.Contract(ERC20.abi, eth_address, provider); let result = contract.populate("transfer", { recipient: to, amount: { low: 10000000, high: 0, }, }); let hash = await account.execute(result, undefined, {}); console.log("Txn hash - ", hash); } transfer("0x100"); ``` -------------------------------- ### Build and Run Madara Locally Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md Build Madara using Cargo and then set it up and run it. This method starts the sequencer without peers, suitable for testing RPC accessibility and serialization. ```bash cargo build --release ``` ```bash ./target/release/madara setup ``` ```bash ./target/release/madara ``` -------------------------------- ### Run Node with Manual or Instant Sealing Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Starts the development node with manual or instant block sealing enabled. Use manual sealing to produce blocks via RPC, or instant sealing for immediate block production. ```bash cargo run --release -- --dev --sealing=manual ``` ```bash # Or ``` ```bash cargo run --release -- --dev --sealing=instant ``` -------------------------------- ### Automated RPC Testing Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md Commands to start the Madara node and execute automated Hurl tests. ```bash cargo run --release -- --dev ``` ```bash hurl --variables-file examples/rpc/hurl.config --test examples/rpc/**/*.hurl ``` -------------------------------- ### Example Contract Class Definition Source: https://github.com/abdelstark/madara/blob/main/docs/genesis.md Defines a contract class using a path to the compiled contract and its Cairo version. Use this format when the full serialized class is not provided. ```json { "path": "cairo-contracts/NoValidateAccount.json", "version": 0 } ``` -------------------------------- ### Get Transaction Receipt via starknet_getTransactionReceipt Source: https://context7.com/abdelstark/madara/llms.txt Returns the execution receipt for a transaction, including status, events, and gas usage. ```bash curl -X POST http://localhost:9944 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "starknet_getTransactionReceipt", "params": [ "0x3024c929c1bec3a872441d8ad6a8e5b0c5b931d2bf75dc5dbad2b93c1c4dec0" ], "id": 1 }' # Response: # { # "jsonrpc": "2.0", # "result": { # "transaction_hash": "0x3024c929c1bec3a872441d8ad6a8e5b0c5b931d2bf75dc5dbad2b93c1c4dec0", # "status": "ACCEPTED_ON_L2", # "actual_fee": {"amount": "0x1234", "unit": "WEI"}, # "events": [...], # "execution_resources": {...} # }, # "id": 1 # } ``` -------------------------------- ### Madara Client Storage Package Configuration Source: https://github.com/abdelstark/madara/blob/main/docs/contributor-starter-pack.md This snippet shows the Cargo.toml configuration for Madara's client storage package. It's an example of how Madara adheres to the 'mc_' prefix convention for its client implementation libraries, similar to Substrate's 'sc_' convention. ```toml [package] name = "madara-client-storage" version = "0.1.0" edition = "2021" [dependencies] # --snip-- ``` -------------------------------- ### Set Log Level with RUST_LOG Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Configures the log level for the Madara node using the RUST_LOG environment variable. This example sets the runtime logs to 'info'. ```bash RUSTLOG=runtime=info cargo run --release -- --dev ``` -------------------------------- ### Get Madara Predeployed Accounts Source: https://context7.com/abdelstark/madara/llms.txt Madara-specific RPC method `madara_predeployedAccounts` retrieves information on accounts pre-configured in the genesis state. This is particularly useful for development and testing environments. ```bash curl -X POST http://localhost:9944 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "madara_predeployedAccounts", "params": [], "id": 1 }' ``` -------------------------------- ### Starknet Get Storage At Source: https://context7.com/abdelstark/madara/llms.txt Retrieves the value stored at a specific storage key for a given contract address at the specified block. Essential for reading contract state variables directly. ```APIDOC ## GET starknet_getStorageAt ### Description Retrieves the value stored at a specific storage key for a given contract address at the specified block. ### Method POST ### Endpoint http://localhost:9944 ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **contract_address** (string) - Required - The address of the contract. - **storage_key** (string) - Required - The storage key. - **block_id** (string) - Optional - The block identifier (e.g., "latest", block number, or block hash). ```json { "jsonrpc": "2.0", "method": "starknet_getStorageAt", "params": [ "0x0000000000000000000000000000000000000000000000000000000000001111", "0x02900ac0f31b4cd8101abb46a91021989eb7c9f6e2a5417186e476f08429efce", "latest" ], "id": 1 } ``` ### Response #### Success Response (200) - **result** (string) - The value stored at the storage key. #### Response Example ```json { "jsonrpc": "2.0", "result": "0x1234567890abcdef", "id": 1 } ``` ``` -------------------------------- ### Activate poetry environment Source: https://github.com/abdelstark/madara/blob/main/cairo-contracts/README.md Enter the poetry shell to access the project environment. ```bash poetry shell ``` -------------------------------- ### Violating SRP with a monolithic Report struct Source: https://github.com/abdelstark/madara/blob/main/docs/madara-coding-principles.md This example shows a struct that handles both data formatting and printing, violating the Single Responsibility Principle. ```rust pub struct Report { title: String, data: Vec, } impl Report { pub fn new(title: String, data: Vec) -> Report { Report { title, data } } pub fn print(&self) { println!("Title: {}", self.title); for line in &self.data { println!("{}", line); } } pub fn format(&mut self) { self.data = self.data.iter().map(|line| format!("{}\n", line)).collect(); } } ``` -------------------------------- ### Display Madara Help Information Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Displays all available parameters and subcommands for the Madara executable. This is useful for exploring the node's capabilities. ```bash ./target/release/madara -h ``` -------------------------------- ### Cairo 1 No-Validate Account Contract Source: https://context7.com/abdelstark/madara/llms.txt An example of a Cairo 1 account contract that skips signature verification, useful for testing purposes on Madara. ```cairo #[starknet::contract] mod Account { use array::{ArrayTrait, SpanTrait}; use box::BoxTrait; use starknet::account::Call; use starknet::{ ContractAddress, call_contract_syscall }; use zeroable::Zeroable; #[storage] struct Storage { public_key: felt252 } #[constructor] fn constructor(ref self: ContractState, public_key_: felt252) { self.public_key.write(public_key_); } impl AccountContractImpl of starknet::account::AccountContract { fn __validate_declare__(self: @ContractState, class_hash: felt252) -> felt252 { starknet::VALIDATED } fn __validate__(ref self: ContractState, calls: Array) -> felt252 { starknet::VALIDATED } fn __execute__(ref self: ContractState, mut calls: Array) -> Array> { assert(starknet::get_caller_address().is_zero(), 'INVALID_CALLER'); let tx_info = starknet::get_tx_info().unbox(); assert(tx_info.version != 0, 'INVALID_TX_VERSION'); let mut result = ArrayTrait::new(); loop { match calls.pop_front() { Option::Some(call) => { let mut res = call_contract_syscall( address: call.to, entry_point_selector: call.selector, calldata: call.calldata ).unwrap(); result.append(res); }, Option::None(()): break; , }; }; result } } } ``` -------------------------------- ### Build Madara Binary Source: https://github.com/abdelstark/madara/blob/main/starknet-rpc-test/README.md Build the Madara binary using Cargo. Ensure you have test dependencies compiled first. ```bash cargo build --profile release ``` -------------------------------- ### Stop DA Devnet Node Source: https://github.com/abdelstark/madara/blob/main/docs/da-contribution.md Run this script to shut down the Data Availability development network node. Use the same `` identifier that was used to start the node. ```bash bash scripts/stop_da_devnet.sh ``` -------------------------------- ### Run Integration Tests Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md Command to execute integration tests with logging enabled. ```bash MADARA_LOG=true cargo test --package starknet-rpc-test -- --exact --nocapture --test-threads=1 ``` -------------------------------- ### Get the last block hash Source: https://github.com/abdelstark/madara/blob/main/docs/sharingan-starter-pack.md Retrieve the latest block hash from the Sharingan node using either the Starkli CLI or a direct JSON RPC request. ```bash starkli block-hash --rpc http://52.7.206.208:9944 ``` ```bash curl --header "Content-Type: application/json" \ --request POST \ --data '{ "jsonrpc": "2.0", "method": "starknet_blockHashAndNumber", "params": ["latest"], "id":1}' \ http://52.7.206.208:9944 ``` -------------------------------- ### Execute testing scripts Source: https://github.com/abdelstark/madara/blob/main/cairo-contracts/README.md Scripts for compiling contracts or deploying specific tokens like ERC20. ```bash python scripts/compile_all.py ``` ```bash python scripts/deploy_erc20.py ``` -------------------------------- ### Manage Madara Node Source: https://context7.com/abdelstark/madara/llms.txt Commands for building, configuring, and running a local Madara node using cargo or Docker. ```bash # Install Rust via rustup rustup show # Setup node with genesis state from remote cargo run --release -- setup --chain=dev --from-remote # Start development node cargo run --release -- --dev # Run with manual sealing (produce blocks via RPC) cargo run --release -- --dev --sealing=manual # Run with instant sealing cargo run --release -- --dev --sealing=instant # Run with custom base path for persistent storage cargo run --release -- --chain=dev --force-authoring --alice --rpc-external --rpc-methods=unsafe --base-path=/path/to/data # Enable debug logging RUST_LOG=runtime=info cargo run --release -- --dev # Run in Docker docker run --rm ghcr.io/keep-starknet-strange/madara:latest --dev ``` -------------------------------- ### Build Custom Chain Specs Source: https://context7.com/abdelstark/madara/llms.txt Use these commands to build plain and raw chain specifications for Madara networks. The raw format is optimized for production. ```bash cargo run --release -- build-spec --chain local > chain-specs/madara-local-testnet-plain.json ``` ```bash cargo run --release -- build-spec \ --chain chain-specs/madara-local-testnet-plain.json \ --raw > chain-specs/madara-local-testnet.json ``` ```bash cargo run --release -- \ --chain chain-specs/madara-local-testnet.json \ --base-path /data/madara \ --rpc-external \ --rpc-methods=safe ``` -------------------------------- ### Initialize MadaraRunner with custom arguments Source: https://github.com/abdelstark/madara/blob/main/madara-test-runner/README.md Configures a Madara node instance using MadaraArgs, including settlement layer and base path settings. ```rust use madara_test_runner::{MadaraRunner, MadaraArgs, Settlement}; let madara_client = MadaraRunner::new( MadaraArgs { settlement: Some(Settlement::Ethereum), settlement_conf: Some(format!("/tmp/madara/chains/dev/eth-config.json").into()) base_path: Some(format!("/tmp/madara").into()), } ) .await; ``` -------------------------------- ### Run Madara with DA Layer Configuration Source: https://github.com/abdelstark/madara/blob/main/docs/da-contribution.md Launch the Madara node with development mode enabled, specifying the DA layer and its configuration file. Ensure the path to the configuration file is correct for your chosen DA layer. ```bash ./target/release/madara --dev --da-layer --da-conf examples/da-confs/.json ``` -------------------------------- ### Starknet Block Hash and Number Source: https://context7.com/abdelstark/madara/llms.txt Returns both the block hash and block number of the most recent accepted block in a single call, useful for getting a consistent view of the chain head. ```APIDOC ## GET starknet_blockHashAndNumber ### Description Returns both the block hash and block number of the most recent accepted block. ### Method POST ### Endpoint http://localhost:9944 ### Parameters #### Query Parameters None #### Request Body ```json { "jsonrpc": "2.0", "method": "starknet_blockHashAndNumber", "params": [], "id": 1 } ``` ### Response #### Success Response (200) - **result** (object) - **block_hash** (string) - The hash of the block. - **block_number** (integer) - The number of the block. #### Response Example ```json { "jsonrpc": "2.0", "result": { "block_hash": "0x4c5efa8dc6f...", "block_number": 42 }, "id": 1 } ``` ``` -------------------------------- ### Generate Declare Contracts Source: https://github.com/abdelstark/madara/blob/main/starknet-rpc-test/README.md Generate multiple Cairo contract artifacts with different class hashes for testing the declare class operation. Ensure you are in the correct directory and have the specified scarb version installed. ```bash cd starknet-rpc-test/contracts ./generate_declare_contracts.sh 10 ``` -------------------------------- ### Build and Run Madara with Docker Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md Run Madara using Docker for testing RPC methods related to transactions and blocks. This is the preferred method for a comprehensive test environment. ```bash docker run [TAG] --dev ``` -------------------------------- ### Get State Update Source: https://context7.com/abdelstark/madara/llms.txt Use `starknet_getStateUpdate` to retrieve all state changes within a specific block. This includes storage differences, newly deployed contracts, declared classes, and nonce updates, crucial for state synchronization. ```bash curl -X POST http://localhost:9944 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "starknet_getStateUpdate", "params": ["latest"], "id": 1 }' ``` -------------------------------- ### Run Starknet RPC Tests Source: https://github.com/abdelstark/madara/blob/main/starknet-rpc-test/README.md Execute Starknet RPC tests using Cargo. The --nocapture flag shows test output. ```bash cargo test --package starknet-rpc-test works_with_storage_change -- --nocapture ``` -------------------------------- ### Manage Docker Volume for Sharingan Source: https://github.com/abdelstark/madara/blob/main/docs/sharingan-starter-pack.md Commands to create, inspect, or remove the Docker volume used for storing node data. ```bash docker volume create sharingan-volume ``` ```bash docker volume rm sharingan-volume ``` ```bash docker volume inspect sharingan-volume ``` -------------------------------- ### Simplify Logic with KISS Principle Source: https://github.com/abdelstark/madara/blob/main/docs/madara-coding-principles.md Compares a verbose manual loop implementation with a concise idiomatic Rust approach. ```rust // Complex way fn calculate_sum(numbers: &[i32]) -> i32 { let mut sum = 0; for i in 0..numbers.len() { sum += numbers[i]; } sum } // KISS way fn calculate_sum(numbers: &[i32]) -> i32 { numbers.iter().sum() } ``` -------------------------------- ### Decentralisation Features Compatibility Source: https://github.com/abdelstark/madara/blob/main/docs/starknet_features_compatibility.md Compatibility status for different decentralization models in Starknet. ```APIDOC ## Decentralisation Features Compatibility ### Description Compatibility status for different decentralization models in Starknet. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **Single node** (boolean) - Indicates if single node support is available. - **Small pool of nodes (POA)** (boolean) - Indicates if Proof-of-Authority (POA) is supported. - **Large pool of nodes (Base consensus)** (boolean) - Indicates if base consensus for large node pools is supported. - **Large pool of nodes (Custom consensus)** (boolean) - Indicates if custom consensus for large node pools is supported. #### Response Example { "Single node": true, "Small pool of nodes (POA)": false, "Large pool of nodes (Base consensus)": false, "Large pool of nodes (Custom consensus)": false } ``` -------------------------------- ### RPC Methods Compatibility Source: https://github.com/abdelstark/madara/blob/main/docs/starknet_features_compatibility.md Compatibility status for various Starknet RPC methods. ```APIDOC ## RPC Methods Compatibility ### Description Compatibility status for various Starknet RPC methods. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **starknet_getBlockWithTxHashes** (boolean) - Indicates if the RPC method is supported. - **starknet_getBlockWithTxs** (boolean) - Indicates if the RPC method is supported. - **starknet_getStateUpdate** (boolean) - Indicates if the RPC method is supported. - **starknet_getStorageAt** (boolean) - Indicates if the RPC method is supported. - **starknet_getTransactionByHash** (boolean) - Indicates if the RPC method is supported. - **starknet_getTransactionByBlockIdAndIndex** (boolean) - Indicates if the RPC method is supported. - **starknet_getTransactionReceipt** (boolean) - Indicates if the RPC method is supported. - **starknet_getClass** (boolean) - Indicates if the RPC method is supported. - **starknet_getClassHashAt** (boolean) - Indicates if the RPC method is supported. - **starknet_getClassAt** (boolean) - Indicates if the RPC method is supported. - **starknet_getBlockTransactionCount** (boolean) - Indicates if the RPC method is supported. - **starknet_call** (boolean) - Indicates if the RPC method is supported. - **starknet_estimateFee** (boolean) - Indicates if the RPC method is supported. - **starknet_blockNumber** (boolean) - Indicates if the RPC method is supported. - **starknet_blockHashAndNumber** (boolean) - Indicates if the RPC method is supported. - **starknet_chainId** (boolean) - Indicates if the RPC method is supported. - **starknet_pendingTransactions** (boolean) - Indicates if the RPC method is supported. - **starknet_syncing** (boolean) - Indicates if the RPC method is supported. - **starknet_getEvents** (boolean) - Indicates if the RPC method is supported. - **starknet_getNonce** (boolean) - Indicates if the RPC method is supported. - **starknet_traceTransaction** (boolean) - Indicates if the RPC method is supported. - **starknet_simulateTransaction** (boolean) - Indicates if the RPC method is supported. - **starknet_traceBlockTransactions** (boolean) - Indicates if the RPC method is supported. - **starknet_addInvokeTransaction** (boolean) - Indicates if the RPC method is supported. - **starknet_addDeclareTransaction** (boolean) - Indicates if the RPC method is supported. - **starknet_addDeployAccountTransaction** (boolean) - Indicates if the RPC method is supported. #### Response Example { "starknet_getBlockWithTxHashes": true, "starknet_getBlockWithTxs": true, "starknet_getStateUpdate": false, "starknet_getStorageAt": false, "starknet_getTransactionByHash": true, "starknet_getTransactionByBlockIdAndIndex": true, "starknet_getTransactionReceipt": true, "starknet_getClass": true, "starknet_getClassHashAt": true, "starknet_getClassAt": true, "starknet_getBlockTransactionCount": true, "starknet_call": true, "starknet_estimateFee": true, "starknet_blockNumber": true, "starknet_blockHashAndNumber": true, "starknet_chainId": true, "starknet_pendingTransactions": true, "starknet_syncing": true, "starknet_getEvents": true, "starknet_getNonce": true, "starknet_traceTransaction": false, "starknet_simulateTransaction": false, "starknet_traceBlockTransactions": false, "starknet_addInvokeTransaction": true, "starknet_addDeclareTransaction": true, "starknet_addDeployAccountTransaction": true } ``` -------------------------------- ### Implement Runtime API Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md Provide the implementation for the runtime API function within the runtime crate. ```rust // crates/runtime/src/lib.rs impl pallet_starknet::runtime_api::StarknetRuntimeApi for Runtime { fn call(address: ContractAddressWrapper, function_selector: Felt252Wrapper, calldata: Vec) -> Result, DispatchError> { Starknet::call_contract(address, function_selector, calldata) } fn my_function() -> H256 { // Here comes the logic to interact with storage, pallets... H256::from_low_u64_be(1234) } } ``` -------------------------------- ### Run and manage Madara nodes in Docker Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Commands for running a node without recompilation and purging the local development chain. ```bash # Run Substrate node without re-compiling docker run --rm [TAG] --dev --ws-external # Purge the local dev chain docker run --rm [TAG] purge-chain --dev ``` -------------------------------- ### Build Custom Chain Specification Source: https://github.com/abdelstark/madara/blob/main/docs/getting-started.md Generates custom chain specifications for a local testnet. First, build a plain chain spec, then create a raw chain spec from it. ```bash cargo run --release -- build-spec --chain local > chain-specs/madara-local-testnet-plain.json ``` ```bash # Build final raw chain spec ``` ```bash cargo run --release -- build-spec --chain chain-specs/madara-local-testnet-plain.json --raw > chain-specs/madara-local-testnet.json ``` -------------------------------- ### Retrieve Block Data via starknet_getBlockWithTxs Source: https://context7.com/abdelstark/madara/llms.txt Fetches detailed block information including all transactions. Supports block hash, block number, or tags like 'latest'. ```bash curl -X POST http://localhost:9944 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "starknet_getBlockWithTxs", "params": ["latest"], "id": 1 }' # Response: # { # "jsonrpc": "2.0", # "result": { # "block_hash": "0x...", # "parent_hash": "0x...", # "block_number": 42, # "sequencer_address": "0x...", # "timestamp": 1234567890, # "transactions": [ # { # "type": "INVOKE", # "transaction_hash": "0x...", # "sender_address": "0x...", # "calldata": [...] # } # ] # }, # "id": 1 # } ``` -------------------------------- ### Test RPC Endpoint Locally Source: https://github.com/abdelstark/madara/blob/main/docs/rpc-contribution.md Use curl to manually verify a custom RPC endpoint. Ensure the method name is prefixed with starknet_. ```sh curl -X POST \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"starknet_myEndpoint","params":[{"some_str": "Madara", "some_u64": 1234}]}' \ http://localhost:9933 ``` -------------------------------- ### Run DA Tests in da-test Crate Source: https://github.com/abdelstark/madara/blob/main/docs/da-contribution.md Navigate to the `da-test` directory and execute the tests using Cargo. Set the `DA_LAYER` environment variable to your active DA layer. ```bash cd da-test DA_LAYER= cargo test ``` -------------------------------- ### Check TOML file formatting with Taplo Source: https://github.com/abdelstark/madara/blob/main/taplo/README.md Checks TOML files for formatting issues using the Taplo CLI. Requires a 'taplo.toml' configuration file. ```bash npx @taplo/cli fmt --config taplo.toml --check ``` -------------------------------- ### Fetch Transaction Details via starknet_getTransactionByHash Source: https://context7.com/abdelstark/madara/llms.txt Retrieves complete transaction data using its hash. Returns transaction type, version, signature, and specific fields. ```bash curl -X POST http://localhost:9944 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "starknet_getTransactionByHash", "params": [ "0x3024c929c1bec3a872441d8ad6a8e5b0c5b931d2bf75dc5dbad2b93c1c4dec0" ], "id": 1 }' # Response: # { # "jsonrpc": "2.0", # "result": { # "type": "INVOKE", # "transaction_hash": "0x3024c929c1bec3a872441d8ad6a8e5b0c5b931d2bf75dc5dbad2b93c1c4dec0", # "max_fee": "0xdeadb", # "version": "0x1", # "signature": ["0x...", "0x..."], # "nonce": "0x1", # "sender_address": "0x...", # "calldata": [...] # }, # "id": 1 # } ``` -------------------------------- ### Retrieve Contract Class Definition Source: https://context7.com/abdelstark/madara/llms.txt Fetch the contract class definition, including ABI and code, using `starknet_getClass` by providing the class hash and block identifier. This method returns the full Sierra or Cairo 0 contract class. ```bash curl -X POST http://localhost:9944 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "starknet_getClass", "params": [ "latest", "0x00d0e183745e9dae3e4e78a8ffedcce0903fc4900beace4e0abf192d4c202da3" ], "id": 1 }' ``` -------------------------------- ### Optimisation Features Compatibility Source: https://github.com/abdelstark/madara/blob/main/docs/starknet_features_compatibility.md Compatibility status for various optimization techniques in Starknet. ```APIDOC ## Optimisation Features Compatibility ### Description Compatibility status for various optimization techniques in Starknet. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **Commitments** (boolean) - Indicates if commitments optimization is supported. - **Transaction validity before mempool** (boolean) - Indicates if pre-mempool transaction validity optimization is supported. #### Response Example { "Commitments": false, "Transaction validity before mempool": false } ``` -------------------------------- ### POST starknet_syncing Source: https://context7.com/abdelstark/madara/llms.txt Returns the synchronization status of the node. ```APIDOC ## POST starknet_syncing ### Description Returns the synchronization status of the node. Returns false if fully synced, or an object containing current/highest block numbers if syncing is in progress. ### Method POST ### Endpoint http://localhost:9944 ### Request Body - **params** (array) - Required - Empty array. ### Request Example { "jsonrpc": "2.0", "method": "starknet_syncing", "params": [], "id": 1 } ### Response #### Success Response (200) - **result** (boolean|object) - False if synced, or object with starting_block_num, current_block_num, and highest_block_num. ```