Try it Live
Run Chain examples in the interactive playground
Chain Lookup
Methods and properties for looking up chain configurations by chain ID.byId Record
Chain.byId
Record mapping chain IDs to chain configuration objects. Provides O(1) lookup of any registered chain.
Record<number, Chain>
Returns: Chain | undefined for any chain ID
Defined in: primitives/Chain/Chain.js:36
Delegates to: primitives/Chain/BrandedChain/byId.js:14
Comparison: byId vs fromId
BothChain.byId[id] and Chain.fromId(id) lookup chains by ID:
byId[id]- Direct record access (bracket notation)fromId(id)- Function call, slightly more explicit
byId when:
- You prefer bracket notation
- You’re accessing multiple chains in a loop
- You want the most direct syntax
fromId when:
- You prefer function call syntax
- You want explicit method calls
- You’re chaining operations
Usage Examples
Basic Lookup
Iterating Over Multiple Chains
Dynamic Chain Selection
Chain Validation
All Registered Chains
Common Chain IDs
Type-Safe Chain Map
Safe Chain Access
Network Switch Handler
Chain Registry Explorer
Related
- Constructors - Creating Chain instances
- Metadata - Accessing chain properties
- BrandedChain - Functional API

