# RPC API

Astrone uses the astrone.request(args) method to wrap an RPC API.

The API is based on an interface exposed by all Ethereum clients, along with a growing number of methods that may or may not be supported by other wallets.

Tip

All RPC method requests can return errors. Make sure to handle errors for every call to astrone.request(args).

# Table of Contents

# Ethereum JSON-RPC Methods

For the Ethereum JSON-RPC API, please see the Ethereum wiki (opens new window).

Important methods from this API include:

# Restricted Methods

Astrone introduced Web3 Wallet Permissions via EIP-2255 (opens new window). In this permissions system, each RPC method is either restricted or unrestricted. If a method is restricted, the caller must have the corresponding permission in order to call it. Unrestricted methods, meanwhile, have no corresponding permission. Some of them still rely upon permissions to succeed though (e.g. the signing methods require that you have the eth_accounts permission for the signer account).

If you're interested in learning more about the theory behind this capability-inspired permissions system, we encourage you to take a look at EIP-2255 (opens new window).

# Unrestricted Methods

# Usage with eth_changeNetwork

We recommend using this method with eth_changeNetwork:

try {
  await astrone.request({
    method: 'eth_changeNetwork',
    data: {
      params: { chainId: 56 },
    },
  });
} catch (error) {
  // handle error
}

# eth_changeNetwork

EIP-3326

This method is specified by EIP-3326 (opens new window).

# Parameters

  • string

    1. SwitchEthereumChainParameter - Metadata about the chain that Astrone will switch to.
interface SwitchEthereumChainParameter {
  chainId: string;
}

# Returns

object - The method returns object if the request was successful, and an error otherwise.