Non-Fungible Tokens (NFT) are the unique representation of an item: images, videos, artworks, everything can be reduced to an NFT token.
The usual implementation is in Solidity, through the ERC721 standard. It is just an interface for a contract that gets deployed in the Ethereum blockchain, with suitable implementations.
The use of Java, for programming smart contracts in Takamaka, allowed us to code the NFT contract in Java and run it inside the Hotmoka blockchain. You can see the code here:
It is just a translation from Solidity into Java of the well known implementation by the OpenZeppelin community. By using Java, the code is strongly-typed (forget the address type…), simpler to read and comes with an efficient and simple snapshot operation: you can create a frozen view of the token ledger by simply calling its snaphot() method.
Here is the UML representation of our implementation:
As a bonus, our implementation in Java defines the IERC721Receiver interface for token holders. Holders that implement that interface will be notified upon token receipt. This is fully type-safe: holders cannot pretend to implement that interface, as it is possible in Solidity instead, and there is no need to prove that that method was implemented, as Solidity does instead by returning a special value from that method. Needless to say, simplicity means reliability and smaller gas costs.