Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ Avalanche SDK TypeScript provides a complete set of tools and libraries for deve

## Available SDKs

### [Chains SDK](./chains/)

The `Chains` module provides a collection of Avalanche Layer 1 (L1) chain configurations in a standardized format. These configurations are useful for interacting with Avalanche networks in a consistent and type-safe way, and is compatible with libraries like [viem](https://viem.sh/).

- ChainConfig compatible with libraries like `viem`
- Can be used with other Avalanche SDKs like `client` and `interchain`

### [Client SDK](./client/)
The main Avalanche client SDK for interacting with Avalanche nodes and building blockchain applications.

Expand Down
22 changes: 22 additions & 0 deletions chains/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/models
/models/errors
/types
/node_modules
/lib
/sdk
/funcs
/react-query
/mcp-server
/hooks
/index.*
/core.*
/bin
/cjs
/esm
/dist
/.tsbuildinfo
/.eslintcache
/.tshy
/.tshy-*
/__tests__
/coverage
83 changes: 83 additions & 0 deletions chains/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Avalanche L1 Chains

The `Chains` module provides a collection of Avalanche Layer 1 (L1) chain configurations in a standardized format. These configurations are useful for interacting with Avalanche networks in a consistent and type-safe way, and is compatible with libraries like [viem](https://viem.sh/).

## Requirements

- Node.js >= 20.0.0
- TypeScript >= 5.0.0

## Installation

```bash
npm install @avalanche-sdk/chains
```

## Usage

Using any of the listed L1s from the `chains` module is very simple:

```typescript
import { avalancheFuji, dispatch } from "@avalanche-sdk/chains";

console.log(avalancheFuji.id);
```

## ChainConfig

The `ChainConfig` interface extends `viem`'s [official config](https://viem.sh/docs/chains/introduction) by enforcing the following Teleporter related
properties.

This config is used in other Avalanche SDKs like `interchain` and `client`.

```typescript
export interface ChainConfig extends Chain {
blockchainId: string;
interchainContracts: {
teleporterRegistry: Address;
teleporterManager: Address;
}
}
```

## Extending ChainConfig

If you want to test chains locally which are not in this module, you can easily define the chain config like this (see Viem's [Custom Chains](https://viem.sh/docs/chains/introduction#custom-chains)):

```typescript
import { defineChain } from 'viem'

export const zora = defineChain({
id: 7777777,
name: 'Zora',
nativeCurrency: {
decimals: 18,
name: 'Ether',
symbol: 'ETH',
},
rpcUrls: {
default: {
http: ['https://rpc.zora.energy'],
webSocket: ['wss://rpc.zora.energy'],
},
},
blockExplorers: {
default: { name: 'Explorer', url: 'https://explorer.zora.energy' },
},
contracts: {
multicall3: {
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
blockCreated: 5882,
},
},
blockchainId: 'abc';
interchainContracts: {
teleporterRegistry: '0x0000000';
teleporterManager: '0x000000';
}
})
```

## Contributing

You can expand the official `Chains` module by adding the chain config following the above interface.
271 changes: 271 additions & 0 deletions chains/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading