diff --git a/README.mdx b/README.mdx index cf67babc0..983c941b7 100644 --- a/README.mdx +++ b/README.mdx @@ -124,17 +124,20 @@ To run the local build you created, run: npm run serve ``` -### Adding new words to the dictionary +### Check spelling and style -This repository includes a _linter_, which you can think of as a spell-check that also checks code -formatting and standards, and a lot more. It's possible that you might use a word in your content -that is not known to the linter, and your build, or commit, will fail. +This repository includes multiple linters, which you can think of as spell-checks that also inspect +code formatting and standards, and a lot more. It's possible that you might use an unrecognized word, +style your Markdown incorrectly, or otherwise format your content in a way that conflicts with +style guides. -You can run the linter any time with the command `npm run lint`. +The main linter, Vale, is run through Github Actions and checks spelling, formatting, and adherence to +various style guides. Please pay attention to its suggestions and error warnings in the check that +runs on your PR. These errors will not prevent your PR from building, but you should address them +nevertheless. -If the linter finds a word that it doesn't recognize, take a look at `project-words.txt` in the root -directory; if the word that the linter caught is correctly spelled, and you wish it to pass the -linter's test, add it to `project-words.txt`, save, add and commit those changes, and see if it -passes. +See our [guidance on using Vale](https://docs-template.consensys.net/contribute/run-vale) for more +information. -For tidiness, please ensure you adhere to the alphabetical order established in `project-words.txt`. +You can run other linters for code style (CSS, JavaScript) and link formatting any time with the +command `npm run lint`. 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. 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. - -<> - -