RPC and networks
The chain list
Every L2 Protocol site reads the same JSON feed instead of hardcoding endpoints. Point your own tooling at it and you will never be out of date.
curl https://chains.l2protocol.com/chains.json
Each entry carries the chain id, the native currency, the RPC endpoints, the block explorers and the addresses of the system contracts on that chain.
{
"name": "L2 Protocol",
"chainId": 12216,
"nativeCurrencySymbol": "L2P",
"nativeCurrencyDecimals": 18,
"rpcUrls": [{ "url": "https://rpc.l2protocol.com", "isPrimary": true }],
"blockExplorers": [{ "name": "Blockscout", "url": "https://l2pscan.com", "isPrimary": true }],
"contracts": [{ "name": "governor", "address": "0x..." }]
}
Talking to a node
The RPC is standard JSON-RPC over HTTPS, so anything that speaks Ethereum speaks to it.
curl -s https://rpc.l2protocol.com -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}'
Reading the chain needs no wallet and no key. Every read our own sites do, including the governance tallies and the burn totals, is an eth_call against a public endpoint, and you can make the same call.
Point your tooling at the chain
Anything that talks to an EVM chain needs the same four values.
| Setting | Value |
|---|---|
| Network name | L2 Protocol |
| Chain id | 12216 |
| RPC endpoint | https://rpc.l2protocol.com |
| Currency | L2P, 18 decimals |
| Block explorer | https://l2pscan.com |
In Hardhat:
networks: {
l2protocol: {
url: "https://rpc.l2protocol.com",
chainId: 12216
}
}
In Foundry, foundry.toml:
[rpc_endpoints]
l2protocol = "https://rpc.l2protocol.com"
Read the values from the chain feed rather than pasting them if your tooling can, for the reason above: the feed is what our own sites read, so it is never the stale copy.
The explorer
Blocks, transactions and contract source live at l2pscan.com. Every figure on our sites links back to it, because a number you cannot verify is just a claim.
All of it is available as an API as well, with no key and no registration, and there is an interactive reference where you can call it from the browser:
- The explorer API, the endpoints and how to page through them
- Try the API in your browser, the live reference at
/api-docs - Verify your contract, publishing your source so others can read and call it
RPC or API?
Both answer questions about the chain, and they are good at different things.
The RPC is the chain itself, right now. Use it for current state, for anything you need at the head of the chain, and for sending transactions.
The explorer API is indexed history. Use it for anything that would take many RPC calls to assemble: an address's transaction list, a token's holders, statistics over time. It runs a block or two behind the head, and /api/explorer/status tells you exactly how far.