### MultiversX Initial Nodes Setup Example (nodesSetup.json) Source: https://docs.multiversx.com/developers/overview/sovereign/distributed-setup An example `nodesSetup.json` file for a MultiversX sovereign chain, illustrating how to configure initial network parameters such as start time, round duration, consensus group sizes, and a list of initial nodes with their public keys and associated addresses. ```json { "startTime": 1733138599, "roundDuration": 6000, "consensusGroupSize": 2, "minNodesPerShard": 2, "metaChainConsensusGroupSize": 0, "metaChainMinNodes": 0, "hysteresis": 0, "adaptivity": false, "initialNodes": [ { "pubkey": "6a1ee46baa8da9279f53addbfbc61a525604eb42d964bd3a25bf7f34097c3b3a31706728718ccdbe3d43386c37ec3011df6ceb4188e14025ab149bd568cafaba18a78b51e71c24046c5276a187a6c1d6da83e30590a6025875b8f6df8984ec05", "address": "erd1a2jq3rrqa0heta0fmlkrymky7yj247mrs54g6fyyx8dm45menkrsmu3dez", "initialRating": 0 }, { "pubkey": "40f3857218333f0b2ba8592fc053cbaebec8e1335f95957c89f6c601ce0758372ba31c30700f10f25202d8856bb948055f9f0ef53dea57b62f013ee01c9dc0346a2b3543f2b4d423166ee1981b310f2549fb879d4cd89de6c392d902a823d116", "address": "erd1pn564xpwk4anq9z50th3ae99vplsf7d2p55cnugf00eu0gcq6gdqcg7ytx", "initialRating": 0 } ] } ``` -------------------------------- ### Run Observing Squad Installation Script Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Executes the primary installation script for the Observing Squad. This command initiates the setup process based on the configurations defined in `variables.cfg`. ```bash ./script.sh observing_squad ``` -------------------------------- ### Start MultiversX Chain Simulator Source: https://docs.multiversx.com/developers/overview/developers/tutorials/chain-simulator-adder Demonstrates how to start the Chain Simulator after successful installation, showing the command and the typical output indicating a successful startup with configuration details. ```Shell my-adder/interactor$ sudo my-path/.cargo/bin/sc-meta cs start ``` ```Shell Attempting to start the Chain Simulator... Successfully started the Chain Simulator. INFO [2024-11-11 13:09:15.683] using the override config files files = [./config/nodeOverrideDefault.toml] WARN [2024-11-11 13:09:15.684] signature bypass = true INFO [2024-11-11 13:09:15.699] updated config value file = systemSmartContractsConfig.toml path = ESDTSystemSCConfig.BaseIssuingCost value = 50000000000000000 INFO [2024-11-11 13:09:15.699] updated config value file = config.toml path = Debug.Process.Enabled value = false INFO [2024-11-11 13:09:15.699] updated config value file = config.toml path = VirtualMachine.Execution.WasmVMVersions value = [map[StartEpoch:0 Version:1.5]] INFO [2024-11-11 13:09:15.699] updated config value file = config.toml path = VirtualMachine.Querying.WasmVMVersions value = [map[StartEpoch:0 Version:1.5]] INFO [2024-11-11 13:09:15.699] updated config value file = config.toml path = WebServerAntiflood.WebServerAntifloodEnabled value = false INFO [2024-11-11 13:09:15.699] updated config value file = config.toml path = WebServerAntiflood.SimultaneousRequests value = 100000 ... ``` -------------------------------- ### Install docker-compose Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Ensure `docker-compose` is installed on your system. If not, use the `apt install` command to install it before proceeding with Docker-based setup. ```bash apt install docker-compose ``` -------------------------------- ### Example localnet startup logs Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Provides an illustrative example of the console output expected when the MultiversX localnet successfully starts. The logs indicate the initiation of key processes such as the seednode, blockchain nodes, and the proxy, confirming the network's operational status. ```text INFO:cli.localnet:Starting localnet... ... INFO:localnet:Starting process ['./seednode', ... ... INFO:localnet:Starting process ['./node', ... ... INFO:localnet:Starting process ['./proxy', ... [PID=...] DEBUG[...] [process/block] started committing block ... ``` -------------------------------- ### Start MultiversX Observing Squad Docker Stack Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Navigate into the `mainnet` directory within the cloned repository and execute the `start_stack.sh` script. This script will install and run the entire Observing Squad using Docker. ```bash cd mainnet ./start_stack.sh ``` -------------------------------- ### Example: Installing 'testwallets' Dependency with mxpy Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/mxpy/mxpy-cli A practical example demonstrating how to install the `testwallets` dependency using the `mxpy deps install` command. This command adds the specified component to the `mxpy` environment. ```Shell mxpy deps install testwallets ``` -------------------------------- ### Run Sovereign Bridge Prerequisites Script Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup Executes the `prerequisites.sh` script to install required software dependencies and download cross-chain contracts, preparing the environment for the sovereign bridge setup. ```bash ./prerequisites.sh ``` -------------------------------- ### Execute Prerequisites Script for MultiversX Localnet Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet-advanced This command navigates into the `mx-chain-go` testnet scripts directory and executes the `prerequisites.sh` script. This script automates the installation of necessary packages and clones additional required repositories, streamlining the setup process for the local testnet. ```Bash $ cd mx-chain-go/scripts/testnet $ ./prerequisites.sh ``` -------------------------------- ### Setup and Start MultiversX Localnet Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Executes the full setup process for the MultiversX localnet, including prerequisites, build, and configuration, and then initiates the localnet operation. This command is used after all configurations are finalized. ```bash mxpy localnet setup mxpy localnet start ``` -------------------------------- ### Start Observing Squad Nodes and Proxy Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Starts all components of the installed Observing Squad, including the observer nodes and the associated proxy service. This command brings the entire squad online. ```bash ./script.sh start ``` -------------------------------- ### Generate Adder Contract Template Source: https://docs.multiversx.com/developers/overview/developers/meta/interactor/interactors-example This command uses `sc-meta` to create a new contract folder, pre-populated with a copy of the `adder` contract, streamlining the setup process for the interactor example. ```Shell sc-meta new --template adder ``` -------------------------------- ### List Running Docker Containers Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad After starting the Docker stack, verify that the Observing Squad components are running by listing all active Docker containers using the `docker ps` command. ```bash docker ps ``` -------------------------------- ### Example: Checking 'testwallets' Dependency with mxpy Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/mxpy/mxpy-cli A practical example demonstrating how to check the installation status of the `testwallets` dependency using the `mxpy deps check` command. This verifies if the component is present and ready for use. ```Shell mxpy deps check testwallets ``` -------------------------------- ### MultiversX Genesis Configuration Example (genesis.json) Source: https://docs.multiversx.com/developers/overview/sovereign/distributed-setup An example `genesis.json` file demonstrating the structure for defining initial addresses, their supply, balance, and staking values. This file is crucial for funding genesis accounts and designating validators at the network's inception. ```json [ { "address": "erd1a2jq3rrqa0heta0fmlkrymky7yj247mrs54g6fyyx8dm45menkrsmu3dez", "supply": "10000000000000000000000000", "balance": "9997500000000000000000000", "stakingvalue": "2500000000000000000000", "delegation": { "address": "", "value": "0" } }, { "address": "erd1pn564xpwk4anq9z50th3ae99vplsf7d2p55cnugf00eu0gcq6gdqcg7ytx", "supply": "10000000000000000000000000", "balance": "9997500000000000000000000", "stakingvalue": "2500000000000000000000", "delegation": { "address": "", "value": "0" } } ] ``` -------------------------------- ### Setup and Start MultiversX Localnet Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet These commands are used to finalize the MultiversX localnet setup based on the `localnet.toml` configuration and then start the localnet. This step is performed after any configuration changes, such as sharding alterations or local source build settings. ```bash mxpy localnet setup mxpy localnet start ``` -------------------------------- ### Start MultiversX Sovereign Extras Service Source: https://docs.multiversx.com/developers/overview/sovereign/sovereign-api This command initiates the MultiversX Sovereign Extras service in a custom environment. It leverages `npm` to execute the `start:faucet` script, which is typically defined within the project's `package.json` file. Users should ensure Node.js and npm are installed, and all project dependencies are satisfied before running this command. ```Shell NODE_ENV=custom npm run start:faucet ``` -------------------------------- ### Install Dependencies and Start Sovereign Lite Wallet Source: https://docs.multiversx.com/developers/overview/sovereign/sovereign-wallet Executes `yarn install` to download and set up all necessary project dependencies, followed by `yarn start:sovereign` to launch the MultiversX Sovereign Lite Wallet application. This command initiates the wallet service, making it accessible. ```bash yarn install yarn start:sovereign ``` -------------------------------- ### MultiversX CLI: Install Development Tools Source: https://docs.multiversx.com/developers/overview/developers/meta/sc-meta-cli Describes the `install` command used to set up necessary tools for MultiversX smart contract development, interaction, and testing. It supports installing all known tools or specific ones like `mx-scenario-go`, with an option to specify framework versions. ```APIDOC install: description: "Installs tools needed for smart contract development, interaction and testing." parameters: all: "Installs all the known tools." mx-scenario-go: "Installs the `mx-scenario-go` tool. Can further specify the framework version on which the contracts should be created by using `--tag`." ``` -------------------------------- ### Start MultiversX dApp Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-microservice This command starts the MultiversX decentralized application in development mode. It compiles the dApp and serves it, allowing users to interact with the updated microservice integration. ```bash npm run start ``` -------------------------------- ### Execute MultiversX Observing Squad Setup Commands Source: https://docs.multiversx.com/developers/overview/bridge/axelar This snippet provides a sequence of `bash` commands to clone the `mx-chain-scripts` repository, set up the Observing Squad using `./script.sh observing_squad`, and start the nodes and Proxy service with `./script.sh start`. ```bash git clone https://github.com/multiversx/mx-chain-scripts ./script.sh observing_squad ./script.sh start ``` -------------------------------- ### Setup MultiversX localnet in one go Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Executes a comprehensive setup process for the MultiversX localnet. This single command handles the creation, prerequisite checks, building, and configuration of the localnet components, streamlining the initial setup. ```bash mxpy localnet setup ``` -------------------------------- ### Install and Start Redis on Linux Source: https://docs.multiversx.com/developers/overview/sovereign/services These commands facilitate the installation and automatic startup of the Redis server on Debian/Ubuntu-based systems. Redis is utilized for caching and data persistence within the Sovereign Chain services. ```Shell sudo apt update sudo apt install redis sudo systemctl start redis sudo systemctl enable redis ``` -------------------------------- ### Start Sovereign API Service Source: https://docs.multiversx.com/developers/overview/sovereign/sovereign-api This command initiates the MultiversX Sovereign API service using `npm`. It specifically runs the `start:testnet` script, implying that it will use the testnet configuration files. Ensure all dependencies are installed before running this command. ```npm npm run start:testnet ``` -------------------------------- ### Install MultiversX sdk-dapp Library Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-dapp Instructions to install the MultiversX sdk-dapp library, a React-based tool for MultiversX dApps, using npm or yarn package managers. ```shell npm install @multiversx/sdk-dapp ``` ```shell yarn add @multiversx/sdk-dapp ``` -------------------------------- ### Start MultiversX Validator Node Source: https://docs.multiversx.com/developers/overview/validators/nodes-scripts/install-update This command uses the `script.sh` utility to initiate the MultiversX validator node. Executing this command brings the node online, allowing it to begin participating in the network. ```Bash ~/mx-chain-scripts/script.sh start ``` -------------------------------- ### Clone MultiversX Observing Squad Repository Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad To set up the Observing Squad using Docker, begin by cloning the official MultiversX Observing Squad GitHub repository to your local machine. ```bash git clone https://github.com/multiversx/mx-chain-observing-squad.git ``` -------------------------------- ### Set Up MultiversX Proxy Instance Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/proxy This snippet provides the necessary shell commands to clone the MultiversX Proxy Go repository, navigate into the proxy's command directory, and build the executable. It's the initial step for hosting a local proxy instance. ```bash git clone https://github.com/multiversx/mx-chain-proxy-go.git cd elrond-proxy-go/cmd/proxy go build . ``` -------------------------------- ### Create New MultiversX Smart Contract Project Source: https://docs.multiversx.com/developers/overview/developers/tutorials/crowdfunding-p1 Command to initialize a new MultiversX smart contract project using the `sc-meta` tool, based on a specified template. This sets up the basic directory structure and initial files. ```bash sc-meta new --name crowdfunding --template empty ``` -------------------------------- ### Clone MultiversX Repositories for Localnet Setup Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet-advanced This command sequence creates a new directory and then clones the essential `mx-chain-go` and `mx-chain-proxy-go` repositories from GitHub, which are fundamental components for establishing a local MultiversX Testnet environment. ```Bash $ mkdir mytestnet && cd mytestnet $ git clone git@github.com:multiversx/mx-chain-go.git $ git clone git@github.com/multiversx/mx-chain-proxy-go.git ``` -------------------------------- ### Hyperblock Processing Log Example Source: https://docs.multiversx.com/developers/overview/integrators/egld-integration-guide Illustrates the sequence of operations for processing hyperblocks by nonce, including fetching, processing, saving the last processed nonce, and handling API errors for nonces not yet available. It demonstrates the system's behavior when waiting for new hyperblocks. ```Log Output ...\n-> fetched hyperblock with nonce 900\n-> processed hyperblock with nonce 900\n-> saved last processed nonce = 900\n-> waiting 2 seconds\n-> fetching hyperblock with nonce 901: API error (nonce not yet processed on chain side), skip\n-> waiting 2 seconds\n-> fetching hyperblock with nonce 901: API error (nonce not yet processed on chain side), skip\n-> waiting 2 seconds\n-> fetched the hyperblock with nonce 901\n-> processed hyperblock with nonce 901\n-> saved last processed nonce = 901\n-> waiting 2 seconds\n... ``` -------------------------------- ### Create New Project Directory for Ping-Pong DApp Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-dapp Initializes a new project folder named 'ping-pong' and navigates into it. This directory will serve as the root for the entire dApp project, containing subfolders for wallet, contract, and dapp components. ```bash mkdir -p ping-pong cd ping-pong/ ``` -------------------------------- ### Configure Observing Squad Environment Variables Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Example configuration for the `config/variables.cfg` file. This snippet shows how to set the network environment (e.g., 'mainnet'), custom home directory, and user for the Observing Squad installation. ```bash ENVIRONMENT="mainnet" ... CUSTOM_HOME="/home/ubuntu" CUSTOM_USER="ubuntu" ``` -------------------------------- ### Monitor MultiversX Observers with termui Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Use the `termui` utility, installed during the setup process, to monitor the status of running MultiversX Observer nodes for different shards and the Metachain. Replace `localhost` and ports as per your configuration. ```bash ~/elrond-utils/termui --address localhost:8080 # Shard 0 ~/elrond-utils/termui --address localhost:8081 # Shard 1 ~/elrond-utils/termui --address localhost:8082 # Shard 2 ~/elrond-utils/termui --address localhost:8083 # Metachain ``` -------------------------------- ### Start MultiversX Node Visual Interface (TermUI) Source: https://docs.multiversx.com/developers/overview/validators/nodes-scripts/install-update This snippet shows how to navigate to the `elrond-utils` directory and then launch the `TermUI` application. `TermUI` provides a visual interface to monitor the progress and status of a running validator node, connecting to its local REST API endpoint. ```Bash cd $HOME/elrond-utils ./termui -address localhost:8080 ``` -------------------------------- ### Install MultiversX Chain Simulator Source: https://docs.multiversx.com/developers/overview/developers/tutorials/chain-simulator-adder Instructions for installing the Chain Simulator Docker image using `sc-meta cs install`. It also covers common troubleshooting steps for permission denied errors (requiring `sudo`) and `command not found` errors (finding and using the full path to `sc-meta`). ```Shell my-adder/interactor$ sc-meta cs install Attempting to install prerequisites for the Chain Simulator... Successfully pulled the latest Chain Simulator image. ``` ```Shell Attempting to install prerequisites for the Chain Simulator... Error: Failed to execute command: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock ``` ```Shell my-adder/interactor$ sudo sc-meta cs install ``` ```Shell sudo: sc-meta: command not found ``` ```Shell my-adder/interactor$ which sc-meta my-path/.cargo/bin/sc-meta ``` ```Shell sudo my-path/.cargo/bin/sc-meta cs install ``` -------------------------------- ### Start MultiversX Testnet Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet-advanced To initiate the Testnet, execute the `start.sh` script, optionally with the `debug` flag for verbose output. After execution, allow approximately one minute for nodes to become active. ```bash ./start.sh debug ``` -------------------------------- ### Install MultiversX dApp Development Prerequisites Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-dapp Commands to install and verify the necessary tools for MultiversX dApp development, including Rust, `multiversx-sc-meta`, Node.js, and Yarn. These tools are essential for compiling smart contracts and managing frontend dependencies. ```Shell stable Rust version ≥ 1.78.0 (install via rustup) Node.js with version ≥ 20 (guide here) ``` ```Rust cargo install multiversx-sc-meta ``` ```JavaScript npm install --global yarn ``` -------------------------------- ### Query MultiversX Observer Status with curl Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Alternatively, perform GET requests using `curl` to retrieve the status of MultiversX Observer nodes for different shards and the Metachain. The output is piped to `jq` for pretty printing and easier readability. ```bash curl http://localhost:8080/node/status | jq # Shard 0 curl http://localhost:8081/node/status | jq # Shard 1 curl http://localhost:8082/node/status | jq # Shard 2 curl http://localhost:8083/node/status | jq # Metachain ``` -------------------------------- ### Create a new MultiversX staking smart contract project Source: https://docs.multiversx.com/developers/overview/developers/tutorials/staking-contract This command initializes a new empty smart contract project named 'staking-contract' using the `sc-meta` tool. It sets up the basic directory structure required for MultiversX smart contract development. ```Bash sc-meta new --name staking-contract --template empty ``` -------------------------------- ### Configure Test Accounts in MultiversX Rust Blackbox Test Source: https://docs.multiversx.com/developers/overview/developers/tutorials/crowdfunding-p1 Rust code example showing how to define and initialize a mock account (`OWNER`) with a specific nonce and balance within the `ScenarioWorld` for blackbox testing MultiversX smart contracts. ```Rust const OWNER: TestAddress = TestAddress::new("owner"); #[test] fn crowdfunding_deploy_test() { let mut world = world(); world.account(OWNER).nonce(0).balance(1000000); } ``` -------------------------------- ### Perform Smoke Test to Fetch Latest Hyperblock Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Execute a smoke test to fetch the latest synchronized hyperblock. This involves first querying the network status to get the highest final nonce, then using that nonce to retrieve the corresponding hyperblock data. ```bash export NONCE=$(curl http://localhost:8079/network/status/4294967295 | jq '.data["status"]["erd_highest_final_nonce"]') curl http://localhost:8079/hyperblock/by-nonce/$NONCE | jq ``` -------------------------------- ### Example: Overwriting 'testwallets' Dependency Installation Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/mxpy/mxpy-cli Demonstrates how to force an overwrite of an existing dependency installation using the `--overwrite` argument with `mxpy deps install`. This ensures that the latest version or a specific version of the dependency is installed, replacing any prior installation. ```Shell mxpy deps install testwallets --overwrite ``` -------------------------------- ### Install Redis Server on Linux Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-microservice This command installs the Redis server package on Debian/Ubuntu-based Linux distributions using the `apt` package manager. Redis is used for caching in the microservice. ```bash sudo apt install redis-server ``` -------------------------------- ### Navigate to Testnet Scripts Directory Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup After cloning the repository, this command changes the current directory to the 'scripts/testnet' subdirectory within the 'mx-chain-sovereign-go' repository. This directory contains essential setup scripts. ```Bash cd mx-chain-sovereign-go/scripts/testnet ``` -------------------------------- ### Install Microservice Node.js Dependencies Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-microservice This command installs all necessary Node.js package dependencies for the MultiversX microservice. It should be run in the microservice's root directory after cloning the repository. ```bash npm install ``` -------------------------------- ### Install Dependencies for MultiversX dApp Template Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-dapp These commands ensure that the necessary package managers and development tools are available for the dApp. It first installs `yarn` globally and then adds `vite` as a development dependency, which is crucial for building and running the dApp. ```Shell npm install --global yarn yarn add vite --dev ``` -------------------------------- ### Constructing a Basic MultiversX Transaction in Rust Source: https://docs.multiversx.com/developers/overview/developers/tutorials/eth-to-mvx Illustrates the fluent API for building a MultiversX transaction. Starting with `self.tx()`, developers chain methods like `from`, `to`, `payment`, `gas`, `raw_call`, and `with_result` to progressively define the transaction's parameters before execution. This example shows the initial construction phase. ```Rust self.tx() .from(from) .to(to) .payment(payment) .gas(gas) .raw_call("function") .with_result(result_handler) ``` -------------------------------- ### Install MultiversX SDK with Ledger Device Support Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-py This command installs the MultiversX SDK along with additional dependencies required for interacting with Ledger hardware devices. The `[ledger]` extra specifies the optional components to be installed. ```Shell pip install multiversx-sdk[ledger] ``` -------------------------------- ### Start MultiversX dApp Development Server Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-dapp This command initiates the local development server for a MultiversX dApp, allowing for local testing and interaction. It's typically used during the development phase to run the application and make it accessible via a web browser. ```Shell yarn start:devnet ``` -------------------------------- ### Check pip3 Version Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/mxpy/installing-mxpy This command verifies if pip3 is installed on the system and displays its version, which is a prerequisite for shell completion setup. ```Shell pip3 --version ``` -------------------------------- ### Install Rust using the official rustup script Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/troubleshooting/rust-setup Executes the recommended `rustup` installation script to set up the Rust toolchain, followed by updating to the latest stable version. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ```bash rustup update rustup default stable ``` -------------------------------- ### MultiversX Crowdfunding Contract Project Structure Source: https://docs.multiversx.com/developers/overview/developers/tutorials/crowdfunding-p1 Displays the recommended directory layout for a MultiversX smart contract project, including source code, build outputs, and dedicated test folders for blackbox testing. ```Shell . ├── Cargo.lock ├── Cargo.toml ├── meta │ ├── Cargo.toml │ └── src ├── multiversx.json ├── output │ ├── crowdfunding.abi.json │ ├── crowdfunding.imports.json │ ├── crowdfunding.mxsc.json │ └── crowdfunding.wasm ├── src │ └── crowdfunding.rs ├── target │ ├── CACHEDIR.TAG │ ├── debug │ ├── release │ ├── tmp │ └── wasm32-unknown-unknown ├── tests │ └── crowdfunding_blackbox_test.rs └── wasm ├── Cargo.lock ├── Cargo.toml └── src ``` -------------------------------- ### Start MultiversX Microservice on Devnet Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-microservice This command initiates the MultiversX microservice, configured to connect to the devnet. It starts the service on a specified port, typically 3001, making its API endpoints accessible. ```bash npm run start:devnet ``` -------------------------------- ### Direct Command for MultiversX Node Installation Source: https://docs.multiversx.com/developers/overview/validators/nodes-scripts/install-update As an alternative to the interactive menu, this command directly triggers the node installation process using the `script.sh` utility. It provides a non-interactive way to initiate the setup of the MultiversX validator node. ```Bash ~/mx-chain-scripts/script.sh install ``` -------------------------------- ### Execute Prerequisites Script for Sovereign Chain Setup Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup This script verifies and downloads all necessary packages required to run the MultiversX sovereign chain nodes. It also clones additional repositories such as 'mx-chain-deploy-sovereign-go', 'mx-chain-proxy-sovereign-go', 'mx-chain-sovereign-bridge-go', and 'mx-chain-tools-go', which are crucial for chain configuration, proxy services, cross-chain bridging, and elastic index updates. ```Bash ./prerequisites.sh ``` -------------------------------- ### Create Account from Entrypoint Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-js/sdk-js-cookbook Demonstrates how to initialize a new account directly from an entrypoint. Accounts are essential for signing transactions and messages, and for managing the account's nonce. ```JavaScript { const entrypoint = new DevnetEntrypoint(); const account = entrypoint.createAccount(); } ``` -------------------------------- ### MultiversX API: Get NFT Data Response Example Source: https://docs.multiversx.com/developers/overview/tokens/nft-tokens An example JSON response structure returned by the 'Get NFT data for an address' API endpoint. It illustrates the typical fields contained within the 'tokenData' object, such as attributes, balance, creator, hash, name, nonce, properties, royalties, token identifier, and URIs, along with the overall status. ```JSON { "data": { "tokenData": { "attributes": "YXR0cmlidXRl", "balance": "2", "creator": "erd1ukn0tukrdhuv0zzxn0zlr53g7h0fr68dz9dd56mkksev59nwuvnswnlyuy", "hash": "aGFzaA==", "name": "H", "nonce": 1, "properties": "", "royalties": "9000", "tokenIdentifier": "4W97C-32b5ce", "uris": ["bmZ0IHVyaQ=="] } }, "error": "", "code": "successful" } ``` -------------------------------- ### Example Output of MultiversX Smart Contract Deployment Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-dapp This snippet shows the typical console output after successfully running the smart contract deployment command. It includes details such as the sender's nonce, transaction hash, and the newly deployed contract address, which are crucial for verification and further interaction. ```Shell Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s Running `/ping-pong/contract/target/debug/ping-pong-interact deploy --ping-amount 1000000000000000000 --duration-in-seconds 180` sender's recalled nonce: 12422 -- tx nonce: 12422 sc deploy tx hash: b6ca6c8e6ac54ed168bcd6929e762610e2360674f562115107cf3702b8a22467 deploy address: erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6 new address: erd1qqqqqqqqqqqqqpgqymj43x6anzr38jfz7kw3td2ew33v9jtrd8sse5zzk6 ``` -------------------------------- ### WalletConnect: Connect and Basic Login Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-js/sdk-js-signing-providers Demonstrates how to initiate a WalletConnect connection, obtain the URI for QR code display, and complete a basic login session using the provider's `connect()` and `login()` methods. ```javascript const { uri, approval } = await provider.connect(); // connect will provide the uri required for the qr code display // and an approval Promise that will return the connection session // once the user confirms the login // openModal() is defined above openModal(uri); // pass the approval Promise await provider.login({ approval }); ``` -------------------------------- ### Installing mxpy Dependencies Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/mxpy/mxpy-cli Shows the command for installing a new dependency using `mxpy`. This command takes the dependency's name as a positional argument, facilitating the setup of required components for `mxpy` operations. ```Shell mxpy deps install ``` -------------------------------- ### Fetch MultiversX Localnet Software Prerequisites Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Downloads necessary software components like `mx-chain-go` and `mx-chain-proxy-go` into `~/multiversx-sdk` for the localnet setup. This step is crucial when `resolution = remote` is specified in `localnet.toml`. ```bash mxpy localnet prerequisites ``` -------------------------------- ### Verify Rust Toolchain and Target Installation Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/troubleshooting/rust-setup This command checks the current Rust installation, displaying information about the default host, `rustup` home directory, installed toolchains (e.g., stable), and installed targets (e.g., `wasm32-unknown-unknown`). It helps confirm that the necessary components for MultiversX development are correctly set up. ```bash rustup show ``` -------------------------------- ### Install Rust Toolchain for MultiversX Development Source: https://docs.multiversx.com/developers/overview/developers/meta/interactor/interactors-overview These commands guide the installation of the Rust programming language and its necessary components for MultiversX smart contract development. It includes installing `rustup`, updating the toolchain, setting the default stable version, and adding the `wasm32-unknown-unknown` target, which is essential for compiling WebAssembly smart contracts. ```Shell curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ```Shell rustup update rustup default stable rustup target add wasm32-unknown-unknown ``` ```Shell rustc --version rustup show ``` -------------------------------- ### Underlying commands for mxpy localnet setup Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Details the individual mxpy sub-commands that are executed sequentially when 'mxpy localnet setup' is run. These commands include creating a new localnet instance, checking prerequisites, building components, and configuring the network. ```bash mxpy localnet new mxpy localnet prerequisites mxpy localnet build mxpy localnet config ``` -------------------------------- ### Build MultiversX Localnet Software Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Compiles the previously fetched software prerequisites for the MultiversX localnet. The actual build process occurs within the download folders, typically under `~/multiversx-sdk/localnet_software_remote`. ```bash mxpy localnet build ``` -------------------------------- ### Install MultiversX sdk-dapp without Optional UI Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-dapp Instructions to install the MultiversX sdk-dapp library without its optional UI components, which can reduce dependencies, using npm or yarn. ```shell npm install @multiversx/sdk-dapp --no-optional ``` ```shell yarn add @multiversx/sdk-dapp --no-optional ``` -------------------------------- ### CLI: Build MultiversX Smart Contract Source: https://docs.multiversx.com/developers/overview/developers/tutorials/crowdfunding-p1 This command-line instruction is used to build a MultiversX smart contract. Running `sc-meta all build` compiles the contract code, ensuring it is ready for deployment and testing. ```CLI sc-meta all build ``` -------------------------------- ### MultiversX API: Get Transaction Details Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/rest-api/transactions Documents the `GET /transaction/:txHash` endpoint for retrieving details of a MultiversX transaction. It specifies path and query parameters, their types, and descriptions, along with examples for the JSON responses (basic and extended). ```APIDOC GET https://gateway.multiversx.com/transaction/:txHash Description: This endpoint allows one to query the details of a Transaction. Path Parameters: txHash: REQUIRED, string, The hash (identifier) of the Transaction. Query Parameters: sender: OPTIONAL, string, The Address of the sender - a hint to optimize the request. withResults: OPTIONAL, bool, Boolean parameter to specify if smart contract results and other details should be returned. Response (200 OK): Description: Transaction details retrieved successfully. Body: data: object transaction: object type: string nonce: number round: number epoch: number value: string receiver: string sender: string gasPrice: number gasLimit: number data: string signature: string sourceShard: number destinationShard: number blockNonce: number miniblockHash: string blockHash: string status: string receipt: object (OPTIONAL, if withResults=true) value: number sender: string data: string txHash: string smartContractResults: array of objects (OPTIONAL, if withResults=true) hash: string nonce: number value: number receiver: string sender: string data: string prevTxHash: string originalTxHash: string gasLimit: number gasPrice: number callType: number error: string code: string ``` ```JSON { "data": { "transaction": { "type": "normal", "nonce": 3, "round": 186580, "epoch": 12, "value": "1000000000000000000", "receiver": "erd1...", "sender": "erd1...", "gasPrice": 1000000000, "gasLimit": 70000, "data": "Zm9yIHRlc3Rz", "signature": "1047...", "sourceShard": 2, "destinationShard": 1, "blockNonce": 186535, "miniblockHash": "e927...", "blockHash": "50a1...", "status": "executed" } }, "error": "", "code": "successful" } ``` ```JSON { "data": { "transaction": { "type": "normal", "nonce": 3, "round": 186580, "epoch": 12, "value": "1000000000000000000", "receiver": "erd1...", "sender": "erd1...", "gasPrice": 1000000000, "gasLimit": 70000, "data": "Zm9yIHRlc3Rz", "signature": "1047...", "sourceShard": 2, "destinationShard": 1, "blockNonce": 186535, "miniblockHash": "e927...", "blockHash": "50a1...", "status": "executed", "receipt": { "value": 100, "sender": "erd1...", "data": "...", "txHash": "b37..." }, "smartContractResults": [ { "hash": "...", "nonce": 5, "value": 1000, "receiver": "erd1...", "sender": "erd1...", "data": "@6f6b", "prevTxHash": "3638...", "originalTxHash": "3638...", "gasLimit": 0, "gasPrice": 1000000000, "callType": 0 } ] } }, "error": "", "code": "successful" } ``` -------------------------------- ### Example MultiversX Localnet Directory Tree Output Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Shows a typical directory structure generated after configuring a MultiversX localnet. It includes configuration files, shared libraries, and executable nodes for proxy, seednode, and multiple validator instances. ```text ├── localnet │   ├── proxy │   │   ├── config │   │   └── proxy │   ├── seednode │   │   ├── config │   │   ├── libwasmer_linux_amd64.so │   | ├── ... │   │   └── seednode │   ├── validator00 │   │   ├── config │   │   ├── libwasmer_linux_amd64.so │   | ├── ... │   │   └── node │   ├── validator01 │   │   ├── config │   │   ├── libwasmer_linux_amd64.so │   | ├── ... │   │   └── node │   └── validator02 │   ├── config │   ├── libwasmer_linux_amd64.so │   ├── ... │   └── node └── localnet.toml ``` -------------------------------- ### MultiversX Validator Script Menu Options Source: https://docs.multiversx.com/developers/overview/validators/nodes-scripts/install-update This displays the interactive menu presented by the `script.sh` utility, offering various actions like install, upgrade, start, stop, and cleanup for the validator node. Users select an option by entering its corresponding number. ```Bash 1) install 2) observing_squad 3) multikey_group 4) upgrade 5) upgrade_multikey 6) upgrade_squad 7) upgrade_proxy 8) remove_db 9) start 10) start_all 11) stop 12) stop_all 13) cleanup 14) github_pull 15) add_nodes 16) get_logs 17) benchmark 18) quit Please select an action:1 ``` -------------------------------- ### Create New MultiversX Localnet Workspace Source: https://docs.multiversx.com/developers/overview/developers/setup-local-testnet Creates a new directory for a MultiversX localnet instance and navigates into it, preparing for individual setup steps. This allows for more granular control over the localnet configuration. ```bash mkdir -p ~/my-second-localnet && cd ~/my-second-localnet ``` -------------------------------- ### MultiversX Rust Adder Smart Contract Example Source: https://docs.multiversx.com/developers/overview/developers/tutorials/eth-to-mvx The equivalent 'Adder' smart contract implemented in Rust for the MultiversX blockchain, utilizing the SpaceCraftSDK. This example showcases MultiversX-specific annotations like `#[contract]`, `#[init]`, `#[endpoint]`, `#[view]`, and `#[storage_mapper]` to define contract logic and storage. ```Rust #[multiversx_sc::contract] pub trait Adder { #[init] fn init(&self, initial_value: BigUint) { self.sum().set(initial_value); } #[endpoint] fn add(&self, value: BigUint) { self.sum().update(|sum| *sum += value); } #[view(getSum)] #[storage_mapper("sum")] fn sum(&self) -> SingleValueMapper; } ``` -------------------------------- ### Navigate to Sovereign Bridge Directory Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup Changes the current working directory to the `sovereignBridge` folder, which is a necessary first step before running setup scripts. ```bash cd sovereignBridge ``` -------------------------------- ### Save Key-Value Pair to MultiversX Account using Factory (Python) Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-py This snippet initiates the process of storing key-value pairs on a MultiversX account using the `AccountTransactionsFactory`. It demonstrates the setup of the entrypoint and factory, and the loading of the sender account from a PEM file. The provided code is a partial example, showing the initial setup for this operation. ```python from pathlib import Path from multiversx_sdk import Account, DevnetEntrypoint # create the entrypoint and the account transactions factory entrypoint = DevnetEntrypoint() factory = entrypoint.create_account_transactions_factory() # create the account to guard alice = Account.new_from_pem(Path("../multiversx_sdk/testutils/testwallets/alice.pem")) ``` -------------------------------- ### Source Management Script for Stop/Clean Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup Sources `script.sh` to load functions required for stopping and cleaning the local Sovereign Chain and its associated services. ```bash source script.sh ``` -------------------------------- ### Install MultiversX SDK with Ledger Support Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-py This command installs the `multiversx-sdk` package along with necessary dependencies for Ledger device communication. It enables functionalities like transaction and message signing through a Ledger device. ```bash pip install multiversx-sdk[ledger] ``` -------------------------------- ### Clone MultiversX Ping-Pong Smart Contract Repository Source: https://docs.multiversx.com/developers/overview/developers/tutorials/your-first-dapp Clones the official MultiversX Ping-Pong sample smart contract repository from GitHub into a 'contract' subfolder within the current project directory. This action provides all the necessary source files for the smart contract. ```bash git clone https://github.com/multiversx/mx-ping-pong-sc contract ``` -------------------------------- ### Equivalent `sc-meta all` and `cargo run` Build Commands Source: https://docs.multiversx.com/developers/overview/developers/meta/sc-meta-cli These two code snippets demonstrate equivalent ways to build a smart contract project. The first uses the `sc-meta all` command from the parent directory, while the second navigates into the contract's `meta` subdirectory and uses `cargo run` directly. ```Shell cd my-contract sc-meta all build ``` ```Shell cd my-contract/meta cargo run build ``` -------------------------------- ### Example Output of Get Staked Addresses Query Source: https://docs.multiversx.com/developers/overview/developers/tutorials/staking-contract Illustrative output showing a single staked address in Bech32 format, as a result of the `getStakedAddresses` query. ```Plaintext Result: erd1vx... ``` -------------------------------- ### Instantiate MultiversX Extension Provider Source: https://docs.multiversx.com/developers/overview/sdk-and-tools/sdk-js/sdk-js-signing-providers Demonstrates how to import the `ExtensionProvider` and obtain its singleton instance, which is essential for interacting with the MultiversX DeFi Wallet browser extension. ```javascript import { ExtensionProvider } from "@multiversx/sdk-extension-provider"; const provider = ExtensionProvider.getInstance(); ``` -------------------------------- ### Inspect MultiversX Proxy Activity with journalctl Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad The MultiversX Proxy does not offer a `termui` monitor. Instead, its activity can be inspected by viewing its logs in real-time using `journalctl` for the `elrond-proxy.service`. ```bash journalctl -f -u elrond-proxy.service ``` -------------------------------- ### Build MultiversX Smart Contract Source: https://docs.multiversx.com/developers/overview/developers/tutorials/staking-contract This command builds all components of the MultiversX smart contract project. It must be executed from the contract's root directory to prepare the contract for deployment. ```shell sc-meta all build ``` -------------------------------- ### Clone MultiversX Chain Scripts Repository Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Clones the official `mx-chain-scripts` repository from GitHub. This repository contains the necessary scripts for setting up and managing the MultiversX Observing Squad. ```bash git clone https://github.com/multiversx/mx-chain-scripts ``` -------------------------------- ### Clone MultiversX Sovereign Go Repository Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup This command clones the main MultiversX sovereign chain Go repository from GitHub. Ensure an SSH key for GitHub is configured on your machine before executing. ```Bash git clone git@github.com:multiversx/mx-chain-sovereign-go.git ``` -------------------------------- ### Example MultiversX Mandos Scenario Trace JSON Source: https://docs.multiversx.com/developers/overview/developers/meta/interactor/interactors-example This JSON snippet illustrates the structure of a Mandos scenario trace file (`trace1.scen.json`) generated by the interactor's tracer. It captures a sequence of smart contract interactions, including state setup (`setState`), contract deployment (`scDeploy`), function calls (`scCall` for 'add'), and queries (`scQuery` for 'getSum'), along with their transaction details and expected outcomes. ```JSON { "steps": [ { "step": "setState", "newAddresses": [ { "creatorAddress": "0x0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1", "creatorNonce": "1427", "newAddress": "bech32:erd1qqqqqqqqqqqqqpgqmauhsqd6zr7kt8pg80qhph2tw0ejed3pd8sszl98x7" } ] }, { "step": "scDeploy", "id": "", "tx": { "from": "0x0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1", "contractCode": "mxsc:../output/adder.mxsc.json", "arguments": [ "0x" ], "gasLimit": "5,000,000" }, "expect": { "out": [], "status": "0" } }, { "step": "scCall", "id": "", "tx": { "from": "0x0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1", "to": "bech32:erd1qqqqqqqqqqqqqpgqmauhsqd6zr7kt8pg80qhph2tw0ejed3pd8sszl98x7", "function": "add", "arguments": [ "0x03" ], "gasLimit": "5,000,000" }, "expect": { "out": [], "status": "0" } }, { "step": "scQuery", "id": "", "tx": { "to": "bech32:erd1qqqqqqqqqqqqqpgqmauhsqd6zr7kt8pg80qhph2tw0ejed3pd8sszl98x7", "function": "getSum", "arguments": [] }, "expect": { "out": [ "0x03" ], "status": "0" } } ] } ``` -------------------------------- ### Initialize Scenario World for Testing Environment Source: https://docs.multiversx.com/developers/overview/developers/testing/rust/sc-blackbox-example Defines the `world` function, which initializes a `ScenarioWorld` instance, registers the `adder` contract with its code path, and provides access to the testing framework's methods for environment setup. ```Rust fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); blockchain.register_contract(CODE_PATH, adder::ContractBuilder); blockchain } ``` -------------------------------- ### MultiversX Rust Staking Contract Test Setup Source: https://docs.multiversx.com/developers/overview/developers/tutorials/staking-contract This Rust code snippet provides the initial setup for testing the MultiversX staking smart contract. It imports necessary modules, defines constants for addresses and contract paths, and sets up initial values like user balance and APY for test scenarios. ```Rust mod staking_contract_proxy; use multiversx_sc::{ imports::OptionalValue, types::{BigUint, TestAddress, TestSCAddress}, }; use multiversx_sc_scenario::imports::*; use staking_contract_proxy::StakingPosition; const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); const USER_ADDRESS: TestAddress = TestAddress::new("user"); const STAKING_CONTRACT_ADDRESS: TestSCAddress = TestSCAddress::new("staking-contract"); const WASM_PATH: MxscPath = MxscPath::new("output/staking-contract.mxsc.json"); const USER_BALANCE: u64 = 1_000_000_000_000_000_000; const APY: u64 = 10_00; // 10% struct ContractSetup { ``` -------------------------------- ### Enable Node Log Saving Source: https://docs.multiversx.com/developers/overview/integrators/observing-squad Sets an additional flag (`-log-save`) for the node. This ensures that logs generated by the MultiversX node are saved persistently within its designated `logs` folder. ```bash NODE_EXTRA_FLAGS="-log-save" ``` -------------------------------- ### Source Management Script for Upgrade/Reset Source: https://docs.multiversx.com/developers/overview/sovereign/local-setup Sources `script.sh` to load functions necessary for upgrading and resetting the local Sovereign Chain and its associated services. ```bash source script.sh ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.