3

So in the ERC720 contract there is a _transfer function which is calling a hook named _beforeTokenTransfer().

As we see in the image _beforeTokenTransfer is called and I understand it may be calling the function to check something before doing the transfer. That's fine but when i navigate to the _beforeTokenTransfer function it has no logic inside it. It just accepts the same arguments _transfer accepts then what is the use of adding it?

Pic of the _tranfer Function

As I described before, let me show you the _beforeTokenTransfer function as well.

Pic of the _beforeTokenTransfer

As you see in this pic, there is no logic inside the function, I was thinking that hooks are used because it is going to add some extra functionality to the current function like checking some conditions before deploying. But this function is just accepting the same argument?

Please can someone explain me this?

1 Answer 1

5

Basically, it is a function for you to override; You can insert some checks here before the main execution code.

Or simply leave it as it is, it won't cost gas.

To read more about hook:

https://docs.openzeppelin.com/contracts/3.x/extending-contracts#using-hooks

1
  • Ohhh, so basically they have added these hooks to allow the users to add additional Checks if we want to. I got it now, Thanks a Lot Wuzhong. Mar 24 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.