Skip to content

Commit

Permalink
feat: create api docs (#9)
Browse files Browse the repository at this point in the history
# What 💻 
* Create API Reference Docs
  • Loading branch information
itsacoyote authored Apr 11, 2024
1 parent be2c6a9 commit 2640353
Show file tree
Hide file tree
Showing 21 changed files with 3,211 additions and 23 deletions.
8 changes: 3 additions & 5 deletions .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json",
"default": true,
"MD001": false,
"MD003": {
"style": "atx"
},
"MD007": {
"indent": 2
},
"MD013": {
"code_blocks": false,
"line_length": 120,
"line_length": 150,
"tables": false
},
"MD033": false,
"MD003": false,
"MD034": false,
"MD024": false,
"MD022": false
"MD022": false,
"MD023": false
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"editor.insertSpaces": true,
"files.eol": "\n",
"[markdown]": {
"editor.wordWrap": "on"
"editor.wordWrap": "on",
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint",
"editor.formatOnSave": true
}
}
8 changes: 5 additions & 3 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export default defineAppConfig({
},
},
},
'navigation-accordion': {
button: {
label: 'text-sm/6 font-semibold text-left text-pretty',
navigation: {
accordion: {
button: {
label: 'text-left text-pretty',
},
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions components/content/DisplayPartial.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script setup lang="ts">
defineProps<{
partial: string;
path: string;
}>();
</script>

<template>
<ContentQuery
v-slot="{ data }"
path="_partials"
:path
find="one"
:where="{ _partial: true, title: { $icontains: partial } }"
:where="{ _partial: true }"
>
<ContentRenderer :value="data" />
</ContentQuery>
Expand Down
2 changes: 1 addition & 1 deletion content/10.getting-started/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ There are already many websites based on this template:

::display-partial
---
partial: 'Setting up your wallet'
path: '_partials/setting-up-your-wallet'
---
::

Expand Down
74 changes: 74 additions & 0 deletions content/20.api-reference/00.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Overview
description: Explore the comprehensive guide to the zkSync Era JSON-RPC API, offering seamless Ethereum integration and advanced Layer 2 functionalities for developers.
---

Welcome to the zkSync Era API reference documentation! This page provides you with a high-level overview of our API capabilities and essential information.

zkSync Era seamlessly integrates with the Ethereum ecosystem. To achieve this integration,
we support not only the standard <a href="https://ethereum.org/en/developers/docs/apis/json-rpc/" target="_blank">Ethereum JSON-RPC API</a>
but also introduce L2-specific features that enhance functionality.

<!-- TODO: make icon larger -->
::callout{icon="i-heroicons-information-circle" color="amber"}
To ensure a seamless experience, we impose rate limits on both HTTPS and WebSocket APIs.
Generally, these limits are ample, ranging from 10 to 100 requests per second (RPS) per client.
::

## Mainnet

- **Network Name**: zkSync Era Mainnet
- **RPC URL**: https://mainnet.era.zksync.io
- **WebSocket URL**: wss://mainnet.era.zksync.io/ws
- **Chain ID**: 324
- **Currency Symbol**: ETH
- **Block Explorer URL**: https://explorer.zksync.io/

## Testnet

- **Network Name**: zkSync Era Testnet
- **RPC URL**: https://testnet.era.zksync.dev
- **WebSocket URL**: wss://testnet.era.zksync.dev/ws
- **Chain ID**: 280
- **Currency Symbol**: ETH
- **Block Explorer URL**: https://sepolia.explorer.zksync.io/

## API Collections

Explore our curated collections of API endpoints tailored for every need, from seamless Ethereum integrations to advanced debugging tools.
Embrace the full potential of zkSync Era and elevate your dApps to new heights. Discover, integrate, and innovate with our robust API offerings.

::card-group
::card
---
title: Ethereum JSON-RPC API
icon: i-simple-icons-ethereum
to: /api-reference/ethereum-rpc
---
Integrate effortlessly with full compatibility for the Ethereum JSON-RPC API.
::
::card
---
title: zkSync JSON-RPC API
icon: i-zksync-zksync-logo
to: /api-reference/zks-rpc
---
Unlock Layer 2 capabilities with our dedicated zkSync JSON-RPC API.
::
::card
---
title: Debugging JSON-RPC API
icon: i-heroicons-code-bracket-16-solid
to: /api-reference/debug-rpc
---
Simplify your development process with powerful debugging tools.
::
::card
---
title: PubSub JSON-RPC
icon: i-heroicons-signal-solid
to: /api-reference/pub-sub-rpc
---
Stay informed with real-time event subscriptions.
::
::
57 changes: 57 additions & 0 deletions content/20.api-reference/10.conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Conventions
description: Formatting conventions and references for use with zkSync Era API docs.
---

## Hex value encoding

Two key data types get passed over JSON: unformatted byte arrays and quantities.
Both are passed with a hex encoding but with different requirements for formatting.

### Quantities

When encoding quantities (integers, numbers): encode as hex, prefix with "0x",
the most compact representation (slight exception: zero should be represented as "0x0").

Here are some examples:

- 0x41 (65 in decimal)
- 0x400 (1024 in decimal)
- WRONG: 0x (should always have at least one digit - zero is "0x0")
- WRONG: 0x0400 (no leading zeroes allowed)
- WRONG: ff (must be prefixed 0x)

### Unformatted data
When encoding unformatted data (byte arrays, account addresses, hashes, bytecode arrays):
encode as hex, prefix with "0x", two hex digits per byte.

Here are some examples:

- 0x41 (size 1, "A")
- 0x004200 (size 3, "\0B\0")
- 0x (size 0, "")
- WRONG: 0xf0f0f (must be even number of digits)
- WRONG: 004200 (must be prefixed 0x)

## Error Codes

| **Category** | **Error Code** | **Message** | **Description** |
|--------------|----------------|--------------------|-----------------------------------------------------------|
| Standard | -32700 | Parse error | The JSON payload could not be parsed due to invalid syntax. |
| Standard | -32600 | Invalid request | The JSON object is not a valid request structure. |
| Standard | -32601 | Method not found | The requested method does not exist or is not available. |
| Standard | -32602 | Invalid params | The parameters provided to the method are invalid or malformed. |
| Standard | -32603 | Internal error | An unspecified internal error occurred within the JSON-RPC framework. |

## The default block parameter

When requests are made that act on the state of Ethereum, the last default block parameter determines the height of the block.

The following options are possible for the defaultBlock parameter:

- HEX String - an integer block number
- String "earliest" for the earliest/genesis block
- String "latest" - for the latest mined block
- String "safe" - for the latest safe head block
- String "finalized" - for the latest finalized block
- String "pending" - for the pending state/transactions
Loading

0 comments on commit 2640353

Please sign in to comment.