Skip to content

Commit

Permalink
feat: add docs on custom chains (#5505)
Browse files Browse the repository at this point in the history
<!-- start pr-codex -->

## PR-Codex overview
This PR introduces support for custom chains in the `thirdweb Engine`, enhancing functionality by allowing users to add and manage their own EVM chains, including RPC URL overrides and related metadata.

### Detailed summary
- Added new section for `Custom Chains` in the documentation.
- Included images related to adding custom chains.
- Provided detailed instructions on overriding chain RPC URLs.
- Added examples for API requests to manage custom chains.
- Specified limitations and additional guidance for using custom chains.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
arcoraven committed Nov 24, 2024
1 parent de2a7ba commit 7dd4298
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 34 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 0 additions & 34 deletions apps/portal/src/app/engine/faq/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,3 @@ Here's an example of a 2-hour timeout:
}
}
```

### How do I customize my RPC?

Use [Update Chain Configuration](https://thirdweb-engine.apidocumentation.com/reference#tag/configuration/POST/configuration/chains) to override a chain's settings.

**Example**

`POST /configuration/chains`

Headers

```text
Content-Type: application/json
Authorization: Bearer <access_token>
```

Body

```json
[
{
"name": "Polygon Mainnet",
"chain": "Polygon",
"slug": "polygon",
"chainId": 137,
"rpc": ["https://<custom_rpc_url>"],
"nativeCurrency": {
"name": "MATIC",
"symbol": "MATIC",
"decimals": 18
}
}
]
```
108 changes: 108 additions & 0 deletions apps/portal/src/app/engine/features/custom-chains/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Callout, createMetadata, DocImage } from "@doc";
import addCustomChain1 from "../../assets/add-custom-chain-1.png";
import addCustomChain2 from "../../assets/add-custom-chain-2.png";
import addCustomChain3 from "../../assets/add-custom-chain-3.png";
import addCustomChain4 from "../../assets/add-custom-chain-4.png";

export const metadata = createMetadata({
title: "Custom Chains | thirdweb Engine",
description: "Engine supports custom chains and chain overrides.",
});

# Custom Chains

Engine supports all [public EVM chains](https://thirdweb.com/chainlist) and your own custom chains.

You can define chain overrides allowing Engine to look up a chain ID's RPC URL, currency, and other metadata.

## Use Cases

- Allow Engine to interact with your private or custom EVM chain.
- Bring your own RPC URL for an existing EVM chain.

## Add a custom chain

When adding a chain override, Engine will use the provided chain metadata for the given chain ID.

<Callout variant='info' title="How to override a chain RPC URL">

To override a chain's RPC URL, provide the same chain ID as an existing chain and a new RPC URL.

</Callout>

**Endpoint**

`POST /configuration/chains`

**Headers**

- `Authorization: Bearer <engine_access_token>`
- `Content-Type: application/json`

**Body**
```json
{
"chainOverrides": [
{
"name": "My Custom Chain",
"chain": "ETH",
"rpc": [
"https://my-custom-rpc-url.com"
],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"chainId": 678,
"slug": "my-custom-chain"
}
]
}
```

Reference: [`POST /configuration/chains`](https://engine-api.thirdweb.com/reference#tag/configuration/POST/configuration/chains)

## View custom chains

Call Engine to [get a chain's metadata](https://engine-api.thirdweb.com/reference#tag/chain/GET/chain/get) or [view all chain overrides](https://engine-api.thirdweb.com/reference#tag/configuration/GET/configuration/chains).

## Limitations

- **When calling the Engine API for a custom chain, provide the chain ID and not the chain slug.** Chain slugs are only supported for public chains.
- Since Engine may be unable to resolve the ABI for your contract automatically, provide the ABI manually to call contract methods. We recommend providing the full function signature:

```json
POST /contract/:chainId/:address/write
{
"functionName": "function setTokenURI(string uri)",
"args": ["ipfs://..."]
}
```

- Due to this reason, extension endpoints like `erc721/transfer` may not be supported for custom chains.

## Add custom chains to the thirdweb dashboard

While you may interact with your custom chain from the Engine dashboard, the UI may not support your custom chain yet. To add it to the dashboard, follow these steps:

<DocImage
src={addCustomChain1}
alt="Add custom chain"
className="max-w-[300px] mx-auto"
/>
<DocImage
src={addCustomChain2}
alt="Add custom chain"
className="max-w-[300px] mx-auto"
/>
<DocImage
src={addCustomChain3}
alt="Add custom chain"
className="max-w-[300px] mx-auto"
/>
<DocImage
src={addCustomChain4}
alt="Add custom chain"
className="max-w-[500px] mx-auto"
/>
4 changes: 4 additions & 0 deletions apps/portal/src/app/engine/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export const sidebar: SideBar = {
name: "Preventing Duplicate Transactions",
href: `${engineSlug}/features/preventing-duplicate-transactions`,
},
{
name: "Custom Chains",
href: `${engineSlug}/features/custom-chains`,
},
{
name: "Account Abstraction",
href: `${engineSlug}/features/account-abstraction`,
Expand Down

0 comments on commit 7dd4298

Please sign in to comment.