Hic Et Nunc Smart Contracts (Part 3)
By: Leon Nicholls
Tags: Blockchain, Smart Contracts, Nft, Tezos, Hicetnunc

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:

swap_id — the ID of the swap record in the swaps map of the V2 marketplace contract.

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.

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.

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:

query addressQuery($address: String!) {

hic_et_nunc_holder(where: { address: {_eq: $address}}) {

address

name

hdao_balance

metadata

metadata_file

}

}

The hicdex API returns the following account information:

{

"data": {

"hic_et_nunc_holder": [

{

"address": "tz1XtjZTzEM6EQ3TnUPUQviCD6WfcsZRHXbj",

"name": "NoRulesJustFeels",

"hdao_balance": 2503656,

"metadata": {

"description": "3D Artist."

},

"metadata_file":

"ipfs://QmQH27Cq8UECTZ4gVsu2MsHz5kF6c6onuqxRJ6sdjKiJSK"

}

]

}

}

The metadata_file contains the following:

{

"description": "3D artist",

"identicon":

"ipfs://QmcWXt7x2nZ1AMqWwFhymXP54mZBCzzPmhzTZwoLDmAoxj"

}

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.