Skip to content

Instantly share code, notes, and snippets.

@puyu-eth
Last active December 23, 2021 21:04
Show Gist options
  • Save puyu-eth/5078f7c214d61eb42c9772035216cdf8 to your computer and use it in GitHub Desktop.
Save puyu-eth/5078f7c214d61eb42c9772035216cdf8 to your computer and use it in GitHub Desktop.
ENS commitment
const send_commitment = async(ens_name, owner_address, secret, resolver, pub_key) => {
console.debug(`Check if ENS is available for ${ens_name}.eth.`);
const available = await contract.available(ens_name);
if (! available) { console.debug("Name is not available"); return };
console.debug("Get commitment object.");
const commitment = await contract.makeCommitmentWithConfig(
ens_name, // name
owner_address, // owner
secret, // secret
resolver, // resolver
owner_address, // addr
);
console.debug("Send commitment.");
const resp = await contractConnected.commit(commitment, {
value: 0,
maxFeePerGas: ethers.utils.parseUnits(MAX_FEE, "gwei"),
maxPriorityFeePerGas: ethers.utils.parseUnits(PRIORITY_FEE, "gwei"),
});
console.debug(resp);
const receipt = await provider.waitForTransaction(resp.hash);
console.debug(receipt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment