How to upgrade the codebase w/ the update of Namewrapper?

Background

It’s tedious to upgrade the code when the smart contract is updated. So here are the steps one can follow when updating the code base. (Hopefully, this pain can be gone later)

Step 0: Check for updates:

Always go to this thread to check jefflau.eth’s post about the update of namewrapper.

As of today (Mar 19), the latest namewrapper address is 0x114D4603199df73e7D157787f8778E21fCd13066.

Step 1: Redeployed our contracts

Our contracts constructor is based on the namewrapper contract address. As a result, we need to first redeploy our contracts.

Take m3mber as an example, let’s go to:

./contracts/scripts/deploy.js

we need to first change LATEST_ADDRESS to the latest namewrapper address:

    const subdomain_reg = await NaiveSubdomainRegistrar.deploy(LATEST_ADDRESS);

Then cd .. i.e. go to ./contracts then type in terminal

$> npx hardhat compile
$> npx hardhat run scripts/deploy.js --network goerli
Contract deployed to address: CONTRACT_DEPLOYMENT_ADDRESS
$> npx hardhat verify --network goerli CONTRACT_DEPLOYMENT_ADDRESS

Note CONTRACT_DEPLOYMENT_ADDRESS is the real address that our contract has been deployed to.

Verify the deployment on https://goerli.etherscan.io/address/CONTRACT_DEPLOYMENT_ADDRESS Keep a record of it so it will be used in step two.

Pro tip: if it’s deployed & verify successfully, there should be a little check mark on contract

Step 2: Update the ABI files

To correctly call the smart contract, we not only need the smart contract's address, but we also need its ABI.

Our ABI files are all saved in a directory. Go to m3mber/lib and see all the ABI json files in it. For our current update, you need to update the ABI file of

  1. m3mber-registrar-abi-goerli.json

    1. This address is the address of the contract that you deployed in step 1
  2. ens-resolver-abi-goerli.json

    1. You need to look up the right contract address step 0
  3. namewrapper-abi-goerli.json

    1. You need to look up the right contract address step 0

To access a contract’s latest ABI, go to https://goerli.etherscan.io/address/ADDRESS then click the contract tab, scroll all the way down, and you will see:

Click the copy button - then you get the ABI of that address, then paste it to the correspondent file.

Step 3: Update constants.tsx

Go to lib/constants.tsx and update

export const M3mberRegistrarAddrGoerli = LATEST_ADDRESS_DEPLOYED_ON_STEP_1
export const namewrapperAddrGoerli = LATEST_ADDRESS_ON_STEP_0
export const ensResolverGoerli = LATEST_ADDRESS_ON_STEP_0 

🎉 Yay you are done! You just finished the step of upgrading the files~

Subscribe to julieshi.eth
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.