### Install and Start Development Server Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/frontend.mdx Provides commands to install project dependencies and start the Vite development server for the frontend application. This is a standard procedure for setting up and running the React application locally. ```bash cd hello/frontend yarn yarn dev ``` -------------------------------- ### Setup ZetaChain Environment Variables Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/staking.mdx Sets up necessary environment variables for interacting with the ZetaChain testnet, including RPC URL and private key. It also shows how to get a wallet address and its ZETA balance. ```bash export RPC_URL="https://zetachain-athens-evm.blockpi.network/v1/rpc/public" export PRIVATE_KEY="YOUR_PRIVATE_KEY_HEX" cast wallet address $PRIVATE_KEY cast balance --rpc-url "$RPC_URL" $(cast wallet address $PRIVATE_KEY) export STAKING_PRECOMPILE=0x0000000000000000000000000000000000000800 ``` -------------------------------- ### Install Dependencies (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui.mdx Installs project dependencies using Yarn and updates Foundry contracts using 'forge soldeer update'. These commands are essential after cloning the example project. ```bash yarn forge soldeer update ``` -------------------------------- ### Install Cosmovisor from Source (Go/Shell) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Installs Cosmovisor, a process manager for Cosmos SDK binaries, from source using 'go install'. The compiled binary is then moved to '/usr/local/bin'. ```shell go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.7.1 mv $(go env GOPATH)/bin/cosmovisor /usr/local/bin/cosmovisor ``` -------------------------------- ### Set Up Project and Install Dependencies Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/solana.mdx Initializes a new ZetaChain project and installs necessary dependencies using npm and yarn. This is the first step in setting up the development environment for cross-chain applications. ```bash npx zetachain@latest new --project call cd call yarn ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/messaging.mdx Installs project dependencies including TypeScipt and Foundry. Navigates into the project directory and runs yarn and forge soldeer update. Assumes yarn is installed. ```bash cd messaging yarn forge soldeer update ``` -------------------------------- ### Install Cosmovisor from Precompiled Binaries (Shell) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Installs Cosmovisor by downloading a precompiled binary from the Cosmos SDK releases. The downloaded archive is extracted, permissions are set, and the binary is moved to '/usr/local/bin'. ```shell wget https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2Fv1.7.1/cosmovisor-v1.7.1-linux-amd64.tar.gz tar xf cosmovisor-v1.7.1-linux-amd64.tar.gz && chmod a+x cosmovisor && sudo mv cosmovisor /usr/local/bin ``` -------------------------------- ### Install ZetaChain Node Binary (Shell) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Downloads and installs the ZetaChain node binary, granting it executable permissions. Ensure you replace 'VERSION' with the latest release tag and select the correct platform. ```shell sudo wget https://github.com/zeta-chain/node/releases/download/VERSION/zetacored-linux-amd64 -O /usr/local/bin/zetacored && sudo chmod a+x /usr/local/bin/zetacored ``` -------------------------------- ### Clone Project and Install Dependencies (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui-withdraw-and-call.mdx Clones the example contracts repository and installs its dependencies using npm and yarn. This sets up the local development environment for cross-chain interactions. ```bash npx zetachain@next new --project call cd call yarn ``` -------------------------------- ### Install ZetaChain CLI Binary Source: https://github.com/zeta-chain/docs/blob/main/src/pages/users/cli/setup.mdx This snippet shows how to install the ZetaChain CLI by placing the pre-compiled binary in the system's PATH. Ensure you have the correct binary for your OS and architecture. This method is quick and requires no compilation. ```shell /usr/local/bin/zetacored ``` -------------------------------- ### Install ZetaChain Toolkit Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/toolkit.mdx This command installs the ZetaChain Toolkit using npm. It's the first step to integrating the SDK into your project. ```bash npm i @zetachain/toolkit ``` -------------------------------- ### Download and Extract Latest Full Node Snapshot (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/syncing.mdx This script downloads the latest full node snapshot for ZetaChain, extracts it, and starts the node. It requires `lz4` and `jq` to be installed. The script captures a JSON response to dynamically determine the snapshot link and filename, then downloads and extracts the archive into the specified directory. Finally, it starts the `zetacored` service. ```bash # Ensure lz4 is installed sudo apt update && sudo apt install lz4 -y # Capture the JSON response once SNAPSHOT_JSON=$(curl -s https://snapshots.rpc.zetachain.com/mainnet/fullnode/latest.json) # Extract link and filename into variables SNAPSHOT_LINK=$(echo $SNAPSHOT_JSON | jq -r '.snapshots[].link') SNAPSHOT_FILENAME=$(echo $SNAPSHOT_JSON | jq -r '.snapshots[].filename') # Download and extract the snapshot sudo -u zetachain curl "$SNAPSHOT_LINK" -o "/home/zetachain/$SNAPSHOT_FILENAME" && \ sudo -u zetachain lz4 -dc /home/zetachain/$SNAPSHOT_FILENAME | sudo -u zetachain tar -C /home/zetachain/.zetacored/ -xvf - && \ sudo systemctl start zetacored ``` -------------------------------- ### Compile ZetaChain CLI from Source Source: https://github.com/zeta-chain/docs/blob/main/src/pages/users/cli/setup.mdx This snippet demonstrates compiling the ZetaChain CLI from its source code. It requires Go 1.20+ and Git. The process involves cloning the repository, navigating into the directory, and running the `make install` command. This method ensures you have the latest code and is suitable if you need to modify the source. ```shell git clone https://github.com/zeta-chain/node cd node make install ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/standards/token.mdx After creating a new Universal Token project, these commands navigate into the project directory, install necessary dependencies using yarn, and update Solidity contracts using forge soldeer. Ensure Node.js, yarn, and Forge are installed. ```bash cd token yarn forge soldeer update ``` -------------------------------- ### Verify ZetaChain CLI Installation Source: https://github.com/zeta-chain/docs/blob/main/src/pages/users/cli/setup.mdx This snippet shows how to verify that the ZetaChain CLI has been installed correctly. Running the `zetacored` command should display the daemon's usage information and available commands. This is a simple check to confirm the executable is accessible and functional. ```shell zetacored ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/frontend.mdx Installs project dependencies using Yarn. This command is typically run after navigating to the frontend directory of a project. ```bash cd hello/frontend yarn ``` -------------------------------- ### Initialize npm Project and Install Dependencies Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/goldrush.mdx This snippet demonstrates the commands to create a new npm project, navigate into its directory, and install the necessary GoldRush client SDK and axios for making HTTP requests. ```bash mkdir zetachain-app cd zetachain-app npm init -y npm install @covalenthq/client-sdk axios ``` -------------------------------- ### Install KSYNC (Go) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/syncing.mdx This command installs the latest version of KSYNC, a tool used for syncing blocks and state-sync snapshots for Cosmos blockchain nodes. It utilizes the Go programming language's installation command. ```bash go install github.com/KYVENetwork/ksync/cmd/ksync@latest ``` -------------------------------- ### Start Local ZetaChain and Sui Network (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui.mdx Launches a local development environment with both ZetaChain and Sui running concurrently. This command also pre-deploys gateway contracts on both networks. ```bash yarn zetachain localnet start --chains sui ``` -------------------------------- ### Start Local ZetaChain Network (CLI) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/cli.mdx Starts a local multi-chain development environment, including EVM, Solana, and others, with a single command. This is essential for local testing and development before deploying to a live network. ```bash zetachain localnet start ``` -------------------------------- ### Query Account Balances using zetacored CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/users/cli/balances.mdx This command queries the bank balances for a specified account ('alice' in this example) on the ZetaChain network. It requires the zetacored CLI to be installed and a valid RPC node URL. The output shows a list of balances with amounts and denominations. ```bash zetacored q bank balances $(zetacored keys show alice -a) --node https://zetachain-athens.blockpi.network:443/rpc/v1/public ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/swap.mdx Installs project dependencies using Yarn after navigating into the project directory. This step is crucial for ensuring all necessary packages are available for building and running the application. ```bash cd swap yarn ``` -------------------------------- ### Install Graph CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/the-graph.mdx Installs the Graph Command Line Interface globally on your local machine. This tool is essential for managing and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Install ZetaChain CLI (npm) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/intro.mdx Installs the ZetaChain Command Line Interface globally using npm. This CLI is essential for interacting with the ZetaChain network, managing assets, and querying chain information. ```bash npm install -g zetachain ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/zeta-chain/docs/blob/main/README.md Installs all necessary project dependencies using the Yarn package manager. This is a prerequisite for local development and building. ```bash yarn ``` -------------------------------- ### Install Goldsky CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/goldsky.mdx This command installs the Goldsky Command Line Interface (CLI) using curl. The CLI is used to manage and deploy subgraphs to the Goldsky indexing service. After installation, users need to log in using their API key. ```bash curl https://goldsky.com | sh ``` -------------------------------- ### Check ZetaChain Node Binary Version (Shell) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Verifies the installation of the ZetaChain node binary by checking its current version. ```shell zetacored version ``` -------------------------------- ### Install Go Programming Language using Shell Script Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/validate/validator-gcp.mdx This script installs a specific version of the Go programming language. It downloads the tarball, removes any existing Go installation, extracts the new version to /usr/local/go, and cleans up the downloaded archive. ```shell #!/bin/bash GO_VERSION="1.20" # Install Go curl -L -O "https://golang.org/dl/go$GO_VERSION.linux-amd64.tar.gz" sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf "go$GO_VERSION.linux-amd64.tar.gz" rm "go$GO_VERSION.linux-amd64.tar.gz" ``` -------------------------------- ### Tendermint WebSocket Connection Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/network/api.mdx Example of how to connect to the ZetaChain Tendermint WebSocket API using `wscat`. ```APIDOC ## Tendermint WebSocket Tendermint WebSocket API provides access to JSON RPC via WebSockets. ### Request Example ```bash wscat -c wss://zetachain-athens.blockpi.network/rpc/v1/public/websocket ``` ``` -------------------------------- ### Install Cosmovisor using Shell Script and Go Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/validate/validator-gcp.mdx This script builds and installs the Cosmovisor binary, a tool for managing Cosmos SDK nodes. It uses the Go toolchain to install a specific version of Cosmovisor and copies the resulting binary to /usr/local/bin. ```shell #!/bin/bash # Build the Cosmovisor binary. /usr/local/go/bin/go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 cp ~/go/bin/cosmovisor /usr/local/bin/ echo "Built Cosmovisor" ``` -------------------------------- ### Start Local Development Server with Yarn Source: https://github.com/zeta-chain/docs/blob/main/README.md Starts a local development server using Yarn. This command automatically opens a browser window and enables live reloading for most code changes without requiring a server restart. ```bash yarn dev ``` -------------------------------- ### Install SPACE ID SDK and Viem Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/space-id.mdx Installs the necessary packages for the Web3 Name SDK and Viem. For Next.js projects, additional configuration is required to transpile commonjs dependencies. ```bash npm install @web3-name-sdk/core viem@^1.20 ``` ```typescript const nextConfig = { transpilePackages: ["@web3-name-sdk/core"], }; ``` -------------------------------- ### Launch Localnet (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui-withdraw-and-call.mdx Starts the local development environment, setting up instances of ZetaChain and Sui. This command should be kept running to maintain the local network. ```bash npx zetachain localnet start ``` -------------------------------- ### Start ZetaChain Localnet Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/cli.mdx Starts the ZetaChain local network. It allows configuration of the Anvil port, additional Anvil arguments, and options to force kill processes, stop after initialization, or exit on error. It also supports specifying which chains to launch. Dependencies include Anvil and the specified blockchain clients. ```bash Usage: zetachain localnet start [options] Start localnet Options: -p, --port Port to run anvil on (default: "8545") -a, --anvil Additional arguments to pass to anvil (default: "-q") -f, --force-kill Force kill any process on the port without prompting (default: false) -s, --stop-after-init Stop the localnet after successful initialization (default: false) -e, --exit-on-error Exit with an error if a call is reverted (default: false) -v, --verbosity Logger verbosity level (choices: "emerg", "alert", "crit", "error", "warning", "notice", "info", "debug", default: "info") --chains [chains...] Chains to launch when starting localnet (choices: "ton", "solana", "sui", default: []) -h, --help display help for command ``` -------------------------------- ### Launch ZetaChain Local Development Environment Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/solana.mdx Starts the local development network for ZetaChain. This command needs to be run in a terminal and left active to support subsequent development and testing operations. ```bash yarn zetachain localnet start ``` -------------------------------- ### Enable and Reload Systemd Service (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Reloads the systemd daemon to recognize the new service file and enables the zetacored service to start automatically at boot. ```bash sudo systemctl daemon-reload sudo systemctl enable zetacored ``` -------------------------------- ### Install and Compile Project Dependencies Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/standards/nft.mdx These commands are used after creating a new Universal NFT project. 'cd nft' navigates into the project directory. 'yarn' installs project dependencies. 'forge soldeer update' updates Solidity dependencies. 'forge build' compiles the smart contracts. ```bash cd nft yarn forge soldeer update forge build ``` -------------------------------- ### Initialize npm Project and Install Axios Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/alchemy.mdx These commands initialize a new npm project and install the Axios HTTP client, which is necessary for making API requests to the ZetaChain network via Alchemy. ```bash mkdir zetachain-app cd zetachain-app npm init -y npm install axios ``` -------------------------------- ### Initialize ZetaChain Project using CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/hello.mdx Sets up a new ZetaChain project named 'hello' using the ZetaChain CLI. It then installs dependencies using yarn and updates Solidity dependencies with Foundry's Soldeer. This establishes the basic project structure and ensures all necessary tools and libraries are in place. ```bash npx zetachain@latest new --project hello cd hello yarn forge soldeer update ``` -------------------------------- ### Setup Web3 Name SDK Client Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/space-id.mdx Initializes the Web3 Name SDK client. This client is used to interact with the SDK's functionalities for domain name resolution and reverse resolution. ```typescript import { createWeb3Name } from "@web3-name-sdk/core"; const web3Name = createWeb3Name(); ``` -------------------------------- ### ZetaChain Localnet Management Commands Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/cli.mdx Provides commands for managing the ZetaChain local development environment. This includes starting, stopping, checking the status of the localnet, and accessing TON-specific commands. ```bash Usage: zetachain localnet [options] [command] Local development environment Options: -h, --help display help for command Commands: start [options] Start localnet stop Stop localnet check [options] Check if localnet is running ton TON commands ``` -------------------------------- ### Upgrade Existing ERC-721 Project for Universal NFTs Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/standards/nft.mdx This command adds the official ZetaChain standard contracts package to an existing ERC-721 project, allowing it to be upgraded to support Universal NFT functionality. After installation, developers need to integrate Universal NFT-specific logic into their contract, referencing the provided example implementation. ```bash yarn add @zetachain/standard-contracts ``` -------------------------------- ### Configure Zetachain Node with Shell Script Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/validate/validator-gcp.mdx This script performs initial setup for a Zetachain node. It extracts a snapshot archive, removes the archive, sets the keyring backend to 'file', and changes ownership of relevant directories to the 'zetachain' user. Finally, it enables and starts the 'zetacored' systemd service. ```shell gsutil cp /var/lib/zetacored/snapshot.tar gs://${gcs_bucket_static}/snapshot/${zetachain_network}/${zetachain_snapshot} fi tar -xf /var/lib/zetacored/snapshot.tar -C /var/lib/zetacored rm /var/lib/zetacored/snapshot.tar # Set the keyring backend. https://docs.cosmos.network/v0.52/user/run-node/keyring /var/lib/zetacored/cosmovisor/genesis/bin/zetacored --home /var/lib/zetacored \ config keyring-backend file # Change the ownership of the directories. chown -R zetachain:zetachain /var/lib/zetacored/config chown -R zetachain:zetachain /var/lib/zetacored/cosmovisor chown -R zetachain:zetachain /var/lib/zetacored/data # Start the Zetachain node. systemctl enable zetacored.service systemctl start zetacored.service ``` -------------------------------- ### Create ZetaChain Project with CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/swap.mdx Sets up a new ZetaChain project named 'swap' using the ZetaChain CLI. This command initializes the project structure and prepares it for development. ```bash zetachain new --project swap ``` -------------------------------- ### Solidity: Example Swaps using SwapHelperLib Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/swap.mdx Demonstrates how to use a `SwapHelperLib` to perform token swaps. This includes buying an exact amount of a token (e.g., gas) and swapping an exact amount of one token for another. ```solidity // Buy exact destination gas SwapHelperLib.swapTokensForExactTokens( uniswapRouter, inputToken, gasFee, gasZRC20, amount ); // Swap remainder to target SwapHelperLib.swapExactTokensForTokens( uniswapRouter, inputToken, swapAmount, targetToken, 0 ); ``` -------------------------------- ### Compile Solidity Contracts Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/standards/token.mdx This command compiles the Solidity smart contracts for the Universal Token project using the Forge build tool. Ensure Forge is installed and configured in your environment. ```bash forge build ``` -------------------------------- ### Scaffold New Project with ZetaChain CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/frontend.mdx Scaffolds a new ZetaChain project named 'hello' using the ZetaChain CLI. After scaffolding, it navigates into the project's frontend directory and installs dependencies. ```bash npx zetachain@latest new --project hello cd hello/frontend yarn ``` -------------------------------- ### Initialize Messaging Contract Constructor Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/messaging.mdx Initializes the messaging contract with required parameters: Gateway address, owner address, and Router address. These parameters are essential for ZetaChain's cross-chain communication setup. ```solidity constructor( address payable _gateway, address owner, address _router ) Messaging(_gateway, owner, _router) {} ``` -------------------------------- ### Fetch ZetaChain Configuration Files (Shell) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Downloads essential configuration files (genesis.json, client.toml, config.toml, app.toml) for the ZetaChain node from the network repository and saves them to the data directory. Ensure the correct network configuration is selected (mainnet or testnet). ```shell sudo -u zetachain wget https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/genesis.json -O /home/zetachain/.zetacored/config/genesis.json && sudo -u zetachain wget https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/client.toml -O /home/zetachain/.zetacored/config/client.toml && sudo -u zetachain wget https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/config.toml -O /home/zetachain/.zetacored/config/config.toml && sudo -u zetachain wget https://raw.githubusercontent.com/zeta-chain/network-config/main/mainnet/app.toml -O /home/zetachain/.zetacored/config/app.toml ``` -------------------------------- ### Create Project with ZetaChain CLI Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/messaging.mdx Initializes a new project using the ZetaChain CLI with the 'messaging' template. Requires Node.js and npm/yarn. The command creates a new directory with the project structure. ```bash npx zetachain new --project messaging ``` -------------------------------- ### Create Cosmovisor Directories (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Creates the necessary directory structure for Cosmovisor to managezetacored binaries. It ensures the genesis and upgrades directories exist. ```bash sudo -u zetachain mkdir -p /home/zetachain/.zetacored/cosmovisor/genesis/bin &&\ sudo -u zetachain mkdir -p /home/zetachain/.zetacored/cosmovisor/upgrades ``` -------------------------------- ### Installzetacored Binary (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/start-here/setup.mdx Copies the currentzetacored binary to the Cosmovisor genesis bin directory. This ensures Cosmovisor can access the active binary. ```bash sudo -u zetachain cp /usr/local/bin/zetacored /home/zetachain/.zetacored/cosmovisor/genesis/bin ``` -------------------------------- ### EVM RPC Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/network/api.mdx Example of how to interact with the EVM-compatible blockchain of ZetaChain using JSON-RPC to query the latest block number. ```APIDOC ## EVM RPC ZetaChain is an EVM-compatible blockchain. EVM RPC allows you to connect to the ZetaChain blockchain and interact with the EVM. This gives you direct access to reading Ethereum-formatted transactions or sending them to the network. ### Request Example ```bash curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' https://zetachain-athens-evm.blockpi.network/v1/rpc/public ``` ``` -------------------------------- ### Start ZetaChain Localnet Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/localnet.mdx Initiates the ZetaChain local development environment. This command bootstraps all necessary components, including EVM, Solana, Sui, and TON chain simulations, along with pre-deployed protocol contracts, ZRC-20 tokens, and Uniswap pools. It requires Node.js and Foundry (Anvil) as prerequisites. ```bash npx zetachain@latest localnet start ``` -------------------------------- ### Tendermint RPC Block Query Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/network/api.mdx Example of how to query a specific block from the ZetaChain blockchain using the Tendermint RPC API. ```APIDOC ## Tendermint RPC Tendermint RPC API allows broadcasting transactions and querying the blockchain through an JSON RPC interface. ### Request Example ```bash curl --header "Content-Type: application/json" --request POST --data '{"method": "block", "params": ["3336883"], "id": 1}' https://rpc.ankr.com/zetachain_tendermint_athens_testnet ``` ``` -------------------------------- ### Tendermint HTTP Genesis File Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/network/api.mdx Example of how to query the genesis file of the ZetaChain blockchain using the Tendermint HTTP API. ```APIDOC ## Tendermint HTTP ZetaChain is powered by the Tendermint Core BFT consensus engine. The Tendermint HTTP API allows you to query blocks, information about validators, genesis file, etc. ### Request Example ``` https://zetachain-athens.blockpi.network/rpc/v1/public/genesis ``` ``` -------------------------------- ### Subgraph API Response Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/goldsky.mdx Example JSON response from the subgraph API when querying for SwapCompleted events. Shows a list of events with their IDs. ```json { "data": { "swapCompleteds": [ { "id": "0xbfcc4e8ea59625da42aa3eec6e5aba66bcd120f8e83dea8dc855ebd1d834e1e6-25" } ] } } ``` -------------------------------- ### Cosmos SDK HTTP Latest Block Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/network/api.mdx Example of how to query the latest block of the ZetaChain blockchain using the Cosmos SDK HTTP API. ```APIDOC ## Cosmos SDK HTTP ZetaChain is built with Cosmos SDK. Cosmos SDK HTTP API allows querying the state of the ZetaChain blockchain and broadcast transactions. ### Request Example ``` https://zetachain-athens.blockpi.network/lcd/v1/public//cosmos/base/tendermint/v1beta1/blocks/latest ``` ``` -------------------------------- ### Detailed SwapCompleted Event Response Example Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/goldsky.mdx Example JSON response detailing a specific SwapCompleted event from the subgraph API. Includes comprehensive event data. ```json { "data": { "swapCompleteds": [ { "id": "0xbfcc4e8ea59625da42aa3eec6e5aba66bcd120f8e83dea8dc855ebd1d834e1e6-25", "block_number": "3065437", "timestamp_": "1704357233", "transactionHash_": "0xbfcc4e8ea59625da42aa3eec6e5aba66bcd120f8e83dea8dc855ebd1d834e1e6", "contractId_": "0x9846bbde15b857d88ddad4e00cd76962245e1b6f", "zrc20": "0x48f80608b672dc30dc7e3dbbd0343c5f02c738eb", "targetToken": "0x65a45c57636f9bcced4fe193a602008578bca90b", "amount": "369767", "recipient": "0x74623171326472383564353734353078776465363536307179686a377a767a7739383935687132357478" } ] } } ``` -------------------------------- ### Initialize Subgraph Project Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/the-graph.mdx Initializes a new subgraph project. This command requires your subgraph's unique slug obtained from Subgraph Studio and sets up the project structure. ```bash graph init --studio ``` -------------------------------- ### Build and Set Up Solana Program for Withdraw-and-Call Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/solana.mdx Builds an example Solana program and deploys it using Anchor. It also sets the SPL-20 USDC address, preparing the Solana environment for advanced cross-chain interactions where a Solana program is invoked during a withdrawal from ZetaChain. ```bash USDC_SPL=3Kx5SY7SwzdUZSorLVSpPgxBL8DZFiu8mg4FWduu2tQp cd solana && anchor build && npx ts-node setup/main.ts "$USDC_SPL" && cd - ``` -------------------------------- ### Get ZetaChain CLI Help (CLI) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/cli.mdx Retrieves comprehensive help documentation for the ZetaChain CLI and its commands. Users can access full command documentation or use the `--help` flag with any specific command for detailed usage information. ```bash zetachain docs zetachain accounts --help zetachain query balances --help ``` -------------------------------- ### Deploy Universal Contract with Foundry (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui.mdx Compiles and deploys the 'Universal' smart contract to the local ZetaChain RPC endpoint using Foundry's 'forge create'. It uses a provided private key and constructor arguments, outputting the deployed contract address. ```bash UNIVERSAL=$(forge create Universal \ --rpc-url http://localhost:8545 \ --private-key $PRIVATE_KEY \ --broadcast \ --json \ --constructor-args $GATEWAY_ZETACHAIN | jq -r .deployedTo) && echo $UNIVERSAL ``` -------------------------------- ### Extract Localnet Deployment Details Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/call.mdx Retrieves essential deployment information from the localnet registry and Anvil configuration. This includes the RPC URL, a funded private key, and addresses for ZRC20 tokens and Gateway contracts on different chains. Requires `jq` to be installed. ```bash RPC=http://localhost:8545 ZRC20_ETHEREUM=$(jq -r '."11155112".chainInfo.gasZRC20' ~/.zetachain/localnet/registry.json) && echo $ZRC20_ETHEREUM PRIVATE_KEY=$(jq -r '.private_keys[0]' ~/.zetachain/localnet/anvil.json) && echo $PRIVATE_KEY GATEWAY_ETHEREUM=$(jq -r '.["11155112"].contracts[] | select(.contractType == "gateway") | .address' ~/.zetachain/localnet/registry.json) && echo $GATEWAY_ETHEREUM GATEWAY_ZETACHAIN=$(jq -r '.["31337"].contracts[] | select(.contractType == "gateway") | .address' ~/.zetachain/localnet/registry.json) && echo $GATEWAY_ZETACHAIN ``` -------------------------------- ### Build and Deploy Subgraph Source: https://github.com/zeta-chain/docs/blob/main/src/pages/about/services/the-graph.mdx Commands to generate code, build the subgraph, authenticate with Subgraph Studio using a deploy key, and deploy the subgraph. ```bash $ graph codegen $ graph build $ graph auth --studio $ graph deploy --studio ``` -------------------------------- ### Solidity: Get Withdrawal Gas Fee for ZRC-20 Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/swap.mdx Retrieves the gas token and fee amount required for a withdrawal to a destination chain. It interacts with the ZRC-20 contract of the target chain to get this information. ```solidity (address gasZRC20, uint256 gasFee) = IZRC20(targetToken).withdrawGasFee(); ``` -------------------------------- ### Deploy Universal Contract with Forge Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/call.mdx Deploys the Universal smart contract to the local ZetaChain network using the Forge build tool. It utilizes previously extracted RPC URL, private key, and Gateway address. The `--broadcast` and `--json` flags enable broadcasting and JSON output, respectively. ```bash UNIVERSAL=$(forge create Universal \ --rpc-url $RPC \ --private-key $PRIVATE_KEY \ --broadcast \ --json \ --constructor-args $GATEWAY_ZETACHAIN | jq -r .deployedTo) && echo $UNIVERSAL ``` -------------------------------- ### Get All ZRC20 Tokens Information (Solidity) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/evm.md Retrieves information for all registered ZRC20 tokens. This function returns an array of `ZRC20Info` structs, each containing details about a ZRC20 token. It's useful for getting a comprehensive list of all ZRC20 tokens managed by ZetaChain. ```solidity function getAllZRC20Tokens() external view returns (ZRC20Info[] memory); ``` -------------------------------- ### Sui Contract Build and Publish Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui.mdx These commands are used to build and publish a Sui smart contract project locally. The `cd sui` command navigates to the contract's directory. The `sui move build --force` command compiles the Move code. The subsequent command publishes the compiled package to a local Sui instance, capturing the package ID for future use. ```bash cd sui ``` ```bash sui move build --force ``` ```bash SUI_CONTRACT=$(sui client publish \ --skip-dependency-verification \ --json 2>/dev/null | jq -r '.objectChanges[] | select(.type == "published") | .packageId') && echo $SUI_CONTRACT ``` -------------------------------- ### Cloud-Init: Install Packages and Configure User Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/validate/validator-gcp.mdx This cloud-init configuration installs essential packages like curl, git, jq, lz4, build-essential, unzip, and mdadm. It also creates a 'zetachain' user with a locked password. ```cloud-config #cloud-config package_update: true package_upgrade: true packages: - curl - git - jq - lz4 - build-essential - unzip - mdadm users: - name: zetachain gecos: Zetachain lock_passwd: true ``` -------------------------------- ### Deploy Universal Contract to ZetaChain Testnet using Forge Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/call.mdx Deploys a 'Universal' contract to the ZetaChain testnet using the Forge build tool. It requires the RPC URL, private key, and constructor arguments, outputting the deployed address in JSON format. ```bash UNIVERSAL=$(forge create Universal \ --rpc-url $RPC_ZETACHAIN \ --private-key $PRIVATE_KEY \ --broadcast \ --json \ --constructor-args $GATEWAY_ZETACHAIN | jq -r .deployedTo) && echo $UNIVERSAL ``` -------------------------------- ### Example Encoded Message for Arbitrary Calls Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/chains/zetachain.mdx This example demonstrates the structure of an encoded message for arbitrary calls, including the function selector and ABI-encoded arguments. The function selector is derived from the Keccak-256 hash of the function signature, and the arguments follow Ethereum's ABI encoding rules. ```plaintext 0xa777d0dc00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000005616c696365000000000000000000000000000000000000000000000000000000 ``` -------------------------------- ### ZetaChain Testnet Gateway Addresses and RPCs Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/call.mdx Configuration variables for ZetaChain testnet deployment, including Gateway addresses for ZetaChain and a connected EVM testnet (Base Sepolia), and their respective RPC endpoints. ```bash GATEWAY_ZETACHAIN=0x6c533f7fe93fae114d0954697069df33c9b74fd7 GATEWAY_BASE=0x0c487a766110c85d301d96e33579c5b317fa4995 RPC_ZETACHAIN=https://zetachain-athens-evm.blockpi.network/v1/rpc/public RPC_BASE=https://sepolia.base.org ``` -------------------------------- ### Install Zetachain Binary using Shell Script Source: https://github.com/zeta-chain/docs/blob/main/src/pages/nodes/validate/validator-gcp.mdx This script installs the Zetachain binary. It first attempts to download from a GCS bucket and falls back to GitHub if the download fails, then uploads the binary to GCS. It also copies the binary to the Cosmovisor directories for genesis and upgrades. ```shell #!/bin/bash # Copy the Zetachain binary from Cloud Storage if available. echo "Attempting to download Zetachain binary from Cloud Storage" gsutil cp gs://${gcs_bucket_static}/binaries/${zetacored_version}/zetacored-linux-amd64 /usr/local/bin/zetacored if [ $? -eq 1 ]; then echo "Downloading Zetachain binary from GitHub" wget https://github.com/zeta-chain/node/releases/download/${zetacored_version}/zetacored-linux-amd64 -O /usr/local/bin/zetacored gsutil cp /usr/local/bin/zetacored gs://${gcs_bucket_static}/binaries/${zetacored_version}/zetacored-linux-amd64 fi # Copy the Zetachain client binary to the Cosmovisor directory. mkdir -p /var/lib/zetacored/cosmovisor/genesis/bin mkdir -p /var/lib/zetacored/cosmovisor/upgrades/${zetachain_version}/bin cp /usr/local/bin/zetacored /var/lib/zetacored/cosmovisor/genesis/bin/zetacored cp /usr/local/bin/zetacored /var/lib/zetacored/cosmovisor/upgrades/${zetachain_version}/bin/zetacored chmod a+x /usr/local/bin/zetacored echo "Installed Zetachain binary" ``` -------------------------------- ### Get CCTX Data by Inbound Hash Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/evm/cctx.mdx Retrieves cross-chain transaction data by providing an inbound transaction hash from a connected chain. ```APIDOC ## GET /zeta-chain/crosschain/inboundHashToCctxData/{inboundHash} ### Description This endpoint allows you to retrieve the Cross-Chain Transaction (CCTX) data by providing the hash of the inbound transaction that initiated the CCTX. ### Method GET ### Endpoint `/zeta-chain/crosschain/inboundHashToCctxData/{inboundHash}` ### Parameters #### Path Parameters - **inboundHash** (string) - Required - The hash of the inbound transaction from a connected chain. ### Request Example ```json { "example": "https://zetachain-athens.blockpi.network/lcd/v1/public/zeta-chain/crosschain/inboundHashToCctxData/0x8e925fa63c69bd27a3aa8e30f4c0f1e67e5fd3fedb23339b387b51b1543e55af" } ``` ### Response #### Success Response (200) - **cctx_hash** (string) - The unique hash of the cross-chain transaction. - **inbound_hash** (string) - The hash of the inbound transaction. - **outbound_hash** (string) - The hash of the outbound transaction on the destination chain (if applicable). - **chain_id** (string) - The identifier of the source chain. - **status** (string) - The current status of the CCTX (e.g., `ZETA_SEND`, `OUTBOUND_SUCCESS`, `ABORTED`). #### Response Example ```json { "cctx_hash": "0x542b6bd80004f4013b725c2170b9ed01731b8af9dc61bfb5c0534dc2f0d511da", "inbound_hash": "0x8e925fa63c69bd27a3aa8e30f4c0f1e67e5fd3fedb23339b387b51b1543e55af", "outbound_hash": "0x49f67ece0c0b59d58312df91342d46b14496abf2d8a52a1a5ce9f4c6136e8d75", "chain_id": "ethereum-sepolia", "status": "OUTBOUND_SUCCESS" } ``` #### Error Response (404) - **message** (string) - "CCTX not found" ``` -------------------------------- ### Get GatewayZEVM Address (Solidity) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/evm.md This external Solidity function returns the address of the GatewayZEVM contract. It is part of the ICoreRegistry interface. ```solidity function gatewayZEVM() external returns (address); ``` -------------------------------- ### Get Program ID (Const Version) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/solana.md Provides a compile-time constant version of the program ID. This can be useful for optimizations and static initialization. ```rust pub const fn id_const() -> anchor_lang::solana_program::pubkey::Pubkey { /* ... */ } ``` -------------------------------- ### Build and Deploy Universal Contract (Bash) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/sui.mdx This bash script uses `forge` to build and deploy the universal contract to a local ZetaChain environment. It requires the `PRIVATE_KEY` and `GATEWAY_ZETACHAIN` environment variables to be set. The output includes the deployed contract address, which is stored in the `UNIVERSAL` variable. This step is crucial for having the target contract ready on ZetaChain. ```bash forge build ``` ```bash UNIVERSAL=$(forge create Universal \ --rpc-url http://localhost:8545 \ --private-key $PRIVATE_KEY \ --broadcast \ --json \ --constructor-args $GATEWAY_ZETACHAIN | jq -r .deployedTo) && echo $UNIVERSAL ``` -------------------------------- ### Get Program ID Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/solana.md Returns the program's unique identifier (program ID). This is crucial for various on-chain operations and verifications. ```rust pub fn id() -> anchor_lang::solana_program::pubkey::Pubkey { /* ... */ } ``` -------------------------------- ### Create New ZetaChain Project (CLI) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/reference/cli.mdx Scaffolds a new universal contract project using the ZetaChain CLI. It supports specifying an output directory, project name, and verbose logging. ```bash npx zetachain@next new npm install -g zetachain@latest zetachain new zetachain new --verbose zetachain new --output my-project zetachain new --project my-example ``` -------------------------------- ### Deploy Connected Contract to Base Sepolia Testnet using Forge Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/call.mdx Deploys a 'Connected' contract to the Base Sepolia testnet using the Forge build tool. It requires the RPC URL, private key, and constructor arguments, outputting the deployed address in JSON format. ```bash CONNECTED=$(forge create Connected \ --rpc-url $RPC_BASE \ --private-key $PRIVATE_KEY \ --broadcast \ --json \ --constructor-args $GATEWAY_BASE | jq -r .deployedTo) && echo $CONNECTED ``` -------------------------------- ### Get All Chains Information (Solidity) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/evm.md Retrieves information for all chains, both active and inactive, present in the registry. It returns an array of `ChainInfoDTO` structs. ```solidity function getAllChains() external view returns (ChainInfoDTO[] memory chainsInfo); ``` -------------------------------- ### Get All Contracts Information (Solidity) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/evm.md Returns information for all contracts registered within the system. The output is an array of `ContractInfoDTO` structs, detailing each contract. ```solidity function getAllContracts() external view returns (ContractInfoDTO[] memory contractsInfo); ``` -------------------------------- ### Compile and Deploy Universal Contract using Hardhat Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/tutorials/solana.mdx Compiles the smart contract code and deploys a universal contract to the local ZetaChain network using Hardhat. Requires the Hardhat CLI and specifies network and gateway contract addresses. ```bash npx hardhat compile --force npx hardhat deploy --name Universal --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 ``` -------------------------------- ### Get Active Chains (Solidity) Source: https://github.com/zeta-chain/docs/blob/main/src/pages/developers/protocol/evm.md Returns an array of chain IDs for all currently active chains registered in the system. This function does not require any parameters. ```solidity function getActiveChains() external view returns (uint256[] memory); ```