# Building on ONINO

<table data-view="cards"><thead><tr><th></th><th></th><th data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>Developer Platform</strong></td><td>Rapidly build and deploy blockchain solutions with ease.</td><td><a href="/pages/Y4DAJFQvnVoIdtqsbrcv">/pages/Y4DAJFQvnVoIdtqsbrcv</a></td><td><a href="/files/sRbaT9UNT2Y4pMHaCxbS">/files/sRbaT9UNT2Y4pMHaCxbS</a></td></tr><tr><td><strong>Mainnet Configuration</strong></td><td>Set up and connect smoothly to the ONINO main network.</td><td><a href="/pages/rbnEDF82KdsdqRnPj0kZ">/pages/rbnEDF82KdsdqRnPj0kZ</a></td><td><a href="/files/T81Ug2II21qpTH9Q4FaV">/files/T81Ug2II21qpTH9Q4FaV</a></td></tr><tr><td><strong>Testnet Configuration</strong></td><td>Quickly configure and test your apps on ONINO’s test network.</td><td><a href="/pages/M5N535rvIirKrvk3nIn2">/pages/M5N535rvIirKrvk3nIn2</a></td><td><a href="/files/T81Ug2II21qpTH9Q4FaV">/files/T81Ug2II21qpTH9Q4FaV</a></td></tr><tr><td><strong>Solidity Compiler Versions</strong></td><td>Guidelines on supported Solidity versions for smart contracts.</td><td><a href="/pages/9SqJBAwf8lY6f14lwkMT">/pages/9SqJBAwf8lY6f14lwkMT</a></td><td><a href="/files/DW881ZsbdQbFb84qo5dt">/files/DW881ZsbdQbFb84qo5dt</a></td></tr><tr><td> <strong>Nodes &#x26; Validators</strong></td><td>Learn how to operate nodes and validate transactions.</td><td><a href="/pages/gG43nRBHIea46hNRv7jt">/pages/gG43nRBHIea46hNRv7jt</a></td><td><a href="/files/DJJqRTNrJo95zciwkT9G">/files/DJJqRTNrJo95zciwkT9G</a></td></tr><tr><td><strong>Start Building</strong></td><td>Explore how to build directly on the ONINO Mainnet.</td><td><a href="/pages/U3C48qWyxGdtzwbtpWVD#building-on-onino">/pages/U3C48qWyxGdtzwbtpWVD#building-on-onino</a></td><td><a href="/files/HDw3VkVFQuSk4roycNqs">/files/HDw3VkVFQuSk4roycNqs</a></td></tr></tbody></table>

## Building on ONINO

ONINO is a **fully EVM-compatible Layer-1 blockchain**, meaning it behaves just like Ethereum and any other EVM-based blockchain from a smart contract perspective. Smart contracts written in Solidity will run on ONINO without modification, and developers can use their favorite Ethereum development libraries and tools to interact with ONINO. This compatibility allows **native interoperability with existing Ethereum tooling,** making the developer experience very familiar.

Developers can work with ONINO using standard Web3 libraries such as **ethers.js**, **web3.js**, and **wagmi**, among others. Below are brief examples of how to connect to ONINO using these tools (simply change the RPC endpoint to switch between Mainnet and Testnet):

### Get Started

#### Using ethers.js

You can use **thers.js** to connect to ONINO by pointing a JSON RPC provider to ONINO’s RPC URL. For example, to connect to ONINO and fetch the latest block number:

```jsx
import { ethers } from "ethers";

// Connect to ONINO (Mainnet in this example)
const provider = new ethers.providers.JsonRpcProvider("<https://rpc.onino.io>");

// Fetch the latest block number (returns a Promise)
provider.getBlockNumber().then(blockNumber => {
  console.log("Latest ONINO block:", blockNumber);
});
```

This code uses the ONINO Mainnet RPC. To target the Testnet instead, you would use the Testnet RPC URL (see details below). All other ethers.js functionalities (like sending transactions, reading contract data, etc.) work the same way as they do on Ethereum.

#### Using web3.js

With **web3.js**, connecting to ONINO is also straightforward. You just initialize a Web3 instance with the ONINO RPC endpoint. For example:

```jsx
const Web3 = require('web3');

// Connect to ONINO (Mainnet)
const web3 = new Web3('<https://rpc.onino.io>');

// Get the ONINO chain ID to verify connection
web3.eth.getChainId().then(chainId => {
  console.log("Connected to chain:", chainId);
});
```

This snippet will output ONINO’s chain ID (e.g., 1425 for Mainnet). You can use all usual `web3.eth` methods on ONINO as you would on Ethereum (for example, `sendTransaction`, contract calls, etc.), since ONINO’s nodes use the same JSON-RPC interface as an Ethereum node.

#### Using wagmi (for React)

If you're building a front-end with **wagmi** (a React hooks library for Ethereum), you can integrate ONINO as a custom chain. Define ONINO’s chain parameters and include them in wagmi’s configuration. For example, to add ONINO Mainnet:

```tsx
import { configureChains, createConfig, Chain } from 'wagmi';
import { publicProvider } from 'wagmi/providers/public';

const oninoMainnet: Chain = {
  id: 1425,
  name: 'ONINO Mainnet',
  network: 'onino',
  nativeCurrency: { name: 'ONINO', symbol: 'ONI', decimals: 18 },
  rpcUrls: {
    default: { http: ['<https://rpc.onino.io>'] },
  },
  blockExplorers: {
    default: { name: 'ONINO Explorer', url: '<https://explorer.onino.io>' },
  },
  testnet: false,
};

const { chains, publicClient } = configureChains(
  [oninoMainnet],
  [publicProvider()]
);

const wagmiClient = createConfig({
  autoConnect: true,
  publicClient,
  chains,
});
```

This configuration snippet creates a custom chain object for ONINO Mainnet and sets up a wagmi client. Once configured, your dApp can connect wallets to ONINO, and wagmi’s hooks (like `useAccount`, `useContractRead`, etc.) will operate on ONINO’s network. For ONINO Testnet, you would use the Testnet chain ID and RPC (and mark `testnet: true`).

*Tip:* Other developer tools such as **Hardhat**, **Truffle**, or **Remix** are also compatible with ONINO. For example, you can deploy contracts via Hardhat by setting the network URL to ONINO’s RPC and chain ID in the Hardhat config, just as you would for any other Ethereum-compatible network.

### Hardhat Configuration for ONINO

To deploy and interact with smart contracts on the ONINO network using Hardhat, you need to configure the `hardhat.config.js` file to include ONINO's network settings. Below is an example configuration:

```jsx
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();

module.exports = {
  solidity: {
    version: "0.8.19", // Use Solidity 0.8.19 or set evmVersion to "paris" for compatibility (see below for more details)
    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
      evmVersion: "paris", // Target the Paris EVM version to avoid PUSH0 opcode issues (see below for more details)
    },
  },
  defaultNetwork: "oninoMainnet",
  networks: {
    oninoMainnet: {
      url: "<https://rpc.onino.io>",
      chainId: 1425,
      accounts: [process.env.PRIVATE_KEY], // Load your private key from env
    },
    oninoTestnet: {
      url: "<https://rpctestnet.onino.io>",
      chainId: 211223,
      accounts: [process.env.PRIVATE_KEY],
    },
  },
};
```

#### Using Reown (Previously Web3Modal)

To integrate ONINO with **Reown's AppKit** (previously known as Web3Modal), first install the necessary packages:

```bash
npm install @reown/appkit @reown/appkit-adapter-wagmi wagmi viem @tanstack/react-query
```

Then, configure AppKit with ONINO's network details:

```jsx
import { createAppKit } from '@reown/appkit/react';
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
import { mainnet } from '@reown/appkit/networks';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WagmiProvider } from 'wagmi';

const oninoNetwork = {
  id: 1425,
  name: 'ONINO Mainnet',
  network: 'onino',
  nativeCurrency: { name: 'ONINO', symbol: 'ONI', decimals: 18 },
  rpcUrls: {
    default: { http: ['<https://rpc.onino.io>'] },
  },
  blockExplorers: {
    default: { name: 'ONINO Explorer', url: '<https://explorer.onino.io>' },
  },
  testnet: false,
};

const projectId = 'YOUR_PROJECT_ID'; // Obtain from Reown Cloud

const metadata = {
  name: 'Your App Name',
  description: 'Your App Description',
  url: '<https://yourapp.com>',
  icons: ['<https://yourapp.com/icon.png>'],
};

const wagmiAdapter = new WagmiAdapter({
  networks: [oninoNetwork],
  projectId,
});

const appKit = createAppKit({
  adapters: [wagmiAdapter],
  networks: [oninoNetwork],
  projectId,
  metadata,
  features: {
    analytics: true,
  },
});

const queryClient = new QueryClient();

function App() {
  return (
    <WagmiProvider config={wagmiAdapter.wagmiConfig}>
      <QueryClientProvider client={queryClient}>
        {/* Your app components */}
      </QueryClientProvider>
    </WagmiProvider>
  );
}
```

Ensure you replace `'YOUR_PROJECT_ID'` with your actual project ID from the Reown Cloud Dashboard. For more details, refer to the [Reown AppKit documentation](https://docs.reown.com/appkit/overview).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onino.io/for-developers/building-on-onino.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
