Skip to content

Latest commit

 

History

History
88 lines (67 loc) · 2.07 KB

authentication.md

File metadata and controls

88 lines (67 loc) · 2.07 KB
description
Authenticate yourself to the Particle Node Service API

Authentication

Endpoint

Base URL: https://rpc.particle.network

The Solana chain's RPC URL is:

{% hint style="info" %} https://rpc.particle.network/solana {% endhint %}

All EVM-compatible chains' RPC URL is:

{% hint style="info" %} https://rpc.particle.network/evm-chain {% endhint %}

Authentication

{% hint style="info" %} We assume you already have a Particle Account and access to our Dashboard, where you can create projects and apps. {% endhint %}

The Web3 APIs require HTTP Basic Authentication:

Basic Auth Key Basic Auth Value
Username Your Project Id
Password Your Project Client Key / Server Key

chainId

  1. You can add it to the URL as param: chainId=xxx
  2. OR You can add it to the JSON RPC request
{
  "chainId": 1, // set chainId here
  "jsonrpc": "2.0",
  "id": "5a91fd28-88a5-4a13-bfa3-bad1cbc048e9",
  "method": "eth_getBalance",
  "params": ["0xE860aE9379B1902DC08F67F50de7b9CC066AF0FF", "latest"]
}

Code Example

{% tabs %} {% tab title="Javascript" %}

const axios = require('axios');

const chainId = 5; // Goerli Network
const projectId = 'Your Project Id';
const projectServerKey = 'Your Project Client Or Server Key';

(async () => {
    const response = await axios.post(`https://rpc.particle.network/evm-chain?chainId=${chainId}`, {
        method: 'eth_getBalance',
        params: [
            '0xE860aE9379B1902DC08F67F50de7b9CC066AF0FF',
            'latest',
        ],
    }, {
        auth: {
            username: projectId,
            password: projectServerKey,
        },
    });

    console.log(response.data);
})();

{% endtab %}

{% tab title="Curl" %}

curl 'https://api.particle.network/server/rpc' \
--header 'Authorization: Basic { Auth String }'

{% endtab %} {% endtabs %}