Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
533 changes: 393 additions & 140 deletions content/docs.yml

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions content/documentation/account/authentication/permissions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "Permissions"
description: "Give each token only the access it needs."
subtitle: "Give each token only the access it needs."
slug: documentation/account/authentication/permissions
---

Each token is granted one or more permissions. Each endpoint needs one permission, listed on its API Reference page. A request to an endpoint the token isn't allowed to call is rejected with `403 Forbidden`.

Permissions are named `area:access`, where access is `read` or `write`:

* **`read`** lets a token fetch data, such as `evm:read` for `eth_getBalance` or `balances:read` for the [Balances](/docs/reference/token-api-overview) endpoint.
* **`write`** lets a token change something, such as `evm:write` to send transactions or `webhooks:write` to create webhooks. A `write` permission doesn't include the matching `read`, so grant both if you need both.

## Examples

| Service | Permissions |
| - | - |
| Read-only backend for a wallet | `evm:read`, `balances:read`, `activity:read` |
| Service that sends transactions | `evm:read`, `evm:write` |
| Script that manages webhooks | `webhooks:read`, `webhooks:write` |
| Admin automation | `admin:read`, `admin:write` |

## All permissions

| Permission | Grants access to |
| - | - |
| `evm:read` | EVM methods that read chain state, such as [eth\_blockNumber](/docs/chains/ethereum/ethereum-api-endpoints/eth-block-number) and [eth\_getBalance](/docs/chains/ethereum/ethereum-api-endpoints/eth-get-balance) |
| `evm:write` | EVM methods that submit transactions, such as `eth_sendRawTransaction` |
| `solana:read` | Solana methods that read chain state, such as [getSlot](/docs/chains/solana/solana-api-endpoints/get-slot) and [getBalance](/docs/chains/solana/solana-api-endpoints/get-balance) |
| `bundler:read` | Bundler methods that read user operations, such as [eth\_estimateUserOperationGas](/docs/wallets/api-reference/bundler-api/bundler-api-endpoints/eth-send-user-operation) and [eth\_getUserOperationReceipt](/docs/wallets/api-reference/bundler-api/bundler-api-endpoints/eth-send-user-operation) |
| `bundler:write` | Bundler methods that submit user operations, such as [eth\_sendUserOperation](/docs/wallets/api-reference/bundler-api/bundler-api-endpoints/eth-send-user-operation) |
| `utxo:read` | UTXO methods that read chain state, such as [getblock](/docs/chains/bitcoin/bitcoin-api-endpoints/getblock) and [getrawtransaction](/docs/chains/bitcoin/bitcoin-api-endpoints/getrawtransaction) |
| `utxo:write` | UTXO methods that broadcast transactions, such as [sendrawtransaction](/docs/chains/bitcoin/bitcoin-api-endpoints/sendrawtransaction) |
| `hypercore:read` | Hypercore `/info` methods, such as [allMids](/docs/chains/websockets/hypercore) and [l2Book](/docs/chains/websockets/hypercore) |
| `activity:read` | [Activity](/docs/reference/transfers-api-quickstart) |
| `balances:read` | [Balances](/docs/reference/token-api-overview) |
| `collectibles:read` | [Collectibles](/docs/reference/nft-api-overview) |
| `staking:read` | [Staking](/docs/reference/portfolio-apis) (beta) |
| `defi:read` | [DeFi](/docs/reference/portfolio-apis) (beta) |
| `stablecoins:read` | [Stablecoins](/docs/reference/token-api-overview) (beta) |
| `webhooks:read` | [List Webhooks](/docs/reference/webhooks-overview), [Get Webhook](/docs/reference/webhooks-overview), [Get Addresses](/docs/reference/webhooks-overview) |
| `webhooks:write` | [Create Webhook](/docs/reference/webhooks-overview), [Update Webhook](/docs/reference/webhooks-overview), [Delete Webhook](/docs/reference/webhooks-overview), [Update Addresses](/docs/reference/webhooks-overview) |
| `policies:read` | [List Policies](/docs/wallets/low-level-infra/gas-manager/policy-management/api-endpoints), [Get Policy](/docs/wallets/low-level-infra/gas-manager/policy-management/api-endpoints) |
| `policies:write` | [Create Policy](/docs/wallets/low-level-infra/gas-manager/policy-management/api-endpoints), [Update Policy](/docs/wallets/low-level-infra/gas-manager/policy-management/api-endpoints), [Delete Policy](/docs/wallets/low-level-infra/gas-manager/policy-management/api-endpoints) |
| `admin:read` | [List Apps](/docs/reference/admin-api/overview), [List Teams](/docs/reference/admin-api/overview) |
| `admin:write` | [Create App](/docs/reference/admin-api/overview), [Update App](/docs/reference/admin-api/overview), [Delete App](/docs/reference/admin-api/overview), [Create Team](/docs/reference/admin-api/overview), [Update Team](/docs/reference/admin-api/overview) |

[Networks](/docs/reference/node-supported-chains) and Regions work with any valid token.
16 changes: 16 additions & 0 deletions content/documentation/account/security/audits.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: "Audits"
description: "Get our SOC 2 report and other security documents for your vendor review."
subtitle: "Get our SOC 2 report and other security documents for your vendor review."
slug: documentation/account/security/audits
---

Request reports and see our security controls in the [Alchemy Trust Center](https://trust.alchemy.com).

| | |
| - | - |
| **SOC 2 Type II** | Independent audit of our security controls. Request the report in the Trust Center. |
| **Penetration tests** | Run annually by third parties. |
| **Bug bounty** | Ongoing program run through [Cantina](https://cantina.xyz). |

Our infrastructure runs on AWS, Google Cloud and Cloudflare, which are each SOC 2 certified.
23 changes: 23 additions & 0 deletions content/documentation/account/security/leaked-key-detection.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "Leaked Key Detection"
description: "Keys pushed to public GitHub repositories are revoked automatically."
subtitle: "Keys pushed to public GitHub repositories are revoked automatically."
slug: documentation/account/security/leaked-key-detection
---

We're part of [GitHub's secret scanning partner program](https://docs.github.com/en/code-security/secret-scanning/secret-scanning-partnership-program/secret-scanning-partner-program). If an Alchemy key or access token is pushed to a public GitHub repository, GitHub finds it and tells us within minutes.

When that happens:

1. GitHub detects the key in a public repository, gist or issue, and sends it to us.
2. We check the key is real and active.
3. We revoke it, so it can't be used to spend your compute units.
4. We email your team's admins with where it was found and how to replace it.

Your apps keep working with any key that wasn't leaked. Create a new key in the dashboard, update your app, and remove the old key from your repository and its history.

<Tip>
Keep keys out of code. Load them from environment variables or a secrets manager, and add files like `.env` to `.gitignore`.
</Tip>

See [Rotate an Access Token](/docs/how-to-rotate-api-keys) for how to replace a key without downtime, and [IP Allowlisting](/docs/how-to-add-allowlists-to-your-apps-for-enhanced-security) to make a leaked key unusable outside your servers.
10 changes: 10 additions & 0 deletions content/documentation/account/team/teams.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Teams"
description: "Group members, apps and tokens, such as one team per product or environment."
subtitle: "Group members, apps and tokens, such as one team per product or environment."
slug: documentation/account/team/teams
---

Teams group members, such as one per product or environment. A team can have many members, and a member can be on several teams. Each team has one or more [apps](/docs/create-an-api-key), and each app belongs to one team.

On the Enterprise plan, teams belong to an [organization](/docs/dashboard-organizations), and a member can have a different [role](/docs/dashboard-roles) on each team.
20 changes: 20 additions & 0 deletions content/documentation/architecture/edge.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: "Edge"
description: "Where your requests enter, close to you, before they reach the engine."
subtitle: "Where your requests enter, close to you, before they reach the engine."
slug: documentation/architecture/edge
---

The edge is the front door to every request. It runs in each [region](/docs/documentation/architecture/regions), so your request is received close to where your app runs, and it handles everything that doesn't need a node.

## What the edge does

* **Receives your request** in the closest region. If a region has a problem, traffic moves to another one.
* **Checks your access token** and its [permissions](/docs/documentation/account/authentication/permissions), and rejects requests that aren't allowed before they reach the engine.
* **Applies your [throughput](/docs/reference/throughput) limit,** so a burst returns `429` quickly instead of slowing down other requests.
* **Gives the request a [trace ID](/docs/documentation/monitoring/tracing)** in `x-alchemy-trace-id`, or keeps the one you sent, so the same ID follows it through every layer.
* **Passes it to the [engine](/docs/documentation/architecture/engine/routing)**, which decides how to answer it.

## Caching

The edge works like a globally distributed cache: answers that can't change are served from locations around the world, beyond our [regions](/docs/documentation/architecture/regions#beyond-our-regions), without going further.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Commitment Levels"
description: "How settled a block is, from latest to finalized, for reads and writes."
subtitle: "How settled a block is, from latest to finalized, for reads and writes."
slug: documentation/architecture/engine/consistency/commitment-levels
---

New blocks can be replaced by a reorg before the network settles on them. A commitment level, passed as the block tag, picks how settled the block you read from must be: newer data, or data that won't change.

```bash
curl https://eth-mainnet.g.alchemy.com/v2 \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["finalized", false]}'
```

## Levels

| Tag | What it is | Can it change? | Behind the head on Ethereum |
| - | - | - | - |
| `latest` | The newest block | Yes, a reorg can replace it | 0 |
| `safe` | A block most validators have voted for | Very unlikely | About 6 minutes |
| `finalized` | A block the network has finalized | No | About 13 minutes |

`latest` is the default when you leave out the tag.

## Which to use

* **`latest`** for anything shown to users right away, such as balances and recent activity.
* **`safe`** when acting on data matters but a few minutes of delay is fine, such as crediting a deposit.
* **`finalized`** when a reorg would be costly, such as exchange deposits or bridging.

## Confirming your transactions

A transaction is final once the block it's in is final. After you send one:

1. Get its receipt, and note the `blockNumber`.
2. Read the `safe` or `finalized` block.
3. Once that block's number is at least your receipt's `blockNumber`, your transaction has reached that level.

If a reorg drops the block before then, the receipt disappears and the transaction goes back to the mempool.

## Layer 2 networks

On rollups such as Base, Optimism and Arbitrum, blocks settle in stages:

* **`latest`**: produced by the sequencer, usually in under a second.
* **`safe`**: posted to Ethereum.
* **`finalized`**: posted to Ethereum in a block that Ethereum has finalized.

Need confirmations faster than `safe`? See [Fast Confirmation Rule](/docs/documentation/experiments/fast-confirmation).
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "Read Consistency"
description: "Why your reads always agree with each other, across nodes and regions."
subtitle: "Why your reads always agree with each other, across nodes and regions."
slug: documentation/architecture/engine/consistency/read-consistency
---

Your requests are served by many nodes across several [regions](/docs/documentation/architecture/regions). Nodes don't all see a new block at the same moment, so without care, two requests in a row could disagree:

* `eth_blockNumber` returns block 100, then 99.
* You read block 100, then `eth_getLogs` for block 100 returns nothing because it went to a node that hasn't seen it yet.

## How we keep reads consistent

We track a single canonical chain for each network: the blocks we've confirmed across our nodes. Each request goes to a node that has the blocks it needs, so:

* The head never goes backwards between your requests.
* Once you've seen a block, follow-up requests for it find it.
* During a reorg, every node serves the same chain once we switch over.

If the closest node is behind, your request goes to another node that has the block, in the same region first and then in another.

## Tips

* **Pin the block.** When several calls must describe the same moment, read `eth_blockNumber` once and pass that number to each call instead of `latest`.
* **Check the block hash.** To detect reorgs, compare the `blockHash` of the data you stored with the block's current hash.
* **Use commitment levels.** Read from `safe` or `finalized` for data that must not change. See [Commitment Levels](/docs/documentation/architecture/engine/consistency/commitment-levels).
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "Sticky Routing"
description: "How transactions and filters stay on the node that has them."
subtitle: "How transactions and filters stay on the node that has them."
slug: documentation/architecture/engine/consistency/sticky-routing
---

Some requests only make sense on the node that handled an earlier one. A transaction you just sent sits in that node's mempool before it's shared with the network, and a filter you create lives on the node that created it.

Sticky routing sends these follow-up requests to the same node, so:

* `eth_getTransactionCount` with `pending` counts the transaction you just sent, so your next nonce is right.
* `eth_getTransactionByHash` finds your transaction straight away, before it reaches other nodes.
* `eth_getFilterChanges` reaches the node that holds your filter from `eth_newFilter`.

It works automatically, with no change to your requests.

## Retrying a transaction

If a transaction isn't included, for example because its gas price is too low, it can stay in the node's mempool. Sending the exact same signed transaction again then returns `already known`, because the request goes back to that node.

To retry, replace it instead: sign a new transaction with the **same nonce** and a **higher gas price**, at least 10% more. The node swaps it in for the stuck one.

## Tips

* **Track nonces yourself** when you send many transactions quickly, instead of calling `eth_getTransactionCount` before each one.
* **Wait for the right level.** A receipt means your transaction is in a block, not that it's final. See [Commitment Levels](/docs/documentation/architecture/engine/consistency/commitment-levels).
* **Recreate filters** if `eth_getFilterChanges` returns `filter not found`. Filters expire after a few minutes without being polled.
37 changes: 37 additions & 0 deletions content/documentation/architecture/engine/fallbacks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "Fallbacks"
description: "How a request keeps going when a node or a whole region has a problem."
subtitle: "How a request keeps going when a node or a whole region has a problem."
slug: documentation/architecture/engine/fallbacks
---

A request doesn't depend on one node. If the node it's sent to can't answer, it moves to the next one, and if a whole region has a problem, traffic moves to another region. You don't need to retry or change anything.

## Within a request

Each request tries nodes in this order, and moves on if one times out or can't answer, such as when it doesn't have the block yet:

```mermaid
flowchart LR
Request[Request] --> Consistent[Consistent node<br/>in your region]
Consistent -- fails --> Local[Any healthy node<br/>in your region]
Local -- fails --> Remote[Node in<br/>another region]
```

1. **A consistent node in your region.** A node that's caught up with the latest block we've served you, so [reads stay consistent](/docs/documentation/architecture/engine/consistency/read-consistency).
2. **Any healthy node in your region.** If no consistent node can answer, another node in the same region takes the request.
3. **A node in another region.** If no node in your region can answer, the request goes to another [region](/docs/documentation/architecture/regions) that runs the network. It takes a little longer, but you still get an answer.

## Across a region

We move all of a network's traffic out of a region in two cases:

* **Every node for the network in the region is down.**
* **The network stalls in the region.** If the latest block in the region stops moving, we treat the region as unhealthy and send traffic elsewhere until it recovers. We check this on networks with fast, regular blocks, where a pause reliably means a problem.

Traffic comes back once the region's nodes are healthy and caught up.

## What this means for your app

* **Errors are rarer than node failures.** Most node problems are absorbed by a fallback before you see them.
* **A fallback can add latency.** A request that waits on a slow node before moving on, or is served from another region, takes longer. Set your client timeout above 10 seconds for heavy methods like traces, so a slow node has time to be skipped.
20 changes: 20 additions & 0 deletions content/documentation/architecture/engine/indexes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: "Indexes"
description: "Data the engine answers from directly, without asking a node."
subtitle: "Data the engine answers from directly, without asking a node."
slug: documentation/architecture/engine/indexes
---

A node answers by scanning its own database, block by block. For wide queries that's slow, and for very old data some clients don't keep it at all. So we build our own indexes from the chain, and the engine answers these requests from them instead.

| Index | What it answers | Read more |
| - | - | - |
| **Super Logs** | `eth_getLogs` across any block range, from block `0` to `latest` in one request | [Logs](/docs/deep-dive-into-eth_getlogs) |
| **Data** | An address's balances, collectibles and activity, across networks in one call | [Data](/docs/data) |
| **Historical storage** | Old blocks, transactions, receipts and traces, back to the first block | [Historical Data](/docs/what-is-archive-data-on-ethereum) |

## Super Logs

Most providers cap each `eth_getLogs` call at a few thousand blocks, because a node has to scan every block in the range. Super Logs keeps every log on a network in a separate index, so wide queries are answered from the index in one request, usually in under a second.

It's on by default on supported networks, with no change to your requests. See [Logs](/docs/deep-dive-into-eth_getlogs) for which networks have it and the limits that apply.
29 changes: 29 additions & 0 deletions content/documentation/architecture/engine/routing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: "Routing"
description: "How the engine picks what answers each request."
subtitle: "How the engine picks what answers each request."
slug: documentation/architecture/engine/routing
---

The engine reads each request's method and parameters, and sends it to the backend that can answer it fastest and most reliably:

```mermaid
flowchart LR
Engine[Engine] --> Nodes[Nodes]
Engine --> Index[Indexes]
Engine --> History[Historical storage]
```

* **[Nodes](/docs/documentation/architecture/nodes).** Most methods, including all writes, go to a node that's healthy and caught up with the blocks your request needs.
* **[Indexes](/docs/documentation/architecture/engine/indexes).** Wide queries, such as `eth_getLogs` over many blocks or the [Data](/docs/data) endpoints, are answered from indexes we build from the chain.
* **Historical storage.** Old blocks, transactions and traces come from storage built for history. See [Historical Data](/docs/what-is-archive-data-on-ethereum).

## Choosing a node

When a request goes to a node, the engine picks one that:

* **Has the blocks you need,** so your reads stay [consistent](/docs/documentation/architecture/engine/consistency/read-consistency).
* **Holds your earlier state,** such as a transaction you just sent or a filter you created. See [Sticky Routing](/docs/documentation/architecture/engine/consistency/sticky-routing).
* **Is healthy.** Nodes that lag or fail are taken out of rotation, and a request a node can't answer moves to another one. See [Fallbacks](/docs/documentation/architecture/engine/fallbacks).

Routing is automatic. You send standard JSON-RPC, and the engine does the rest.
Loading
Loading