Hic Et Nunc Smart Contracts (Part 3)

In part 2 of this series, I discussed how Hic Et Nunc (HEN) smart contracts are used for swapping and collecting NFTs.

In this third and last part of this series, I will go over the rest of the smart contract features that make HEN work.

Canceling

The GUI for canceling is implemented in hicetnunc/src/pages/objkt-display/tabs/collectors.js using the React JavaScript library.

The GUI code requests funds from a Tezos wallet and swaps the artwork in src/context/HicetnuncContext.js in the cancel method.

There are two main steps for canceling:

  • Request funds from a Tezos wallet to cover the blockchain fees. This request is similar to the process for minting.
  • Transfer the swapped OBJKTs in the HEN escrow wallet back to the owner’s account.

Here is the Python code for the cancel_swap method:

The @sp.entry_point decorator marks the entry point.

The following parameter values are passed to the cancel_swap function by the HEN GUI code:

Note: sp.sender is the address that calls the current entry point.

The code uses the sp.verify command to prevent the entry point from proceeding with the following conditions:

  • The sender and the issuer addresses have to match. Only the address that swapped the OBJKTs can cancel the swaps.

The code calls fa2_transfer, which uses sp.contract to reference the transfer entry point of the NFT token smart contract. The sp.transfer command invokes the transfer entry point with the parameter values. The FA2 code for the transfer entry point uses the maps in the storage of the NFT token smart contract:

  • Confirms that the calling contract is an operator for the OBJKT by querying the operators map.
  • Updates the ledger map to transfer the swapped number of editions from the V2 marketplace contract wallet to the sender’s account.

The swaps map removes all data associated with the swap_id.

Burning

The GUI for burning is implemented in hicetnunc/src/pages/objkt-display/tabs/burn.js using the React JavaScript library.

The GUI code requests funds from a Tezos wallet and swaps the artwork in src/context/HicetnuncContext.js in the burn method.

There are two main steps for burning:

  • Request funds from a Tezos wallet to cover the blockchain fees. This request is similar to the process for minting.
  • Burn by transferring the OBJKTs to the HEN burn address.

Note: Burning OBJKTs does not remove the associated files stored on IPFS even if no editions sell.

The GUI code directly calls the SmartPy FA2 transfer entry point of the NFT token smart contract. The FA2 code for the transfer entry point uses the maps in the storage of the NFT token smart contract:

  • Confirms that the calling contract is an operator for the OBJKT by querying the operators map.
  • Updates the ledger map to transfer 1 edition from the artist’s account to the HEN burn account.

Reselling

The GUI for reselling is implemented in hicetnunc/src/pages/objkt-display/tabs/collectors.js using the React JavaScript library.

Reselling is similar to swapping, with the difference that the OBJKTs transfer from the collector’s wallet to the HEN escrow wallet.

Editing the user profile

The GUI for editing a HEN account profile is implemented in hicetnunc/src/pages/config/index.js using the React JavaScript library.

HEN allows the configuration of the account username, description, and icon image on its site. You can use Tezos Profiles to customize the Twitter link.

The advantage of using the HEN profile is that it’s easier for new users to onboard without having to pay the Tezos Profiles transaction costs 0.3 tez and it eliminates the need to provide personal information such as an email to create a profile.

When the settings page is loaded, the code reads the current account profile information using the hicdex API with the following GraphQL query:

The hicdex API returns the following account information:

The metadata_file contains the following:

When the user presses the Save Profile button, the code updates the icon image and description for the account.

If the user changed the icon image on the web page, the new icon image file uploads to IPFS, similar to the code for minting.

The metadata file containing the description and identicon CID values then uploads to IPFS.

The GUI code requests funds from a Tezos wallet and updates the account information in src/context/HicetnuncContext.js in the registry method.

There are two main steps for these updates:

  • Request funds from a Tezos wallet to cover the blockchain fees. This request is similar to the process for minting.
  • Invoke the registry entry point of the Hic et Nunc Name Registry smart contract using the username and CID of the metadata file as parameters.

Since the code for this smart contract isn’t on Github, we don’t know the exact logic for updating the storage, but the contract has several maps that track the account information.

Note: The hDAO Curation field can be ignored for now. It’s used for adjusting the amount of hDAO you give every time you curate, which isn’t a commonly used feature.

Conclusion

HEN provides a unique opportunity to study the internal workings of an NFT marketplace. Due to its experimental nature, new smart contract features and capabilities are being explored, including:

  • The possible use of proxies to ease updates to the smart contracts.
  • Support for collaborative OBJKTs created by multiple artists.
  • Porting the ERC-1155 smart contract implementation.

There are also interesting Tezos Improvement Proposals (TZIPs) to keep an eye on, especially TZIP-018 for the requirements of upgradeable contracts.

If you stumbled on this story, start reading the 3 part series in part 1. You can follow my 3D art on HEN.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store