以原价购买的最后机会:专用 SOL 和档​​案 ARB 和 ETH

banner image

Getting Started With XRP Ledger API Methods: Guide 

Alex Grace

Alex Grace

March 14, 2023

5 分鐘閱讀

article cover

In this text, GetBlock, a top-tier blockchain RPC node provider, explains the concept of blockchain node, RPC methods, and demonstrates how these methods can be used to get the information from veteran blockchain XRP Ledger or XRPL.

What is RPC?

In software development, RPC stands for ‘remote procedure call’, a communication protocol used to request a service or functionality from an application or a network. It allows a program to make a request to another program or server, as if they were on the same machine, without the need for low-level network programming.

In the context of blockchain, RPC is commonly used by decentralized applications (dApps) that are communicating with blockchain nodes. For instance, Ethereum and Bitcoin - two largest blockchains - have JSON-RPC interfaces that allow developers to interact with the blockchain via HTTP requests, including querying the blockchain for information, sending transactions, and deploying smart contracts.

What is an RPC node?

An RPC node is a type of node that provides a remote procedure call (RPC) interface for a blockchain network. It allows developers to interact with the blockchain network via API (application programming interface) calls.

In the context of blockchain, an RPC node typically runs a full node that maintains a complete copy of the blockchain's ledger and participates in the consensus process, and exposes an API interface that can be accessed remotely. This interface enables developers to build blockchain-based applications: cryptocurrency wallets, NFT marketplaces, on-chain exchanges, and so on.

What are RPC methods?

In blockchain development, RPC methods are specific commands that can be called by a client application to interact with a blockchain node. These methods are usually exposed via an API or a network interface that enables communication between the client and the blockchain node.

RPC methods are an essential part of blockchain development because they allow developers to access the data stored on the blockchain and interact with the network with no need to write commands manually again and again.

For instance, let’s check some popular blockchain RPC methods for XRP Ledger, a decentralized network focused on cross-border payments and crypto adoption in retail:

account_lines: retrieves information about an account's trust lines, including balances in all non-XRP currencies and assets;
account_tx: retrieves a list of transactions that involved the specified account;
gateway_balances: calculates the total balances issued by a given account, optionally excluding amounts held by operational addresses;
tx: retrieves information on a single transaction, by its identifying hash

Request:

curl --location --request POST 'https://xrp.getblock.io/mainnet/' \
--header 'x-api-key: YOUR-API-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"jsonrpc": "2.0",
"method": "fee",
"params": [{}],
"id": "getblock.io"}'
}

Responce:

{
    "result": {
        "current_ledger_size": "92",
        "current_queue_size": "0",
        "drops": {
            "base_fee": "10",
            "median_fee": "5000",
            "minimum_fee": "10",
            "open_ledger_fee": "10"
        },
        "expected_ledger_size": "102",
        "ledger_current_index": 63648985,
        "levels": {
            "median_level": "128000",
            "minimum_level": "256",
            "open_ledger_level": "256",
            "reference_level": "256"
        },
        "max_queue_size": "2040",
        "status": "success"
    }
}

Here’s how we can check the current state of XRPL fees with the fee method.

All code samples and instructions on how you can run mentioned XRPL RPC methods yourself can be found on GetBlock documentation portal.

Context Banner

What is XRP Ledger?

XRP Ledger or XRPL is a decentralized network (blockchain) launched in 2012 by David Schwartz, Jed McCaleb, and Arthur Britto. The protocol was introduced as ‘Bitcoin without mining’ and prioritized decentralization, usability and open-source approach. XRP is the first native coin of XRP Ledger.

Since 2013, the blockchain has been operated by Ripple Labs. Ripple uses XRPL and XRP to deliver the services of cross-border remittances for individuals and organizations. Ripple’s ‘money corridors’ are popular in LatAm and Asia Pacific.

XRP Ledger doesn’t support smart contracts by default; however, the experiments with NFTs and DeFis on XRPL are curated by XRPL Foundation, a non-profit launched in 2020.

XRPL RPC nodes 101: Finding XRP deposit by address

In this primer, we’re going to demonstrate how a crypto wallet with XRP support recovers the details of XRP deposits initiated by known addresses.

For every address in question, let’s find the transactions authorized by it. To do so, we need to use the account_tx method.
Once we get a pool of transactions, let’s find the one in question by parsing;
If it is found, we need to create the transaction on our side with account_info method (required to get the wallet balance) and fee method to check out the network’s commission.
Now, let’s sign and authorize the transaction by the submit method.
To confirm the deposit, we need to check the number of confirmations via the tx method.

P.S. Also feel free to check the demo of how GetBlock users work with XRPL node: https://www.youtube.com/watch?v=5azQT3xTCWc

That’s it! Now you know the basics of XRPL RPC methods and blockchain APIs. To continue this marvelous journey, sign up and order your first RPC node endpoints: https://account.getblock.io/sign-in

常问问题

  • Does XRP Ledger use XRP?

    plus
  • Who are the largest XRP holders?

    plus
  • Can the XRP Ledger be forked?

    plus
  • What major banks use XRP?

    plus
  • Is the XRP Ledger decentralized?

    plus
Alex Grace

Alex Grace

March 14, 2023

5 分鐘閱讀

twittertwittertelegramtelegramLinkedinLinkedin