P-20 Blockchain
  • Introduction
    • Overview of P-20 Blockchain
    • Introduction to PVT-USD Stablecoin
    • Key Features and Benefits
    • P-20 Blockchain Whitepaper
  • Terminology
    • Explanation of Key Terms and Concepts
  • Getting Started
    • Installing and Setting Up P-20 Blockchain
    • Creating a P-20 Wallet
    • Obtaining PVT-USD Coins
  • Wallets
    • Overview of Wallet Options
    • Choosing the Right Wallet
    • Wallet Security Best Practices
  • Wallet Guide
    • MetaMask Integration
    • Web Wallet
    • App Wallet
    • Paper Wallet
    • Command Line Wallet
  • P-20 Grants Program
    • Overview of the $100 Million Grant Program
    • Process for Applying and Receiving Grants
  • Command Line Interface (CLI)
    • Installation and Setup Guide for the P-20 Tool Suite
    • Sending and Receiving Coins via CLI
    • Deploying Smart Contracts
  • Using PVT-USD
    • Sending and Receiving PVT-USD Coins
    • Checking Transaction History
    • Managing Wallet Balances
    • Gas Fee Calculation in P-20
    • Exploring Privacy Features of PVT-USD
  • Developing on P-20 Blockchain
    • Programming Model for Native Chain Development
    • Clients and Runtimes for Development
    • Onchain Programs and Contract Development
    • Integrating with EVM for Smart Contract Development
  • EVM Integration
    • Introduction to EVM Integration in P-20 Blockchain
    • EVM Bridge Functionality and Usage
    • EVM JSONRPC API Reference
    • Airdrop Functionality for EVM Integration
  • Simple Smart Contract Tutorial
    • Step-by-Step Guide to Developing and Deploying a Simple Smart Contract on P-20 Blockchain
  • Exchange Integration
    • Adding PVT-USD to Your Exchange
  • Architecture
    • Overview of P-20 Blockchain Architecture
    • Components and Layers of the P-20 Network
    • Consensus Mechanism and Transaction Processing
  • RoadMap
    • Roadmap for Sustainable Development
  • Support and Troubleshooting
    • Frequently Asked Questions
    • Troubleshooting Common Issues
    • Community and Support Resources
Powered by GitBook
On this page
  • P-20 JSONRPC API Reference
  • JSONRPC Endpoint
  • API Methods
  • Conclusion

Was this helpful?

  1. EVM Integration

EVM JSONRPC API Reference

P-20 JSONRPC API Reference

The P-20 JSONRPC API provides a comprehensive set of methods to interact with the P-20 blockchain using the JSON-RPC (Remote Procedure Call) protocol. This API allows developers to integrate their applications with the P-20 blockchain and perform various operations, such as querying blockchain data, executing smart contracts, and managing accounts. In this section, we will explore the P-20 JSONRPC API in depth and provide examples of its usage.

JSONRPC Endpoint

The JSONRPC endpoint is the URL that developers can use to connect to the P-20 blockchain network and access its JSONRPC API. The endpoint URL typically follows the format: http://<hostname>:<port>/jsonrpc. Developers can use the HTTP or HTTPS protocol to communicate with the endpoint.

API Methods

The P-20 JSONRPC API provides a wide range of methods categorized into different groups, including blockchain, accounts, transactions, smart contracts, and more. Let's explore some of the commonly used methods within these categories:

1. Blockchain Methods

  • p20_blockNumber: Returns the current block number of the P-20 blockchain.

  • p20_getBlockByNumber: Retrieves information about a specific block based on its number.

  • p20_getTransactionByHash: Retrieves transaction details based on its hash.

2. Transaction Methods

  • p20_sendTransaction: Sends a transaction to the P-20 blockchain for execution.

  • p20_getTransactionReceipt: Retrieves the receipt of a specific transaction.

3. Smart Contract Methods

  • p20_sendRawTransaction: Sends a raw transaction to the P-20 blockchain for execution.

  • p20_call: Executes a call or transaction against a deployed smart contract without modifying the blockchain state.

  • p20_getCode: Retrieves the bytecode of a deployed smart contract.

Examples

Here are a few examples to demonstrate the usage of the P-20 JSONRPC API methods:

  1. Retrieve Block Number:

Request:
{
  "jsonrpc": "2.0",
  "method": "p20_blockNumber",
  "params": [],
  "id": 1
}

Response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x5B7"
}
  1. Get Transaction by Hash:

Request:
{
  "jsonrpc": "2.0",
  "method": "p20_getTransactionByHash",
  "params": ["0x1234567890123456789012345678901234567890"],
  "id": 2
}

Response:
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": "0x295A8A5294BCEF"
}
  1. Send Transaction:

Request:
{
  "jsonrpc": "2.0",
  "method": "p20_sendTransaction",
  "params": [
    {
      "from": "0x1234567890123456789012345678901234567890",
      "to": "0x0987654321098765432109876543210987654321",
      "value": "0x12A05F200"
    }
  ],
  "id": 3
}

Response:


{
  "jsonrpc": "2.0",
  "id": 3,
  "result": "0x123ABCDEF"
}

These examples demonstrate how to retrieve the current block number, check the balance of an account, and send a transaction using the P-20 JSONRPC API. Developers can leverage these methods and customize the parameters based on their specific requirements.

Conclusion

The P-20 JSONRPC API provides a powerful interface for developers to interact with the P-20 blockchain and build decentralized applications on top of it. By utilizing the various API methods, developers can query blockchain data, manage accounts, execute smart contracts, and more. The examples provided in this section showcase the basic usage of some commonly used methods, enabling developers to integrate their applications seamlessly with the P-20 blockchain.

PreviousEVM Bridge Functionality and UsageNextAirdrop Functionality for EVM Integration

Last updated 1 year ago

Was this helpful?