Integrating Radix RPC Advanced Node API – A Complete Guide

Welcome to our first Radix and NOWNodes API guide! In this tutorial, we will guide you through the process of setting up your Radix Advanced Node API and integrating a Radix RPC Full Node endpoint avoiding 404-errors. Additionally, we are going to provide you with examples of the Radix endpoint integration for internal tests before deployment. 

In the fast-evolving landscape of Web3 development and the rise of useful DeFi building platforms, Radix emerges as a powerful blockchain development environment that helps builders utilize powerful resources for DeFi applications and services. Understanding how and why to integrate the Radix Advanced Node API into your code opens up a realm of no-limit capabilities for the requests and ensures a smooth deployment process. Let’s dive into this guide!

You can save this tutorial and share it for development needs 🙂

Table of Contents

    Understanding the Radix platform and its Network

    Before we dive into the technical aspects of developing on Radix with a Node API, let’s take a moment to understand the Radix blockchain and network. 

    Radix is a layer-1 decentralized network designed specifically for the efficient creation and execution of decentralized applications (dApps) and tokens. It aims to address the major limitations of existing blockchain systems: scalability, security, and developer experience. Radix employs a unique consensus mechanism and ledger structure, making it an intriguing platform for developers looking to build scalable dApps.

    How Radix Utilizes Scrypto

    Scrypto is a domain-specific language developed by Radix for crafting smart contracts on its network. It is designed to be an asset-oriented programming language, making it inherently suitable for financial applications. Scrypto leverages the Radix Engine, a component designed to ensure that transactions and smart contracts adhere to specific rules for assets, thereby enhancing security and compliance. This approach allows developers to focus on the business logic of their applications, with the underlying platform handling the intricacies of asset management and transaction processing.

    Developing on Scrypto is considered to be more accessible for numerous reasons:

    1. First, its asset-oriented nature simplifies the creation of financial applications, which are common use cases for blockchain technology. This contrasts with other blockchain development languages that require extensive boilerplate code to handle asset transactions securely. 
    2. Secondly, Scrypto provides higher-level abstractions that reduce the risk of common vulnerabilities found in smart contracts, making it easier for developers to write secure code. 
    3. Finally, Scrypto’s integration within Radix offers a more seamless development experience, with tools and resources tailored to the language and platform’s unique features.

    There are several use cases for the Radix Advanced Node API:

    • Faster and Smoother deployment of Contracts on the mainnet.
      Since NOWNodes Advanced Node API comes with an expanded throughput and capacities, the latency for builders streams right to almost zero;
    • Complete On-Chain Data.
      Our Radix API comes with two main software platforms: Core API and Gateway instance. This ensures the Radix on-chain data availability via one endpoint;
    • Greater User Experience via the backend.
      Updating and displaying the information on your frontend and in the data bases requires prompt and swift updates. The Radix Advanced API comes with zero RPS limits on all paid plans. Since the number of processed Radix transactions can scale to 100x of today’s level, it’s important to provide the capacities for the scalability. 

    Radix RPC Full Node by NOWNodes may be integrated in any configuration of the contract or be used for the on-chain activities that require interacting with the network. 

    Let’s get straight to the guide and proceed to the #BUIDLing!

    Step-by-step tutorial on Integrating Radix RPC Node API

    Performing on-chain activities on Radix involves several steps, including the use of a custom Remote Procedure Call (RPC) endpoint and an API key for enhanced security and control. 

    Always refer to the latest Radix and NOWNodes documentation for the most accurate and detailed guidance.

    Here’s an overview of the integration! This time we’ll exercise in sending and pushing a transaction in the Radix main network.

    Step 0. Prepare Radix-related Data and Tools

    For this tutorial we are going to use:

    • On-chain Data (may be taken from the Radix Explorer);
    • Raw data (conducted directly in the service backend or taken from the DB);
    • Radix Advanced Node API endpoints;
    • Optional – API Environment (Postman, Insomnia)

    Step 1. Obtain your Private API key for Radix Advanced Node API

    The easiest way to access our Radix Node API is to visit a dedicated Radix page at our development hub and create or sign into your profile. If needed, go through the registration process and create an API key. Our Radix Node API supports both Core and Gateway interfaces – a big place to practice and play.

    Never share your API key in text messages or screenshots – even with the NOWNodes team. This is your personal information.

    Step 2. Configure the Radix RPC Node API

    In this step we’ll test the connection to make sure that we will not receive any 500-type of the errors. You can find an example of a call to the Radix mainnet that will display the information about the network, such as the USD price in XRD, the installed tools, etc. 

    curl --request POST \
      --url https://xrd.nownodes.io/core \
      --header 'Content-Type: application/json' \
      --header 'api-key: xxxxxxxxxxx'

    Step 3. Working with Existing Transactions

    Let’s now browse the available methods that can be utilized in order to work with Radix transactions and push them. In this step we’ll collect the most popular endpoints that are useful and popular in the backend development.

    Let’s use a method like getTransactionReceipt to check if everything is on track. Here’s the method in full size:

    In this case we interact with the Radix network through a NOWNodes RPC endpoint. This endpoint is part of the Radix Node API, which facilitates communication between client applications and the Radix network. 

    There are other RPC JSON methods for Radix Full Node that we can use to collect the information on the existing transaction. They include:

    Radix Core API:

    1. Get Transaction Status 
    2. Get Transaction Receipt
    3. Transaction Preview
    4. Get Mempool Transaction
    5. Get Committed Transactions

    Radix Gateway API:

    1. Similar Methods to Radix Core API
    2. Get Committed Transaction Details
    3. Get Transactions Stream

    Step 4. Sending Transactions with XRD

    Building transactions and pushing them directly on-chain requires several JSON-RPC methods. Let’s browse some of them:

    1. Previewing the Transaction

    In this case we will use the transaction/preview/ for the desired endpoint and the command. For this type of method you will need to use the data for the public key. Here’s an example of a request:

    curl --request POST \
      --url https://xrd-gateway.nownodes.io/transaction/preview \
      --header 'Content-Type: application/json' \
      --header 'api-key: xxxxxxxx' \
      --data '{
      "manifest": "string",
      "blobs_hex": [
        "string"
      ],
      "start_epoch_inclusive": 10000000000,
      "end_epoch_exclusive": 10000000000,
      "notary_public_key": {
        "key_type": "KEYTYPE"
      },
      "notary_is_signatory": true,
      "tip_percentage": 65535,
      "nonce": 0,
      "signer_public_keys": [
        {
          "key_type": "KEYTYPE"
        }
      ],
      "flags": {
        "use_free_credit": true,
        "assume_all_signature_proofs": true,
        "skip_epoch_check": true
      }
    }'

    Make sure you inserted the correct variables in the properties in order to avoid 400-type errors.

    2. Sending the Transaction

    For this type of the method, the JSON-body (stated parameters) will be less in size than the previous one. In this case, we’ll be only using the Notarized Transaction HEX – the transaction payload

    curl --request POST \
      --url https://xrd-gateway.nownodes.io/transaction/submit \
      --header 'Content-Type: application/json' \
      --header 'api-key: xxxxxxx' \
      --data '{
      "notarized_transaction_hex": "string"
    }'

    Make sure that your Transaction Hex is actually HEX-encoded. The Radix official GitHub repo has a complete tutorial on how to construct a simple transaction from scratch.  There are various services that you could use to encode the variable for the transaction hash, like this one.

    Conclusion and Resources for Further Learning

    Great news! This is our first installment of an important #NOWBuild campaign which we launched together with the Radix Community Council team. It will include technical guides for the fast and smooth development and community workshops. 

    Make sure you rate this guide and leave your feedback on NOWNodes Radix RPC Full Node. You can email us at [email protected] or leave a message in our builders community.

    Get access to the Radix RPC Full node with a reliable blockchain-as-a-service provider NOWNodes!