### Example: Install Counter Contract Source: https://docs.casper.network/developers/cli/installing-contracts This example demonstrates installing a 'counter-installer.wasm' contract to a local NCTL network. It includes specific node, chain, and file paths. ```bash casper-client put-transaction session \ --node-address http://localhost:11101 \ --chain-name casper-net-1 \ --secret-key ~/casper/casper-nctl/assets/net-1/users/user-1/secret_key.pem \ --gas-price-tolerance 10 \ --pricing-mode fixed \ --transaction-path ~/test_contracts/counter_installer.wasm \ --session-entry-point call \ --category 'install-upgrade' ``` -------------------------------- ### Set Up and Start Local Network Source: https://docs.casper.network/developers/dapps/setup-nctl Set up all necessary assets for a local network (binaries, chainspec, config, faucet, keys) and start the network. The default setup includes 10 nodes and 10 sidecars. ```bash nctl-assets-setup && nctl-start ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://docs.casper.network/developers/dapps/template-frontend Install project dependencies and run the Vite development server to test your application. Press 'q' to quit the server. ```bash npm install vite dev ``` -------------------------------- ### Setup and Start Local Casper Network Source: https://docs.casper.network/resources/beginner/counter/walkthrough Set up and start a local Casper network using NCTL. This command assumes NCTL is already installed and configured. ```bash nctl-assets-setup && nctl-start ``` -------------------------------- ### Running CEP-78 Install Example Source: https://docs.casper.network/resources/tokens/cep78/js-tutorial Executes a script to install a CEP-78 contract instance on the Casper network. Requires environment variables like NODE_URL and MASTER_KEY_PAIR_PATH to be set. ```bash npm run example:install ``` -------------------------------- ### Install Contract with Casper-Client (Rust) Source: https://docs.casper.network/developers/dapps/sdk/client-library-usage This Rust example demonstrates installing a contract using the casper-client crate. It requires specifying node address, deploy parameters including secret key path, and session/payment parameters. The output will be the deploy response. ```rust extern crate casper_client; async fn put_deploy(){ let maybe_rpc: &str = ""; let verbosity: u64 = 1; let node_address: &str = "http://135.181.216.142:7777"; let deploy_params: casper_client::DeployStrParams = casper_client::DeployStrParams{ secret_key:"./sk_testnet.pem", timestamp:"", ttl:"50s", gas_price:"1000000000", chain_name:"casper", // or "casper-test" dependencies: Vec::new(), session_account: "01daad67ebbcb725e02a1955a6617512b311435a21ca6d523085aa015d2d1b473a" }; // Without session args: // let session_args: Vec<&str> = Vec::new(); // With session args: let mut session_args: Vec<&str> = Vec::new(); session_args.push("argument:String='hello world'"); let session_params: casper_client::SessionStrParams = casper_client::SessionStrParams::with_path("./contract.wasm", session_args, ""); let payment_params: casper_client::PaymentStrParams = casper_client::PaymentStrParams::with_amount("10000000000"); let result = casper_client::put_deploy(maybe_rpc_id, node_address, verbosity_level, deploy_params, session_params, payment_params).await.unwrap(); println!("Deploy response: {:?}", result); } #[tokio::main] async fn main(){ send_transfer().await; } ``` -------------------------------- ### Install Casper Client Source: https://docs.casper.network/resources/quick-start Install the Casper client for interacting with the Casper network. ```bash cargo install casper-client ``` -------------------------------- ### Install Rustup Source: https://docs.casper.network/condor/local-setup Install Rustup, the toolchain installer for Rust, which is a prerequisite for building the Casper Client from source. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Install Zstandard Source: https://docs.casper.network/operators/maintenance/archiving-and-restoring Installs the Zstandard compression utility. Ensure you have the necessary permissions. ```bash sudo apt install zstd ``` -------------------------------- ### Install Python SDK Source: https://docs.casper.network/developers/dapps/sdk/python-sdk Install the pycspr library using pip. ```bash pip3 install pycspr ``` -------------------------------- ### Clone and Build Example Project Source: https://docs.casper.network/resources/advanced/list-auth-keys-tutorial Commands to clone the example repository, navigate to the directory, and build the tests. Ensure your Rust environment is prepared. ```bash git clone https://github.com/casper-ecosystem/tutorials-example-wasm cd tutorials-example-wasm/authorization-keys-example make prepare make test ``` -------------------------------- ### Get Block Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-2.0/schema.json Example for retrieving a Block from the network, with optional block identifier. ```json { "name": "chain_get_block", "summary": "returns a Block from the network", "params": [ { "name": "block_identifier", "schema": { "description": "The block identifier.", "$ref": "#/components/schemas/BlockIdentifier" }, "required": false } ], "result": { "name": "chain_get_block_result", "schema": { "description": "Result for \"chain_get_block\" RPC response.", "type": "object", "required": [ "api_version" ], "properties": { "api_version": { "description": "The RPC API version.", "type": "string" }, "block_with_signatures": { "description": "The block, if found.", "anyOf": [ { "$ref": "#/components/schemas/JsonBlockWithSignatures" }, { ``` -------------------------------- ### Run the Example Source: https://docs.casper.network/developers/dapps/sdk/csharp-sdk Execute the C# console application to retrieve the account balance. ```bash dotnet run ``` -------------------------------- ### Get Reward Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-2.0/schema.json Example of how to retrieve reward information for a specific era and validator. ```json { "name": "info_get_reward_example", "params": [ { "name": "era_identifier", "value": { "Era": 1 } }, { "name": "validator", "value": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c" }, { "name": "delegator", "value": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c" } ], "result": { "name": "info_get_reward_example_result", "value": { "api_version": "2.0.0", "reward_amount": "42", "era_id": 1, "delegation_rate": 20 } } } ``` -------------------------------- ### Running CEP-78 Usage Example Source: https://docs.casper.network/resources/tokens/cep78/js-tutorial Executes a script that tests the basic functionality of an installed CEP-78 contract, including minting, transferring, and burning tokens. It utilizes environment variables defined for the installation example. ```bash npm run example:usage ``` -------------------------------- ### Example: Calling Counter Contract by Package Hash and Version Source: https://docs.casper.network/developers/cli/calling-contracts This example demonstrates calling the 'counter-inc' entry point of the Counter contract using its specific package hash and version number. ```bash casper-client put-deploy \ --node-address http://65.21.235.219:7777 \ --chain-name casper-test \ --secret-key [KEY_PATH]/secret_key.pem \ --payment-amount 100000000 \ --session-package-hash hash-76a8c3daa6d6ac799ce9f46d82ac98efb271d2d64b517861ec89a06051ef019e \ --session-entry-point "counter-inc" \ --session-version 1 ``` -------------------------------- ### Installing npm Dependencies Source: https://docs.casper.network/resources/tokens/cep78/js-tutorial Installs the necessary Node.js dependencies for the CEP-78 JavaScript client examples. This command should be run in the project's root directory. ```bash npm i ``` -------------------------------- ### Set up SSH Directory and Authorized Keys Source: https://docs.casper.network/operators/setup/non-root-user These commands switch to the new user, create the .ssh directory, set appropriate permissions, and create the authorized_keys file for SSH key authentication. ```bash sudo su - mkdir .ssh chmod 700 .ssh touch .ssh/authorized_keys ``` -------------------------------- ### NCTL Transaction Installation Response Source: https://docs.casper.network/developers/dapps/nctl-test This is an example of the JSON response received after successfully installing a smart contract transaction via NCTL. Pay attention to the `transaction_hash`. ```json { "jsonrpc": "2.0", "id": 1294011212530641270, "result": { "api_version": "2.0.0", "transaction_hash": { "Version1": "efad4a969064b5f8189ea4d6dd2fba2926d01d583a35178c07d7b827de16789e" } } } ``` -------------------------------- ### Prepare and Build Counter Contract Source: https://docs.casper.network/resources/quick-start Navigate to the contract directory and prepare dependencies, then build the contract and its tests. ```bash cd counter make prepare make test ``` -------------------------------- ### Create Node Configuration from Example Source: https://docs.casper.network/operators/setup/basic-node-configuration Generates a `config.toml` file from a `config-example.toml` for a specific node version. Replace `[m_n_p]` with the current version using underscores. ```bash /etc/casper/config_from_example.sh [m_n_p] ``` -------------------------------- ### Get Dictionary Item Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-1.5/state_get_dictionary_item.json Demonstrates how to call the state_get_dictionary_item RPC method with a specific state root hash and dictionary identifier. This example shows the expected parameters and the structure of the successful response. ```json { "id": 1, "method": "state_get_dictionary_item", "params": [ "0808080808080808080808080808080808080808080808080808080808080808", { "URef": { "seed_uref": "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007", "dictionary_item_key": "a_unique_entry_identifier" } } ], "jsonrpc": "2.0" } ``` -------------------------------- ### State Get Dictionary Item Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-2.0/schema.json Demonstrates a request to retrieve a specific item from a contract's named keys. The example shows the parameters required, including the state root hash and a dictionary identifier. ```json { "name": "state_get_dictionary_item_example", "params": [ { "name": "state_root_hash", "value": "0808080808080808080808080808080808080808080808080808080808080808" }, { "name": "dictionary_identifier", "value": { "URef": { "seed_uref": "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007", "dictionary_item_key": "a_unique_entry_identifier" } } } ], "result": { "name": "state_get_dictionary_item_example_result", "value": { "api_version": "2.0.0", "dictionary_key": "dictionary-67518854aa916c97d4e53df8570c8217ccc259da2721b692102d76acd0ee8d1f", "stored_value": { "CLValue": { "cl_type": "U64", "bytes": "0100000000000000", "parsed": 1 } }, "merkle_proof": "01000000006ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a72536147614625016ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a72536147614625000000003529cde5c621f857f75f3810611eb4af3f998caaa9d4a3413cf799f99c67db0307010000006ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a7253614761462501010102000000006e06000000000074769d28aac597a36a03a932d4b43e4f10bf0403ee5c41dd035102553f5773631200b9e173e8f05361b681513c14e25e3138639eb03232581db7557c9e8dbbc83ce94500226a9a7fe4f2b7b88d5103a4fc7400f02bf89c860c9ccdd56951a2afe9be0e0267006d820fb5676eb2960e15722f7725f3f8f41030078f8b2e44bf0dc03f71b176d6e800dc5ae9805068c5be6da1a90b2528ee85db0609cc0fb4bd60bbd559f497a98b67f500e1e3e846592f4918234647fca39830b7e1e6ad6f5b7a99b39af823d82ba1873d000003000000010186ff500f287e9b53f823ae1582b1fa429dfede28015125fd233a31ca04d5012002015cc42669a55467a1fdf49750772bfc1aed59b9b085558eb81510e9b015a7c83b0301e3cf4a34b1db6bfa58808b686cb8fe21ebe0c1bcbcee522649d2b135fe510fe3" } } } ``` -------------------------------- ### CEP18 Token Test Setup with Arguments Source: https://docs.casper.network/resources/tokens/cep18/tests Sets up the test environment for CEP18 tokens, including creating test accounts and installing the contract. This function is useful for initializing a testing context with specific arguments for the token installation. ```rust // File https://github.com/casper-ecosystem/cep18/blob/dev/tests/src/utility/installer_request_builders.rs // Creating the `TestContext` struct. pub(crate) struct TestContext { pub(crate) cep18_token: ContractHash, pub(crate) cep18_test_contract_package: ContractPackageHash, } // Setting up the test instance of CEP-18. pub(crate) fn setup() -> (InMemoryWasmTestBuilder, TestContext) { setup_with_args(runtime_args! { ARG_NAME => TOKEN_NAME, ARG_SYMBOL => TOKEN_SYMBOL, ARG_DECIMALS => TOKEN_DECIMALS, ARG_TOTAL_SUPPLY => U256::from(TOKEN_TOTAL_SUPPLY), }) } // Establishing test accounts. pub(crate) fn setup_with_args(install_args: RuntimeArgs) -> (InMemoryWasmTestBuilder, TestContext) { let mut builder = InMemoryWasmTestBuilder::default(); builder.run_genesis(&PRODUCTION_RUN_GENESIS_REQUEST); let id: Option = None; let transfer_1_args = runtime_args! { mint::ARG_TARGET => *ACCOUNT_1_ADDR, mint::ARG_AMOUNT => MINIMUM_ACCOUNT_CREATION_BALANCE, mint::ARG_ID => id, }; let transfer_2_args = runtime_args! { mint::ARG_TARGET => *ACCOUNT_2_ADDR, mint::ARG_AMOUNT => MINIMUM_ACCOUNT_CREATION_BALANCE, mint::ARG_ID => id, }; let transfer_request_1 = ExecuteRequestBuilder::transfer(*DEFAULT_ACCOUNT_ADDR, transfer_1_args).build(); let transfer_request_2 = ExecuteRequestBuilder::transfer(*DEFAULT_ACCOUNT_ADDR, transfer_2_args).build(); // Installing the test version of CEP-18 with the default account. let install_request_1 = ExecuteRequestBuilder::standard(*DEFAULT_ACCOUNT_ADDR, CEP18_CONTRACT_WASM, install_args) .build(); let install_request_2 = ExecuteRequestBuilder::standard( *DEFAULT_ACCOUNT_ADDR, CEP18_TEST_CONTRACT_WASM, RuntimeArgs::default(), ) .build(); builder.exec(transfer_request_1).expect_success().commit(); builder.exec(transfer_request_2).expect_success().commit(); builder.exec(install_request_1).expect_success().commit(); builder.exec(install_request_2).expect_success().commit(); let account = builder .get_account(*DEFAULT_ACCOUNT_ADDR) .expect("should have account"); let cep18_token = account .named_keys() .get(CEP18_TOKEN_CONTRACT_KEY) .and_then(|key| key.into_hash()) .map(ContractHash::new) .expect("should have contract hash"); let cep18_test_contract_package = account .named_keys() .get(CEP18_TEST_CONTRACT_KEY) .and_then(|key| key.into_hash()) .map(ContractPackageHash::new) .expect("should have contract package hash"); let test_context = TestContext { cep18_token, cep18_test_contract_package, }; (builder, test_context) } ``` -------------------------------- ### Install Casper Node Launcher Source: https://docs.casper.network/operators/setup/basic-node-configuration Installs the casper-node-launcher using apt. This command should be run once to set up the node environment. ```bash sudo apt update sudo apt install casper-node-launcher ``` -------------------------------- ### Get Dictionary Item Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-2.0/state_get_dictionary_item.json Demonstrates how to retrieve a specific item from a dictionary using its URef and item key. This example shows the parameters required and the expected structure of the response, including the stored value and Merkle proof. ```json { "name": "state_get_dictionary_item", "summary": "returns an item from a Dictionary", "params": [ { "name": "state_root_hash", "schema": { "description": "Hash of the state root", "$ref": "#/components/schemas/Digest" }, "required": true }, { "name": "dictionary_identifier", "schema": { "description": "The Dictionary query identifier.", "$ref": "#/components/schemas/DictionaryIdentifier" }, "required": true } ], "result": { "name": "state_get_dictionary_item_result", "schema": { "description": "Result for \"state_get_dictionary_item\" RPC response.", "type": "object", "required": [ "api_version", "dictionary_key", "merkle_proof", "stored_value" ], "properties": { "api_version": { "description": "The RPC API version.", "type": "string" }, "dictionary_key": { "description": "The key under which the value is stored.", "type": "string" }, "stored_value": { "description": "The stored value.", "$ref": "#/components/schemas/StoredValue" }, "merkle_proof": { "description": "The Merkle proof.", "type": "string" } }, "additionalProperties": false } }, "examples": [ { "name": "state_get_dictionary_item_example", "params": [ { "name": "state_root_hash", "value": "0808080808080808080808080808080808080808080808080808080808080808" }, { "name": "dictionary_identifier", "value": { "URef": { "seed_uref": "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007", "dictionary_item_key": "a_unique_entry_identifier" } } } ], "result": { "name": "state_get_dictionary_item_example_result", "value": { "api_version": "2.0.0", "dictionary_key": "dictionary-67518854aa916c97d4e53df8570c8217ccc259da2721b692102d76acd0ee8d1f", "stored_value": { "CLValue": { "cl_type": "U64", "bytes": "0100000000000000", "parsed": 1 } }, "merkle_proof": "01000000006ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a72536147614625016ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a72536147614625000000003529cde5c621f857f75f3810611eb4af3f998caaa9d4a3413cf799f99c67db0307010000006ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a7253614761462501010102000000006e06000000000074769d28aac597a36a03a932d4b43e4f10bf0403ee5c41dd035102553f5773631200b9e173e8f05361b681513c14e25e3138639eb03232581db7557c9e8dbbc83ce94500226a9a7fe4f2b7b88d5103a4fc7400f02bf89c860c9ccdd56951a2afe9be0e0267006d820fb5676eb2960e15722f7725f3f8f41030078f8b2e44bf0dc03f71b176d6e800dc5ae9805068c5be6da1a90b2528ee85db0609cc0fb4bd60bbd559f497a98b67f500e1e3e846592f4918234647fca39830b7e1e6ad6f5b7a99b39af823d82ba1873d000003000000010186ff500f287e9b53f823ae1582b1fa429dfede28015125fd233a31ca04d5012002015cc42669a55467a1fdf49750772bfc1aed59b9b085558eb81510e9b015a7c83b0301e3cf4a34b1db6bfa58808b686cb8fe21ebe0c1bcbcee522649d2b135fe510fe3" } } } ] } ``` -------------------------------- ### Example Source Account Query Source: https://docs.casper.network/developers/cli/transfers/verify-transfer An example of querying the source account's state with specific parameters for a testnet node. ```bash casper-client query-global-state -v \ --id 4 \ --node-address https://node.testnet.casper.network \ --state-root-hash fdb1474d441ec0fcbf2e088f1630dbf98d3bcf7f7a7fe298303797f35b8cb4e1 \ --key 0154d828baafa6858b92919c4d78f26747430dcbecb9aa03e8b44077dc6266cabf ``` -------------------------------- ### Example info_get_status request Source: https://docs.casper.network/developers/json-rpc/json-rpc-informational This snippet demonstrates how to construct a JSON-RPC request to get the current status of a Casper Network node. ```json { "id": 1, "jsonrpc": "2.0", "method": "info_get_status", "params": [] } ``` -------------------------------- ### Query Global State Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-1.5/query_global_state.json Demonstrates how to query the global state for a specific account using a block hash. This example retrieves the account information associated with a given deploy hash. ```json { "name": "query_global_state", "summary": "a query to global state using either a Block hash or state root hash", "params": [ { "name": "key", "schema": { "description": "`casper_types::Key` as formatted string.", "type": "string" }, "required": true }, { "name": "state_identifier", "schema": { "description": "The identifier used for the query. If none is passed the tip of the chain will be used.", "anyOf": [ { "$ref": "#/components/schemas/GlobalStateIdentifier" }, { "type": "null" } ] }, "required": false }, { "name": "path", "schema": { "description": "The path components starting from the key as base.", "default": [], "type": "array", "items": { "type": "string" } }, "required": false } ], "result": { "name": "query_global_state_result", "schema": { "description": "Result for \"query_global_state\" RPC response.", "type": "object", "required": [ "api_version", "merkle_proof", "stored_value" ], "properties": { "api_version": { "description": "The RPC API version.", "type": "string" }, "block_header": { "description": "The block header if a Block hash was provided.", "anyOf": [ { "$ref": "#/components/schemas/JsonBlockHeader" }, { "type": "null" } ] }, "stored_value": { "description": "The stored value.", "$ref": "#/components/schemas/StoredValue" }, "merkle_proof": { "description": "The Merkle proof.", "type": "string" } }, "additionalProperties": false } }, "examples": [ { "name": "query_global_state_example", "params": [ { "name": "state_identifier", "value": { "BlockHash": "13c2d7a68ecdd4b74bf4393c88915c836c863fc4bf11d7f2bd930a1bbccacdcb" } }, { "name": "key", "value": "deploy-af684263911154d26fa05be9963171802801a0b6aff8f199b7391eacb8edc9e1" }, { "name": "path", "value": [] } ], "result": { "name": "query_global_state_example_result", "value": { "api_version": "1.5.6", "block_header": { "parent_hash": "0707070707070707070707070707070707070707070707070707070707070707", "state_root_hash": "0808080808080808080808080808080808080808080808080808080808080808", "body_hash": "cd502c5393a3c8b66d6979ad7857507c9baf5a8ba16ba99c28378d3a970fff42", "random_bit": true, "accumulated_seed": "ac979f51525cfd979b14aa7dc0737c5154eabe0db9280eceaa8dc8d2905b20d5", "era_end": { "era_report": { "equivocators": [ "013b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29" ], "rewards": [ { "validator": "018a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c", "amount": 1000 } ], "inactive_validators": [ "018139770ea87d175f56a35466c34c7ecccb8d8a91b4ee37a25df60f5b8fc9b394" ] }, "next_era_validator_weights": [ { "validator": "016e7a1cdd29b0b78fd13af4c5598feff4ef2a97166e3ca6f2e4fbfccd80505bf1", "weight": "456" }, { "validator": "018a875fff1eb38451577acd5afee405456568dd7c89e090863a0557bc7af49f17", "weight": "789" }, { "validator": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c", "weight": "123" } ] }, "timestamp": "2020-11-17T00:39:24.072Z", "era_id": 1, "height": 10, "protocol_version": "1.0.0" }, "stored_value": { "Account": { "account_hash": "account-hash-e94daaff79c2ab8d9c31d9c3058d7d0a0dd31204a5638dc1451fa67b2e3fb88c", "named_keys": [], "main_purse": "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007" } } } } } ] } ``` -------------------------------- ### Get Peers RPC Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-1.5/schema.json This RPC method returns a list of peers currently connected to the node. It requires no parameters. ```json { "api_version": "1.5.6", "peers": [ { "node_id": "node-id-1", "address": "192.168.1.100:30303", "is_outbound": true }, { "node_id": "node-id-2", "address": "10.0.0.5:30303", "is_outbound": false } ] } ``` -------------------------------- ### Casper CLI: Query Source Account Balance Example Source: https://docs.casper.network/developers/cli/transfers/verify-transfer An example demonstrating how to query the balance of a source account using its account hash. Includes verbose output and specific network details. ```bash casper-client query-balance -v --id 6 \ --node-address https://node.testnet.casper.network \ --state-root-hash fdb1474d441ec0fcbf2e088f1630dbf98d3bcf7f7a7fe298303797f35b8cb4e1 \ --purse-identifier account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655 ``` -------------------------------- ### Get Block by Hash Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-1.5/chain_get_block.json This example demonstrates how to retrieve a block from the network using its hash. Ensure you have the correct block hash. ```json { "name": "chain_get_block", "summary": "returns a Block from the network", "params": [ { "name": "block_identifier", "schema": { "description": "The block identifier.", "$ref": "#/components/schemas/BlockIdentifier" }, "required": false } ], "result": { "name": "chain_get_block_result", "schema": { "description": "Result for \"chain_get_block\" RPC response.", "type": "object", "required": [ "api_version" ], "properties": { "api_version": { "description": "The RPC API version.", "type": "string" }, "block": { "description": "The block, if found.", "anyOf": [ { "$ref": "#/components/schemas/JsonBlock" }, { "type": "null" } ] } }, "additionalProperties": false } }, "examples": [ { "name": "chain_get_block_example", "params": [ { "name": "block_identifier", "value": { "Hash": "13c2d7a68ecdd4b74bf4393c88915c836c863fc4bf11d7f2bd930a1bbccacdcb" } } ], "result": { "name": "chain_get_block_example_result", "value": { "api_version": "1.5.6", "block": { "hash": "13c2d7a68ecdd4b74bf4393c88915c836c863fc4bf11d7f2bd930a1bbccacdcb", "header": { "parent_hash": "0707070707070707070707070707070707070707070707070707070707070707", "state_root_hash": "0808080808080808080808080808080808080808080808080808080808080808", "body_hash": "cd502c5393a3c8b66d6979ad7857507c9baf5a8ba16ba99c28378d3a970fff42", "random_bit": true, "accumulated_seed": "ac979f51525cfd979b14aa7dc0737c5154eabe0db9280eceaa8dc8d2905b20d5", "era_end": { "era_report": { "equivocators": [ "013b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29" ], "rewards": [ { "validator": "018a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c", "amount": 1000 } ], "inactive_validators": [ "018139770ea87d175f56a35466c34c7ecccb8d8a91b4ee37a25df60f5b8fc9b394" ] }, "next_era_validator_weights": [ { "validator": "016e7a1cdd29b0b78fd13af4c5598feff4ef2a97166e3ca6f2e4fbfccd80505bf1", "weight": "456" }, { "validator": "018a875fff1eb38451577acd5afee405456568dd7c89e090863a0557bc7af49f17", "weight": "789" }, { "validator": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c", "weight": "123" } ] }, "timestamp": "2020-11-17T00:39:24.072Z", "era_id": 1, "height": 10, "protocol_version": "1.0.0" }, "body": { "proposer": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c", "deploy_hashes": [], "transfer_hashes": [ "5c9b3b099c1378aa8e4a5f07f59ff1fcdc69a83179427c7e67ae0377d94d93fa" ] }, "proofs": [ { "public_key": "01d9bf2148748a85c89da5aad8ee0b0fc2d105fd39d41a4c796536354f0ae2900c", "signature": "016291a7b2689e2edcc6e79030be50edd02f9bd7d809921ae2654012f808c7b9a0f125bc32d6aa610cbd012395a9832ccfaa9262023339f1db71ca073a13bb9707" } ] } } } } ] } ``` -------------------------------- ### Calling the Auction Contract's `delegate` Entry Point Source: https://docs.casper.network/developers/cli/calling-contracts This example demonstrates calling the Auction contract's `delegate` entry point with specific validator, amount, and delegator public keys. Ensure you have the correct contract hash and key paths configured. ```bash casper-client put-deploy \ --node-address http://65.21.235.219:7777 \ --chain-name casper-test \ --secret-key [KEY_PATH]/secret_key.pem \ --payment-amount 2500000000 \ --session-hash hash-93d923e336b20a4c4ca14d592b60e5bd3fe330775618290104f9beb326db7ae2 \ --session-entry-point "delegate" \ --session-arg "validator:public_key='0145fb72c75e1b459839555d70356a5e6172e706efa204d86c86050e2f7878960f'" \ --session-arg "amount:u512='500000000000'" \ --session-arg "delegator:public_key='0154d828baafa6858b92919c4d78f26747430dcbecb9aa03e8b44077dc6266cabf'" ``` -------------------------------- ### Get Account Balance Example Source: https://docs.casper.network/condor/jsonrpc-comp/rpc-1.5/schema.json Demonstrates how to retrieve the balance of a specific account purse using its URef and the state root hash. ```json { "name": "state_get_balance_example", "params": [ { "name": "state_root_hash", "value": "0808080808080808080808080808080808080808080808080808080808080808" }, { "name": "purse_uref", "value": "uref-09480c3248ef76b603d386f3f4f8a5f87f597d4eaffd475433f861af187ab5db-007" } ], "result": { "name": "state_get_balance_example_result", "value": { "api_version": "1.5.6", "balance_value": "123456", "merkle_proof": "01000000006ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a72536147614625016ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a72536147614625000000003529cde5c621f857f75f3810611eb4af3f998caaa9d4a3413cf799f99c67db0307010000006ef2e0949ac76e55812421f755abe129b6244fe7168b77f47a7253614761462501010102000000006e06000000000074769d28aac597a36a03a932d4b43e4f10bf0403ee5c41dd035102553f5773631200b9e173e8f05361b681513c14e25e3138639eb03232581db7557c9e8dbbc83ce94500226a9a7fe4f2b7b88d5103a4fc7400f02bf89c860c9ccdd56951a2afe9be0e0267006d820fb5676eb2960e15722f7725f3f8f41030078f8b2e44bf0dc03f71b176d6e800dc5ae9805068c5be6da1a90b2528ee85db0609cc0fb4bd60bbd559f497a98b67f500e1e3e846592f4918234647fca39830b7e1e6ad6f5b7a99b39af823d82ba1873d000003000000010186ff500f287e9b53f823ae1582b1fa429dfede28015125fd233a31ca04d5012002015cc42669a55467a1fdf49750772bfc1aed59b9b085558eb81510e9b015a7c83b0301e3cf4a34b1db6bfa58808b686cb8fe21ebe0c1bcbcee522649d2b135fe510fe3" } } } ``` -------------------------------- ### Example: Calling Auction Contract by Package Hash Source: https://docs.casper.network/developers/cli/calling-contracts This example shows how to call the 'delegate' entry point of the Auction contract using its package hash. The call defaults to the highest enabled version as no specific version is provided. ```bash casper-client put-deploy \ --node-address http://65.21.235.219:7777 \ --chain-name casper-test \ --secret-key [KEY_PATH]/secret_key.pem \ --payment-amount 2500000000 \ --session-package-hash hash-e375d42c29c0e4b2baefa63cf2d70af34439eda851e08129d8515515d63bd6a9 \ --session-entry-point "delegate" \ --session-arg "validator:public_key='0145fb72c75e1b459839555d70356a5e6172e706efa204d86c86050e2f7878960f'" \ --session-arg "amount:u512='500000000000'" \ --session-arg "delegator:public_key='0154d828baafa6858b92919c4d78f26747430dcbecb9aa03e8b44077dc6266cabf'" ``` -------------------------------- ### Example Bonding Deploy Source: https://docs.casper.network/operators/becoming-a-validator/bonding This example demonstrates a bonding request using `add_bid.wasm` with a payment amount of 3 CSPR. Adjust values according to your network's chainspec.toml. ```bash sudo -u casper casper-client put-deploy \ --node-address http://65.21.235.219:7777 \ --secret-key /etc/casper/validator_keys/secret_key.pem \ --chain-name casper-test \ --payment-amount 3000000000 \ --session-path ~/casper-node/target/wasm32-unknown-unknown/release/add_bid.wasm \ --session-arg "public_key:public_key='01c297d2931fec7e22b2fb1ae3ca5afdfacc2c82ba501e8ed158eecef82b4dcdee'" \ --session-arg "amount:U512='$[10000 * 1000000000]'" \ --session-arg "delegation_rate:u8='10'" ``` -------------------------------- ### Get Account Balance Example Source: https://docs.casper.network/developers/dapps/sdk/csharp-sdk This C# code retrieves and prints the main purse balance of a Casper account from a testnet node. ```csharp using System; using System.Threading.Tasks; using Casper.Network.SDK; using Casper.Network.SDK.JsonRpc; using Casper.Network.SDK.Types; namespace Casper.NET.SDK.Examples { public class GetAccountBalance { public static async Task Main(string[] args) { string nodeAddress = "http://testnet-node.make.services:7777"; var hex = "0203914289b334f57366541099a52156b149436fdb0422b3c48fe4115d0578abf690"; var publicKey = PublicKey.FromHexString(hex); try { var casperSdk = new NetCasperClient(nodeAddress); // Get the balance using the account public key // var rpcResponse = await casperSdk.GetAccountBalance(publicKey); Console.WriteLine("Public Key Balance: " + rpcResponse.Parse().BalanceValue); } catch (RpcClientException e) { Console.WriteLine("ERROR:\n" + e.RpcError.Message); } catch (Exception e) { Console.WriteLine(e); } } } } ```