Skip to content

Automatically determine chain by chainId. #418

Answered by jxom
benesjan asked this question in Question
Discussion options

You must be logged in to vote

Yep, you will need to do this on your own, and create your own mapping before passing the chain to viem:

import * as chains from 'viem/chains'

function getChain(id: number) {
  return chains.find(x => x.id === id)
}

const id = getId() 
const chain = getChain(id)

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@fubhy
Comment options

Answer selected by jxom
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@fubhy
Comment options

@0x33dm
Comment options

@jxom
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants