Hello I would like to create an ERC777 token which cannot be divided.

I understand that, because decimals() have to remain 18, I have to override the granularity() to 10^18.

What I don't understand is, that the ERC777 implementation does never check if I send multiples of the granularity().


Returns the smallest part of the token that is not divisible. This means all token operations (creation, movement and destruction) must have amounts that are a multiple of this number.

To my understanding I have to mint 10^18 token to get one and to send 1 token I have to send 10^18. But the ERC777 contract does not check if I send less than the granularity.

I think I'm getting something wrong here.


I think that you are referring to the Open Zeppelin implementation of the ERC777 contract. As you say, it doesn't check for granularity in their implementation because the default granularity is 1. If you see the code commented in https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC777/ERC777.sol you'll see that they mentioned this

 * Additionally, the {IERC777-granularity} value is hard-coded to `1`, meaning that there
 * are no special restrictions in the amount of tokens that created, moved, or
 * destroyed. This makes integration with ERC20 applications seamless.

So you have to inherit the ERC777 contract and implement it yourself. Something like this https://github.com/OpenZeppelin/openzeppelin-contracts/pull/1684/files/65257d51d77f42f66ad852c674aa43b7be519032

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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