How to Utilize ZetaChain RPC API Methods? A Complete & Easy Tutorial

In the world of blockchain technology, the main revolutionizing trend of interoperability is the golden key that unlocks seamless communication and transaction capabilities across diverse networks. ZetaChain has emerged as a powerful platform that enables full interoperability among various blockchain networks. It aims to overcome the limitations of existing blockchains by providing a scalable and secure solution for cross-chain transactions.

This tutorial is your gateway to mastering the methods available on ZetaChain including EVM, Cosmos REST API, and Tendermint RPC, simplifying the complex and empowering your projects with unparalleled connectivity.

Table of Contents

    What is ZetaChain?

    Zetachain is a Simple, Fast, and Secure Omnichain Blockchain. It is a decentralized blockchain protocol that allows for seamless communication and interaction between different blockchain networks. 

    ZetaChain is the first ever L1 blockchain to enable fully interoperable smart contracts, or omnichain smart contracts, that connect all blockchains and bring the power of programmability to non-smart contract chains like Bitcoin and Dogecoin

    Whether you’re dealing with Ethereum, Binance Smart Chain, Polygon, Cosmos, or any other network, ZetaChain’s architecture facilitates seamless communications and transactions.  It provides an unparalleled combination of security, simplicity, and flexibility for developers. ZetaChain stands as the bridge that connects isolated islands in the borderless ocean of blockchains, enabling developers to build truly innovative web3 applications.

    By accessing ZetaChain Mainnet RPC for EVM and Cosmos REST, developers and businesses can work with on-chain data, send requests, and connect to the blockchains to send transactions and messages in ZetaChain, ensuring the highest level of safety, stability, and transaction speed.

    Before we dive into the core of this article and explore the variety of RPC API methods ZetaChain offers, it’s essential to handle a necessary primal step:  access ZetaChain RPC full nodes. You have two primary options for connecting to the ZetaChain network:

    1. Setting up your own ZetaChain node.
    2. Utilizing services from third-party node providers like NOWNodes.

    Given that the first option demands significant time, resources, and financial investment, we strongly recommend you use node providers such as NOWNodes. Our Blockchain-as-a-Service solution, offering access to ZetaChain Full Nodes, is made to economize on your time and finances. It spares you the complexity and responsibility of managing your own nodes, especially when unnecessary. 

    How to Connect to ZetaChain with NOWNodes

    Connecting to ZetaChain RPC Full Nodes with NOWNodes is the most efficient and convenient way to access the ZetaChain blockchain. Moreover, you can easily access ZetaChain’s Tendermint without requiring advanced technical skills or managing infrastructure.

    By choosing NOWNodes RPC endpoints for your ZetaChain RPC development needs, you will receive unparalleled reliability, guaranteed uptime, and 24/7 technical support, allowing you to focus on what matters most: building innovative blockchain solutions. With NOWNodes, you can streamline your Web3 development and crypto business operations for the highest efficiency.

    Wish to get started with a ZetaChain full node today and experience the full power of the ecosystem? Of course, you are! Here’s a simple step-by-step guide on how to do so: 

    1. Visit the NOWNodes website (nownodes.io) and sign up for an account using only your email address and a password. 
    2. Choose a tariff plan that fits your web3 development needs.
    3. With a START FREE plan, you can only access 5 blockchain networks. So, choose ZetaChain mainnet and other blockchains that you wish to connect to. 
    4. On the “DASHBOARD” page find the “ADD API KEY” button and generate your API key.
    5. Finally, when the registration process is complete, it’s time to make some requests! Use the provided endpoint (eg. zetachain.nownodes.io for ZetaChain mainnet full node) and your API key to make it happen.

    If you wish to work with the ZetaChain Tendermint  RPC node interface, it is only available in the PRO plan and higher.

    There are various subscription plans suitable for different development needs. Whether you’re a beginner, you could use our START FREE plan, or you’re an Enterprise owner – we have an ENTERPRISE plan for you, offering 100 MILLION requests/month

    How to Interact with ZetaChain RPC Full Node

    ZetaChain provides a robust set of API methods that developers can utilize to interact with the network. By connecting to the ZetaChain network with NOWNodes you can utilize EVM RPC API, Cosmos REST API, Tendermint RPC, and many other methods available on ZetaChain. Let’s take a closer look at some of the key ZetaChain RPC API methods:

    ZetaChain EVM RPC Methods

    As said, ZetaChain is  Ethereum’s Layer 1 blockchain, which means that it’s compatible with EVM and supports the same methods as used on Ethereum’s main network. For those entrenched in the Ethereum or EVM-compatible universe, ZetaChain’s EVM RPC methods are a godsend. These methods enable you to execute smart contracts, transfer tokens, and interact with the blockchain in familiar ways. 

    To use ETH methods on Zetachain you should use zetachain-evm.nownodes.io endpoint. Now let’s take a look at some of the basic methods of EVM like eth_blockNumber, which returns the current latest block number. Here’s the sample request: 

    https://zetachain-evm.nownodes.io/<api-key>
    --header 'Content-Type: application/json' \
    --data '{
    	"jsonrpc": "2.0",
    	"method": "eth_blockNumber",
    	"params": [],
    	"id": 1
    }

    The response will be a hexadecimal of an integer representing the current block number the client is on. Here’s the sample response: 

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "0x1e1708"
    }

    To explore more ETH methods available on ZetaChain you can visit NOWNodes official documentation

    ZetaChain Cosmos REST API Methods

    ZetaChain is a decentralized and public blockchain network that is built on Cosmos SDK and Tendermint Consensus. This Blockchain is designed to offer interoperability and connectivity across multiple blockchain networks. Its cross-chain interoperability is made possible by its Cosmos SDK origin. Cosmos REST API allows ZetaChain users to retrieve token balances from different networks, stake coins, query different types of information (such as Accounts and Validators data), and much more.  

    To use Cosmos HTTP API methods utilize the provided basic zetachain.nownodes.io endpoint and your API key. Let’s take a look at the /params method which is being used to query the current authentication (auth) module parameters. This endpoint plays a crucial role in retrieving configurations that dictate how aspects such as account management and fee handling are managed within the blockchain network. Here’s an example of how you can make a request with this endpoint: 

    curl --request GET \
      --url https://zetachain.nownodes.io/cosmos/auth/v1beta1/params \
    --header 'Accept: */*' \
    --header 'api-key: <your_api-key>'

    This endpoint queries all the available parameters. Here’s the sample response: 

    {
    	"params": {
    		"max_memo_characters": "256",
    		"tx_sig_limit": "7",
    		"tx_size_cost_per_byte": "10",
    		"sig_verify_cost_ed25519": "590",
    		"sig_verify_cost_secp256k1": "1000"
    	}
    }

    When you make this request, the API responds with the current set of parameters that the auth module is using. These parameters can include settings such as:

    • "max_memo_characters": The maximum number of characters that the memo field of a transaction can contain. 
    • "tx_sig_limit": This parameter defines the maximum number of signatures that a multi-sig transaction can include. 
    • "tx_size_cost_per_byte": This is the cost per byte in the transaction. It’s used to calculate the fee required for a transaction based on its size.
    • "sig_verify_cost_ed25519": and "sig_verify_cost_secp256k1": These parameters specify the cost of verifying signatures using the ED25519 and Secp256k1 signature algorithms, respectively. Signature verification is a crucial step in the transaction validation process.

    It was just one example of many Cosmos API endpoints available on ZetaChain. You can explore all the Cosmos REST API methods here.

    The NOWNodes team is working extremely hard on the new documentation webpage at the moment. Make sure to subscribe to our Telegram Builders Community to get informed first when the new documentation (including ZetaChain) will be published on our website.

    ZetaChain Tendermint RPC Methods

    Monitoring the health of the ZetaChain network and retrieving real-time data is crucial for building robust applications. Whether you’re querying for block information using /block or the information about validators with /validators, these methods provide the necessary tools for engaging with the Tendermint-powered chains.

    To utilize Tendermint RPC API methods utilize the provided endpoint zetachain-tendermint.nownodes.io and your API key. 

    Let’s take a /abci_info Tendermint RPC API method as an example. The primary purpose of this method is to provide information about the application status on the blockchain. 

    curl --request GET \
      --url https://zetachain-tendermint.nownodes.io/abci_info \
      --header 'api-key: <your_api-key>'

    When a request is made to this endpoint, it returns details about the blockchain application that is connected to the Tendermint core. 

    {
    	"jsonrpc": "2.0",
    	"id": -1,
    	"result": {
    		"response": {
    			"data": "zetacore",
    			"version": "12.2.1",
    			"last_block_height": "1987520",
    			"last_block_app_hash": "fPQYM4f8dTjtFaDmh50sh5fDkqi/ypJIhLt4CCcJH/k="
    		}
    	}
    }

    Response data includes the name of the blockchain application, the version of the application, the height of the latest block that has been processed by the application, and a hash of the latest block’s state.

    To explore the methods available on NOWNodes’ ZetaChain Tendermint RPC node you can simply type this endpoint https://zetachain-tendermint.nownodes.io/ into the API Client Application that you use. 

    ZetaChain Specific Crosschain API Methods

    There are several groups of ZetaChain-specific API endpoints designed to cater to various functionalities within the ZetaChain ecosystem, each serving distinct purposes. 

    • /zeta-chain/crosschain
      • This set of endpoints is crucial for facilitating cross-chain interactions, a core feature of ZetaChain that provides constant interoperability
    • /zeta-chain/emissions
      • This group of endpoints relates to the emission mechanisms of ZetaChain, which could involve the distribution of native tokens, rewards, or other incentives within the network.
    • /zeta-chain/fungible
      • These endpoints are dedicated to the management and operation of fungible tokens within the ZetaChain ecosystem, including the native ZETA token and other tokens that may be created or used on the network.
    • /zeta-chain/observer
      • Observer endpoints are designed for monitoring and retrieving information about the state of the ZetaChain network, transactions, blocks, and other relevant data without directly interacting with the chain’s state.

    To explore the ZetaChain-specific API methods you can visit ZetaChain’s Official Documentation.

    Now, let’s take a closer look at one of them, /zeta-chain/fungible/foreign_coins/{index} for example. This endpoint queries data of specific Foreign Coin for a given coin smart contract address. Here’s the sample request: 

    curl --request GET \
      --url https://zetachain.nownodes.io/zeta-chain/fungible/foreign_coins/0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
      --header 'api-key: <your_api_key>'

    This method returns comprehensive information about the specific coin. Here’s the example for USDC Token on Binance Smart Chain.

    {
    	"foreignCoins": {
    		"zrc20_contract_address": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0",
    		"asset": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
    		"foreign_chain_id": "56",
    		"decimals": 18,
    		"name": "ZetaChain ZRC20 USDC on BSC",
    		"symbol": "USDC.BSC",
    		"coin_type": "ERC20",
    		"gas_limit": "100000",
    		"paused": false,
    		"liquidity_cap": "300000000000000000000000"
    	}
    }

    Conclusion

    ZetaChain, with its versatile capabilities, stands as a lighthouse for Web3 developers sailing from one blockchain network to another. By connecting to ZetaChain RPC Full Nodes via NOWNodes and utilizing the various API methods ZetaChain offers, developers are prepared to build more integrated, efficient, and innovative dApps. The era of true cross-chain functionality is upon us, and with this tutorial, you’re fully armored to stand at its forefront.

    Embark on this journey with ZetaChain and NOWNodes, and unlock the boundless potential of blockchain interoperability for your projects. The future is interconnected, and with ZetaChain, you’re poised to lead the charge.

    Please let us know if this guide was helpful by leaving your feedback in the comments in our Telegram Builders Community or just by hitting our DMs at X/Twitter.

    Let’s build truly interoperable dApps #NOW