Configure custom Avalanche L1 chains in your application.
Learn how to configure custom Avalanche L1 chains in your BuilderKit application.
Define your custom L1 chain using viem
's defineChain
:
import { defineChain } from "viem";
export const myL1 = defineChain({
id: 173750, // Your L1 chain ID
name: 'My L1', // Display name
network: 'my-l1', // Network identifier
nativeCurrency: {
decimals: 18,
name: 'Token',
symbol: 'TKN',
},
rpcUrls: {
default: {
http: ['https://api.avax.network/ext/L1/rpc']
},
},
blockExplorers: {
default: {
name: 'Explorer',
url: 'https://explorer.avax.network/my-l1'
},
},
// Optional: Custom metadata
iconUrl: "/chains/logo/my-l1.png",
icm_registry: "0x..." // ICM registry contract
});
Add your custom L1 chain to the Web3Provider:
import { Web3Provider } from '@avalabs/builderkit';
import { avalanche } from '@wagmi/core/chains';
import { myL1 } from './chains/definitions/my-l1';
function App() {
return (
<Web3Provider
chains={[avalanche, myL1]}
defaultChain={avalanche}
>
<YourApp />
</Web3Provider>
);
}
Property | Type | Description |
---|
id | number | Unique L1 chain identifier |
name | string | Human-readable chain name |
network | string | Network identifier |
nativeCurrency | object | Chain's native token details |
rpcUrls | object | RPC endpoint configuration |
blockExplorers | object | Block explorer URLs |
Property | Type | Description |
---|
iconUrl | string | Chain logo URL |
icm_registry | string | ICM registry contract address |
testnet | boolean | Whether the chain is a testnet |
Here's a complete example using the Echo L1:
import { defineChain } from "viem";
export const echo = defineChain({
id: 173750,
name: 'Echo L1',
network: 'echo',
nativeCurrency: {
decimals: 18,
name: 'Ech',
symbol: 'ECH',
},
rpcUrls: {
default: {
http: ['https://subnets.avax.network/echo/testnet/rpc']
},
},
blockExplorers: {
default: {
name: 'Explorer',
url: 'https://subnets-test.avax.network/echo'
},
},
iconUrl: "/chains/logo/173750.png",
icm_registry: "0xF86Cb19Ad8405AEFa7d09C778215D2Cb6eBfB228"
});