Inheritance errors when creating a governor and governance token contract

I am trying to build a governor contract and a governance token contract. Im getting errors in both of them when i do super._afterTokenTransfer(). it says _afterTokenTransfer not found after argument based lookup. I get the same error with minting function as well. and even though im overriding the functions, its says you are not overriding anything. this is one of the functions, i get the same errors in all of them in which im using super.

function _afterTokenTransfer(address from, address to, uint256 amount) internal override {
        super._afterTokenTransfer(from, to, amount);

        if (to != address(0)) {
            _delegate(to, to);
        }
    }

Can someone please help with this?

You should now override function _update instead, and call super._update instead.

1 Like

That problem is solved. My Governance Token is live but I am now facing issues with my Governor contract. There are 2 issues.

  1. Its telling me that my contract exceeds the limit of 24000 bytes, its 26000+ bytes.
  2. Also when I try to deploy my contract using hardhat, it says Transaction Reverted, function returned an unexpected amount of data. I only have one parameter in the constructor ie the token address. This is my deploy script. Could you please help with this?
const { ethers } = require("hardhat")

async function main() {
  const tokenAddr = "0x5357Eb667E4f55101858b92d42eFcfd8D7D2bc70"
  const [deployer] = await ethers.getSigners()

  console.log("Deploying contracts with the account:", deployer.address)

  const Governor = await ethers.getContractFactory("MyGovernorContract")
  const contract = await Governor.deploy(tokenAddr)

  console.log("Contract deployed at:", contract.address)
}

main().catch((error) => {
  console.error(error)
  process.exitCode = 1
})

Have you enabled optimisations in the compiler settings?

Then you probably want to post the new problem in a new question.