From 0bd02f6c2c6d051f2ed83f411b0622c46fb31055 Mon Sep 17 00:00:00 2001 From: Marcos Maceo Date: Tue, 22 Oct 2024 23:44:59 +0400 Subject: [PATCH 1/7] feat: add nethermind to docs --- docs/developers/guides/run-a-node/index.mdx | 3 +- .../guides/run-a-node/nethermind.mdx | 158 ++++++++++++++++++ 2 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 docs/developers/guides/run-a-node/nethermind.mdx diff --git a/docs/developers/guides/run-a-node/index.mdx b/docs/developers/guides/run-a-node/index.mdx index 4db7287a4..daa8c39f5 100644 --- a/docs/developers/guides/run-a-node/index.mdx +++ b/docs/developers/guides/run-a-node/index.mdx @@ -18,7 +18,7 @@ Linea Besu is recommended for infrastructure providers and operators who intend node, whether for offering node services to others or for using Linea with a personal, private RPC endpoint. ::: -The vanilla Ethereum clients such as Besu, Geth, and Erigon are recommended if you only want to follow the +The vanilla Ethereum clients such as Besu, Geth, Erigon and Nethermind, are recommended if you only want to follow the Linea chain. They allow you to have a local copy of the Linea blockchain. This view of the state is "trusted" until the transaction, or the block that transaction is in, has been finalized on L1. @@ -31,6 +31,7 @@ to Linea-specific features. | [Linea Besu](./linea-besu.mdx) | Besu client with plugins that implement Linea-specific features, such as [API methods](../../reference/api/index.mdx) and [`finalized`](../finalized-block.mdx) tag. | ✅ | | [Erigon](./erigon.mdx) | A client implementation focused on performance and saving disk space, written in Go. | ❌ | | [Geth](./geth.mdx) | The most widely used open-source Ethereum client, written in Go. | ❌ | +| [Nethermind](./nethermind.mdx) | A high-performance, highly configurable Ethereum execution client built on .NET. | ❌ | There are no financial incentives for running a Linea node, and there is currently no option to diff --git a/docs/developers/guides/run-a-node/nethermind.mdx b/docs/developers/guides/run-a-node/nethermind.mdx new file mode 100644 index 000000000..533d62d69 --- /dev/null +++ b/docs/developers/guides/run-a-node/nethermind.mdx @@ -0,0 +1,158 @@ +--- +title: Nethermind +description: Install the Nethermind client to run a Linea node. +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + +Nethermind is a high-performance Ethereum client written in C# that supports various networks, including Linea. + +:::info important +Install and run a Nethermind client if you want to follow the Linea network by +maintaining a local copy of the blockchain. However, if you want to interact with the network and use +Linea-specific methods and features, you should [install Linea Besu](./linea-besu.mdx) instead. +::: + +You can run Nethermind from a [binary distribution](#run-using-the-binary-distribution) or [using Docker](#run-using-docker). + +## Run using the binary distribution + +:::info +Ensure you review [Nethermind's installation Guidelines](https://docs.nethermind.io/get-started/installing-nethermind) +before installing the Nethermind client. + +If you're not comfortable with installing the binary distribution, consider using [Docker](#run-using-docker) instead. +::: + +### Step 1. Install Nethermind + +[Download and install the Nethermind client](https://docs.nethermind.io/get-started/installing-nethermind/#standalone-downloads). + +### Step 2. Start the Nethermind client + +Start the node using the following command: + + + + + ```bash + nethermind \ + --datadir ./nethermind-data \ + --config linea-mainnet \ + --JsonRpc.Enabled=true \ + --JsonRpc.Host=0.0.0.0 \ + --JsonRpc.Port=8545 \ + --Metrics.Enabled=true \ + --Metrics.ExposePort=8008 + ``` + + + + + ```bash + nethermind \ + --datadir ./nethermind-data \ + --config linea-sepolia \ + --JsonRpc.Enabled=true \ + --JsonRpc.Host=0.0.0.0 \ + --JsonRpc.Port=8545 \ + --Metrics.Enabled=true \ + --Metrics.ExposePort=8008 + ``` + + + +The Nethermind node will attempt to find peers to begin synchronizing and to download the world state. + +## Run using Docker + +### Prerequisites + +Download and install [Docker](https://www.docker.com/products/docker-desktop/). + +### Step 1. Download Docker image + +Download the Nethermind docker image: + +``` +docker pull nethermind/nethermind:latest +``` + + +### Step 2. Start the Nethermind node + + + + + ```bash + docker run -it \ + -v nethermind_data:/nethermind/nethermind_db \ + -p 8545:8545 \ + -p 8008:8008 \ + nethermind/nethermind \ + --datadir /nethermind/nethermind_db \ + --config linea-mainnet \ + --JsonRpc.Enabled=true \ + --JsonRpc.Host=0.0.0.0 \ + --JsonRpc.Port=8545 \ + --Metrics.Enabled=true \ + --Metrics.ExposePort=8008 + ``` + + + + + ```bash + docker run -it \ + -v nethermind_data:/nethermind/nethermind_db \ + -p 8545:8545 \ + -p 8008:8008 \ + nethermind/nethermind \ + --datadir /nethermind/nethermind_db \ + --config linea-sepolia \ + --JsonRpc.Enabled=true \ + --JsonRpc.Host=0.0.0.0 \ + --JsonRpc.Port=8545 \ + --Metrics.Enabled=true \ + --Metrics.ExposePort=8008 + ``` + + + +:::note + +Ensure that you correctly configure the Docker volume to persist data between container restarts. +Without proper volume setup, data will be lost when the container is stopped. +Additionally, make sure to expose the necessary ports (e.g., 8545 for JSON-RPC and 8008 for metrics) +to enable external access to these services. + +::: + +## Confirm the node is running + +You can call the JSON-RPC API methods to confirm the node is running. For example, call +`eth_syncing` to return the synchronization status. +For example the starting, current, and highest block, or `false` if not synchronizing (or if the head of the chain has been reached). + +```bash +curl localhost:8545 \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' +``` + +You should get a result similar to: + +```bash +{ + "jsonrpc": "2.0", + "id": 1, + "result": { + "startingBlock": "0x0", + "currentBlock": "0x5d228", + "highestBlock": "0x3cedec" + } +} +``` + From 6a936bbdf85b5c0a5de2a70ceb15fd7d3d112d65 Mon Sep 17 00:00:00 2001 From: Vaddi Govardhan <71170706+govardhan666@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:12:03 +0530 Subject: [PATCH 2/7] Update hackathons.mdx (#796) Co-authored-by: Joel Willmore <95916148+jlwllmr@users.noreply.github.com> --- docs/developers/community/hackathons.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/community/hackathons.mdx b/docs/developers/community/hackathons.mdx index a2cbe16de..455d81008 100644 --- a/docs/developers/community/hackathons.mdx +++ b/docs/developers/community/hackathons.mdx @@ -124,7 +124,7 @@ share of another 5,000 USDT pool for integrating Verax/Hemera. [See the Hackques #### General track: 5,000 USDT prize pool -We'll be distributing 8,000 USDT amongst the top qualified projects. This can take the form of two +We'll be distributing 5,000 USDT amongst the top qualified projects. This can take the form of two outstanding projects receiving 2,500 USDT each, 10 projects receiving 500 USDT each, or, in the case that no submissions meet our quality bar, no prize being distributed for that month. From 825a84e2c4df7ac6be0033052ca24694d067b5aa Mon Sep 17 00:00:00 2001 From: Byron Gravenorst <50852695+bgravenorst@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:37:37 +1000 Subject: [PATCH 3/7] Add how to information for the Linea API. (#800) * Add how to information for the Linea API. Signed-off-by: bgravenorst * Fix typos. Signed-off-by: bgravenorst --------- Signed-off-by: bgravenorst --- docs/developers/guides/linea-api.mdx | 220 +++++++++++++++++++++ docs/developers/guides/linea-api/index.mdx | 25 --- sidebars.js | 2 +- 3 files changed, 221 insertions(+), 26 deletions(-) create mode 100644 docs/developers/guides/linea-api.mdx delete mode 100644 docs/developers/guides/linea-api/index.mdx diff --git a/docs/developers/guides/linea-api.mdx b/docs/developers/guides/linea-api.mdx new file mode 100644 index 000000000..9a2e4846c --- /dev/null +++ b/docs/developers/guides/linea-api.mdx @@ -0,0 +1,220 @@ +--- +title: Use the Linea API +description: How to make calls to the Linea blockchain using the Linea JSON-RPC APIs +sidebar_position: 6 +image: /img/socialCards/json-rpc-api.jpg +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Linea supports the standard Ethereum JSON-RPC API methods, meaning the developer experience is +identical to building on Ethereum itself. However, some +[Linea-specific methods, and method implementations](../reference/api/index.mdx) differ to Ethereum. + +:::info +View the full list of Linea methods in the +[MetaMask services documentation](https://docs.metamask.io/services/reference/linea/json-rpc-methods/). +::: + +You must connect to an RPC endpoint when making calls to the Linea blockchain. Use one or more of the +following options: + +- **Run your own node**: Either [run your own node by setting it up yourself](./run-a-node/index.mdx), or + [use a node provider](../tooling/node-providers/index.mdx#run-your-own-node). + We recommend running [Linea Besu](./run-a-node/linea-besu.mdx) if you want to run a node yourself and interact with the + blockchain. +- **Connect to a private RPC endpoint**: [Connect to a blockchain infrastructure provider](../tooling/node-providers/index.mdx#private-rpc-endpoints) + such as Infura or Alchemy. Multiple providers offer free tier access. +- **Use a public endpoint**: [Public endpoints](../tooling/node-providers/index.mdx#public-rpc-endpoints) are + free to use but are rate limited and not suitable for production environments. + +## Make calls + +The following examples call the Linea API methods using an Infura endpoint, however you can substitute +the endpoint with whichever endpoint you prefer. + +In the examples, replace `` with your actual Infura API key. + +:::info +View the [list of node providers](../tooling/node-providers/index.mdx) if you require an endpoint. +::: + + +### cURL + +Run the [`curl`](https://curl.se/) command in a terminal: + +```bash +curl https://linea-mainnet.infura.io/v3/ \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}' +``` + +### Node (JavaScript) + +The following examples use various JavaScript libraries to make calls to the Linea blockchain. + +#### Prerequisites + +Install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +or [yarn](https://yarnpkg.com/getting-started/install) as the package manager. Then, in your project +folder, initialise your new project: + + + + + ```bash + npm init -y + ``` + + + + ```bash + yarn init -y + ``` + + + +#### Node Fetch + +1. In your project folder, install the `node-fetch` package: + + + + + ```bash + npm i node-fetch + ``` + + + + ```bash + yarn add node-fetch + ``` + + + +1. Create your JavaScript file and copy the following code: + + ```javascript title="index.js" + const fetch = require("node-fetch"); + + fetch("https://linea-mainnet.infura.io/v3/", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + method: "eth_blockNumber", + params: [], + id: 1, + }), + }) + .then((response) => response.json()) + .then((data) => { + console.log(data) + }) + .catch((error) => { + console.error(error) + }) + ``` + +1. Run the code using the following command: + + ```bash + node index.js + ``` + +#### Axios + +1. In your project folder, install the `axios` package: + + + + + ```bash + npm i axios + ``` + + + + ```bash + yarn add axios + ``` + + + +1. Create your JavaScript file and copy the following code: + + ```javascript title="index.js" + const axios = require("axios") + + axios + .post("https://linea-mainnet.infura.io/v3/", { + jsonrpc: "2.0", + method: "eth_blockNumber", + params: [], + id: 1, + }) + .then((response) => { + console.log(response.data) + }) + .catch((error) => { + console.error(error) + }) + ``` + +1. Run the code using the following command: + + ```bash + node index.js + ``` + +#### Viem + +1. In your project folder, install the `viem` package: + + + + + ```bash + npm i viem + ``` + + + + ```bash + yarn add viem + ``` + + + +1. Create your JavaScript file and copy the following code: + + ```javascript title="index.js" + const { createClient, http } = require('viem'); + + const client = createClient({ + transport: http('https://linea-mainnet.infura.io/v3/') + }); + + client.request({ + method: 'eth_blockNumber', + params: [] + }) + .then((blockNumber) => { + console.log(parseInt(blockNumber, 16)); // Convert hex to decimal + }) + .catch((error) => { + console.error(error); + }); + ``` + +1. Run the code using the following command: + + ```bash + node index.js + ``` \ No newline at end of file diff --git a/docs/developers/guides/linea-api/index.mdx b/docs/developers/guides/linea-api/index.mdx deleted file mode 100644 index 7021d9c11..000000000 --- a/docs/developers/guides/linea-api/index.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: JSON-RPC API -description: Linea uses the Ethereum JSON-RPC API -sidebar_position: 6 -image: /img/socialCards/json-rpc-api.jpg ---- - -# JSON-RPC API - -Linea uses the [Ethereum JSON-RPC API](https://eth.wiki/json-rpc/API). This is because the zkEVM is EVM-equivalent, meaning that the developer experience is identical to building on Ethereum itself. - -Check out Infura's documentation of the Ethereum API [here](https://docs.infura.io/networks/ethereum/json-rpc-methods). - -> ⚠️ At the moment we do not support the `eth_newFilter` and `eth_newBlockFilter` RPC calls. - -<> - -