Polygon (MATIC)

Polygon Network API Reference for efficient interaction with Polygon PoS nodes, enabling fast and low-cost transactions with enhanced scalability on Ethereum-compatible blockchains.

Polygon (formerly Matic Network) is a Layer 2 scaling solution for Ethereum that provides faster and cheaper transactions while maintaining security through its Proof-of-Stake consensus mechanism. The network is fully EVM-compatible, meaning developers can use the same Ethereum tools, libraries, and JSON-RPC methods to interact with Polygon.

This API reference provides comprehensive documentation for all available JSON-RPC methods supported by GetBlock's Polygon infrastructure. These methods enable developers to query blockchain data, submit transactions, interact with smart contracts, and build decentralized applications.

TECHNICAL DISCLAIMER: AUTHORITATIVE JSON-RPC API SPECIFICATION.

GetBlock's RPC API reference documentation is provided exclusively for informational purposes and to optimize the developer experience. The canonical and normative specification for Ethereum Virtual Machine (EVM) JSON-RPC methods is solely maintained and published through the official Ethereum Foundation documentation portal at ethereum.org. This resource constitutes the sole authoritative reference implementation of the JSON-RPC 2.0 protocol interface across EVM-compatible execution clients.

Network Information

PropertyValue
Network NamePolygon Chain
Chain ID137
Native CurrencyPOL
Decimals18
Block Time~2 seconds
ConsensusProof-of-Stake (PoS)
EVM CompatibleYes

Base URL

https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/
https://shared.us-east-1.getblock.io/<ACCESS-TOKEN>/
https://shared.ap-southeast-1.getblock.io/<ACCESS-TOKEN>/

Supported Networks

NetworkChain IDJSON-RPCWSSgRPCFrankfurt, GermanyNew York, USASingapore, Singapore
Mainnet137✅✅✅✅✅✅
Amoy80002✅✅✅✅✅❌

Quickstart

  1. Setup project

    Create and initialize a new project:

    bashmkdir polygon-api-quickstart
    cd polygon-api-quickstart
    npm init --yes
  2. Install Axios

    bashnpm install axios
  3. Create file

    Create a new file named index.js. This is where you will make your first call.

  4. Set ES module type

    Set the ES module "type": "module" in your package.json.

  5. Add code

    Add the following code to index.js:

    index.js

    javascriptconst axios = require('axios');
    
    const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';
    
    const payload = {
      jsonrpc: '2.0',
      method: 'eth_blockNumber',
      params: [],
      id: 'getblock.io'
    };
    
    axios.post(url, payload, {
      headers: { 'Content-Type': 'application/json' }
    })
    .then(response => {
      const blockNumber = parseInt(response.data.result, 16);
      console.log('Current Block Number:', blockNumber);
    })
    .catch(error => console.error(error));

    Replace <ACCESS-TOKEN> with your actual access token from GetBlock.

  6. Run the script

    bashnode index.js

    Expected output (example):

    json{
        "jsonrpc": "2.0",
        "id": "getblock.io",
        "result": "0x4a87a53"
    }
  1. Set up the project directory

    bashmkdir polygon-api-quickstart
    cd polygon-api-quickstart
  2. Create and activate a virtual environment

    bashpython -m venv venv
    source venv/bin/activate
    
    # On Windows, use venv\Scripts\activate
  3. Install requests

    bashpip install requests
  4. Create script

    Create a file called main.py with the following content:

    main.py

    pythonimport requests
    import json
    
    url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"
    
    payload = json.dumps({
        "jsonrpc": "2.0",
        "method": "eth_blockNumber",
        "params": [],
        "id": "getblock.io"
    })
    
    headers = {
        'Content-Type': 'application/json'
    }
    
    response = requests.post(url, headers=headers, data=payload)
    print(response.text)

    Replace <ACCESS-TOKEN> with your actual access token from GetBlock.

  5. Run the script

    bashpython main.py

API Categories

Support

For technical support and questions:

See Also