Last active
August 10, 2022 16:19
-
-
Save ZaK3939/cd7129079d660575fbc9924255ae8291 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sha3 } from "web3-utils"; | |
import contractAbi from "./abi/ENS.json"; | |
const namehash = require("@ensdomains/eth-ens-namehash"); | |
// Config | |
/* -------------------------------------------------------------------------- */ | |
const secretkey ="<0x123456>" | |
const INFURA_API_KEY ="<aaaaa>" | |
// Definitely long strings (ex. phiphi0320102081028) causes this problem 0x problem. | |
// Only happen testnet(ex.goerli)? | |
const subdomain ="phi0320102081028" | |
const ENSAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; | |
const resolverAddress = "0x4b1488b7a6b320d2d721406204abc3eeaa9ad329"; | |
/* -------------------------------------------------------------------------- */ | |
const providerUrl = `https://goerli.infura.io/v3/${INFURA_API_KEY}`; | |
const provider = new ethers.providers.JsonRpcProvider(providerUrl); | |
// this owner has testdemo.eth owner | |
const wallet = new ethers.Wallet(secretkey).connect(provider); | |
const contract = new ethers.Contract(ENSAddress, contractAbi.abi, wallet); | |
const tx = await contract.setSubnodeRecord( | |
namehash.hash("testdemo.eth"), | |
sha3(subdomain), | |
params.address, | |
resolverAddress, | |
0, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment