Skip to content

Update ENS Content-Hash with viem #1159

Discussion options

You must be logged in to vote

Almost everything in your code looks good to me

I did slight changes, and tested in my end and all worked fine;

import ch from 'content-hash';
import { namehash, normalize } from 'viem/ens';
import { privateKeyToAccount } from 'viem/accounts';
import { parseAbi } from 'viem'

import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

const publicClient = createPublicClient({
  transport: http(),
  chain: mainnet,
});

const abi = parseAbi([
  'function setContenthash(bytes32 node, bytes calldata hash) external',
]);

const encodeIpfsHashAndUpdateEns = async (cid, ens) => {
  // used fromIpfs instead of encode. encode method was giving different hex result whe…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by talentlessguy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants