Using the Web3 API

Getting started

The TEE-attested Web3 relay that protects users' metadata.

1RPC.io provides a single endpoint that protects users' privacy and assets.

  • Zero tracking: Enforces that user metadata is not retained once the request has been successfully relayed. This is also known as burn after relaying.
  • Metadata masking: Metadata attached to a user's request is replaced with 1RPC's own.
  • Random dispatching: Requests are dispatched randomly to providers to break the linkage between wallets when requests are sent from different addresses. Shuffling requests in this manner makes it impossible to log the association between accounts with the same private key.

1rpc.io and 1rpc.ai use a unified account system, so API keys can be used across both platforms. This guide focuses on the 1RPC.io Web3 relay.

Build with 1RPC

Replace the existing URL with 1RPC's endpoint to interact with the blockchain. Public endpoints use https://public.1rpc.io/<network>. Endpoints for API key users use the API key as the path prefix, such as https://1rpc.io/<API_KEY>/<network>.

curl --request POST \
  --url https://public.1rpc.io/eth \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{ "id": 1, "jsonrpc": "2.0", "method": "eth_blockNumber" }'
package main

import (
    "context"
    "fmt"

    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    const url = "https://public.1rpc.io/eth"

    rpcClient, err := ethclient.Dial(url)
    if err != nil {
        panic(err)
    }

    blockNumber, err := rpcClient.BlockNumber(context.Background())
    if err != nil {
        panic(err)
    }

    fmt.Println(blockNumber)
}
const Web3 = require('web3');

const url = 'https://public.1rpc.io/eth';
const web3 = new Web3(new Web3.providers.HttpProvider(url));

web3.eth.getBlockNumber((error, blockNumber) => {
  if (!error) {
    console.log(blockNumber);
  } else {
    console.log(error);
  }
});
from web3 import Web3, HTTPProvider

url = 'https://public.1rpc.io/eth'
web3 = Web3(HTTPProvider(url))
print(web3.eth.block_number)

WebSocket (wss://) endpoints use your API key as the path prefix. See Plans for details.

wscat -c wss://1rpc.io/<API_KEY>/dot

> {"jsonrpc": "2.0", "id": 0, "method": "system_chain"}

On this page