> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Oasis Sapphire tooling

> Set up MetaMask, Hardhat, and the Sapphire ParaTime wrapper to build confidential smart contracts on Oasis Sapphire through Chainstack endpoints.

Get started with a [reliable Oasis Sapphire RPC endpoint](https://chainstack.com/build-better-with-oasis-sapphire/) to use the tools below.

## Interaction tools

### Geth

Interact with your Oasis Sapphire node using [Geth](https://geth.ethereum.org/docs/getting-started).

1. Install [Geth](https://github.com/ethereum/go-ethereum).
2. Use `geth attach` command with the node endpoint.
3. Invoke any methods from [Web3 JavaScript API](https://web3js.readthedocs.io/).

<CodeGroup>
  ```bash Shell theme={"system"}
  geth attach YOUR_CHAINSTACK_ENDPOINT
  ```
</CodeGroup>

where YOUR\_CHAINSTACK\_ENDPOINT — your node HTTPS or WSS endpoint protected either with the key or password. See [node access details](/docs/manage-your-node#view-node-access-and-credentials).

Example below demonstrates how to get the balance of an address in wei value and convert it to ether value:

<CodeGroup>
  ```js JavaScript theme={"system"}
  web3.fromWei(web3.eth.getBalance("0x4EA0911033792C93639bEd297B9289E136d86F89"))
  ```
</CodeGroup>

### MetaMask

On [node access details](/docs/manage-your-node#view-node-access-and-credentials), click **Connect wallet**.

## Development tools

### Hardhat

Configure [Hardhat](https://hardhat.org/) to deploy contracts and interact through your Oasis Sapphire nodes.

1. Install [Hardhat](https://hardhat.org/) and create a project.
2. Install the [sapphire-hardhat](https://www.npmjs.com/package/@oasisprotocol/sapphire-hardhat) plugin.
3. Install the [dotenv](https://www.npmjs.com/package/dotenv) package to securely load your sensitive variables from a `.env` file.
4. Create a new environment in `hardhat.config.js`:

<CodeGroup>
  ```js hardhat.config.js theme={"system"}
  require("@nomicfoundation/hardhat-toolbox");
  require('@oasisprotocol/sapphire-hardhat');
  require('dotenv').config();

  module.exports = {
    solidity: "0.8.18",
    defaultNetwork: "sapphire_testnet",
    networks: {
      sapphire_testnet: {
          url: `${process.env.YOUR_CHAINSTACK_ENDPOINT}`,
          accounts: [process.env.YOUR_PRIVATE_KEY],
          chainId: 0x5aff,
      },
  },
  };
  ```
</CodeGroup>

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node HTTPS or WSS endpoint protected either with the key or password. See [node access details](/docs/manage-your-node#view-node-access-and-credentials).
* YOUR\_PRIVATE\_KEY — the private key of the account that you use to deploy the contract

5. Run `npx hardhat run --network sapphire_testnet scripts/deploy.js`, and Hardhat will deploy using Chainstack.

### web3.js

Build DApps using [web3.js](https://github.com/ethereum/web3.js/) and Oasis Sapphire nodes deployed with Chainstack.

1. Install [web3.js](https://web3js.readthedocs.io/).
2. Connect over HTTP or WebSocket.

#### HTTPS

Use the `HttpProvider` object to connect to your node HTTPS endpoint and get the latest block number:

<CodeGroup>
  ```js JavaScript theme={"system"}
  const Web3 = require('web3');

  const web3 = new Web3(new Web3.providers.HttpProvider('YOUR_CHAINSTACK_ENDPOINT'));

  web3.eth.getBlockNumber().then(console.log);
  ```
</CodeGroup>

where YOUR\_CHAINSTACK\_ENDPOINT is your node HTTPS endpoint protected either with the key or password.

#### WSS

Use the `WebsocketProvider` object to connect to your node WSS endpoint and get the latest block number:

<CodeGroup>
  ```js JavaScript theme={"system"}
  const Web3 = require('web3');

  const web3 = new Web3(new Web3.providers.WebsocketProvider('YOUR_CHAINSTACK_ENDPOINT'));

  web3.eth.getBlockNumber().then(console.log);
  ```
</CodeGroup>

where YOUR\_CHAINSTACK\_ENDPOINT is your node WSS endpoint protected either with the key or password.

### node.js

You can build a web app to query data using node.js and [axios](https://www.npmjs.com/package/axios):

<CodeGroup>
  ```js JavaScript theme={"system"}
  const axios = require("axios");

  const payload = {
      jsonrpc: "2.0",
      id: 0,
      method: "query",
      params: []

  };

  (async () => {
      const response = await axios.post(`YOUR_CHAINSTACK_ENDPOINT`, payload)
      console.log(response.data)
  })();
  ```
</CodeGroup>

where

* YOUR\_CHAINSTACK\_ENDPOINT — your Chainstack node endpoint protected either with the key or password. See [node access details](/docs/manage-your-node#view-node-access-and-credentials).
* `query` — your JSON-RPC query. In this case, to get the latest block number.

### ethers.js

Build DApps using [ethers.js](https://github.com/ethers-io/ethers.js/) and Oasis Sapphire nodes deployed with Chainstack.

1. Install [ethers.js](https://www.npmjs.com/package/ethers).
2. Connect over HTTPS or WebSocket. See also [EVM node connection: HTTP vs WebSocket](https://support.chainstack.com/hc/en-us/articles/900002187586-Ethereum-node-connection-HTTP-vs-WebSocket).

#### HTTPS

Use the `JsonRpcProvider` object to connect to your node endpoint and get the balance of any address:

<CodeGroup>
  ```js JavaScript theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT ";
  const provider = new ethers.JsonRpcProvider(NODE_URL, NETWORK_ID);
  const eth_getBalance = async () => {
      const balance = await provider.getBalance("ACCOUNT_ADDRESS");
      console.log(balance);
    };
  eth_getBalance()
  ```
</CodeGroup>

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node HTTPS endpoint protected either with the key or password

* NETWORK\_ID — Oasis Sapphire network ID:

  * Mainnet: `23294`
  * Testnet: `23295`

* ACCOUNT\_ADDRESS — the Oasis Sapphire account address

#### WebSocket

Use the `WebSocketProvider` object to connect to your node WSS endpoint and get the latest block number:

<CodeGroup>
  ```js JavaScript theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
  const provider = new ethers.WebSocketProvider(NODE_URL, NETWORK_ID);
  const eth_getBalance = async () => {
      const balance = await provider.getBalance("ACCOUNT_ADDRESS");
      console.log(balance);
    };
  eth_getBalance()
  ```
</CodeGroup>

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node WSS endpoint endpoint protected either with the key or password

* NETWORK\_ID — Oasis Sapphire network ID:

  * Mainnet: `23294`
  * Testnet: `23295`

* ACCOUNT\_ADDRESS — the Oasis Sapphire account address

### Remix IDE

To make Remix IDE interact with the network through a zkEVM node deployed with Chainstack:

1. Get [MetaMask](https://metamask.io/) and set it to interact through a Chainstack node. See [Oasis Sapphire tooling: MetaMask](#metamask).
2. In Remix IDE, navigate to the **Deploy** tab. Select **Injected Provider - MetaMask** in **Environment**.

This will engage MetaMask and make Remix IDE interact with the network through a Chainstack node.
