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)
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
.
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
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
m3mber-registrar-abi-goerli.json
ens-resolver-abi-goerli.json
namewrapper-abi-goerli.json
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.
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~