This is useful when your admin for your contract has been compromised. For example, when you add balance to your admin address and suddenly your admin balance goes to random address. It is painful to remove your admin address if you don't have a gas to spend to assign a new admin address.
- Do
npx thirdweb create app --node --javascript --evm
- Rename the
.env.example
to.env
- Copy and paste this to your
.env
WALLET_PRIVATE_KEY=
THIRDWEB_SECRET_KEY=
RELAYER_URL=
- After that, fill out the information needed.
- Get the private key of compromised wallet and paste it as a value to
WALLET_PRIVATE_KEY=
- Get the
secret key
from this https://thirdweb.com/create-api-key - Get the
relayer_url
from this tutorial https://blog.thirdweb.com/guides/setup-gasless-transactions - Copy and paste the
index.js
to your localindex.js
- Complete the info in the variables.
const newAdmin = "0x...";
const contractAddress = "0x...";
- Run the code by doing
node index.js
- After the setup, run the script straight.
node index.js
- Comment this part by adding
//
in front of it.
const tx = await contract.roles.grant("admin", newAdmin);
- Then, uncomment this part. By removing the
//
in front of it.
const tx = await contract.owner.set(newAdmin);
- Run again the script.
node index.js