You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ended up making an example gist resolving basenames using ethers.js since the docs only reference viem and onchainkit. Not sure how the base docs are managed but someone might come to this repo with the same problem so thought I'd leave a link:
import{Contract,utils}from'ethers'import{getProvider}from'./contracts'// https://docs.ethers.org/v5/api/providers/importL2ResolverAbifrom'./L2ResolverAbi.json'// https://gist.github.com/hughescoin/adf1c90b67cd9b2b913b984a2cc98de9constBASENAME_L2_RESOLVER_ADDRESS='0xC6d566A56A1aFf6508b41f6c90ff131615583BCD'constconvertChainIdToCoinType=(chainId)=>{// L1 resolvers to addrif(chainId===1){// 1 is mainnet chain idreturn'addr'}constcointype=(0x80000000|chainId)>>>0returncointype.toString(16).toLocaleUpperCase()}constconvertReverseNodeToBytes=(address,chainId)=>{constaddressFormatted=address.toLowerCase()constaddressNode=utils.solidityKeccak256(['string'],[addressFormatted.substring(2)])// NOTE: hash it as a string not addressconstchainCoinType=convertChainIdToCoinType(chainId)constbaseReverseNode=utils.namehash(`${chainCoinType.toLocaleUpperCase()}.reverse`)constaddressReverseNode=utils.solidityKeccak256(['bytes32','bytes32'],[baseReverseNode,addressNode])returnaddressReverseNode}exportconstgetBaseName=async(address)=>{try{constaddressReverseNode=convertReverseNodeToBytes(address,8453)// 8453 is base chain idconstbaseProvider=awaitgetProvider()constcontract=newContract(BASENAME_L2_RESOLVER_ADDRESS,L2ResolverAbi,baseProvider)constbasename=awaitcontract.name(addressReverseNode)returnbasename}catch(e){console.error('Error getting basename',e)}}
The text was updated successfully, but these errors were encountered:
ended up making an example gist resolving basenames using ethers.js since the docs only reference viem and onchainkit. Not sure how the base docs are managed but someone might come to this repo with the same problem so thought I'd leave a link:
https://gist.github.com/okwme/dde885bced64c92473639a8d2722883c
The text was updated successfully, but these errors were encountered: