Nano contracts
Nano contracts feature is being progressively rolled out but is still in beta testing, and currently only available on nano-testnet.
Introduction
This article talks about nano contracts. We will cover:
- what nano contracts are;
- how they are created;
- what their advantages are;
- what blueprints are;
- how to develop them;
- why develop one; and finally
- how to use nano contracts.
TL;DR: see section key takeaways.
What are nano contracts?
Nano contracts are a unique feature of Hathor, designed to solve the major problems in the development, use, and widespread adoption of smart contracts technology. Nano contracts are Hathor's approach to smart contracts, and every contract registered on Hathor blockchain is referred to as a nano contract.
In nano contracts, there is a separation between code and state. The code is defined by a blueprint, which acts as a template for contract creation. Then, a contract instance (i.e., a nano contract) stores only its state and a reference to a (single) blueprint.
All contracts instantiated from the same blueprint share the same code, akin to a class and its instantiated objects in object-oriented programming (OOP). This eliminates the need to develop, test, and audit each contract individually. Instead, it is the blueprints that undergo this process, and once available on the network, they can be used by anyone to create an unlimited number of contracts.
Moreover, nano contracts fully leverage Hathor technology:
- By leveraging proof of work (PoW), nano contracts will include a mechanism for MEV protection, ensuring that DeFi users are safeguarded against front running.
- By leveraging built-in custom tokens, nano contracts will offer a flexible fee model, allowing contract execution fees to be paid in non-native tokens, eliminating the need for users to hold HTR (Hathor utility token) in their wallets solely for paying fees.
How are they created?
Stricly speaking, nano contracts are not developed; they are simply created from existing blueprints on the network. To create a new contract, a user selects the blueprint that fits their use case, defines the parameters that model their requirements, and finally submits a transaction to the network containing this information — namely, the blueprint and its parameters. The following diagram depicts the difference between creating a conventional smart contract and a nano contract:

For example, suppose a betting company wants to create a contract that implements a betting option. On other blockchain platforms, the company would need to design, implement (code), test, and audit the smart contract before deploying it on chain.
Conversely, Hathor platform offers a blueprint called bet, specifically designed to model such a use case. As a result, the betting company can create the bet contract without needing to develop its code. Instead, it selects the bet blueprint and defines the values for the parameters required by the blueprint to uniquely specify its use case — e.g., the description of the betting event, the odds, and the possible outcomes that bettors can place bets.
As long as there is a blueprint that fits the use case, the user can create contracts without having to develop code. Blueprint developers do the hard work once; afterward, the blueprint will be available on Hathor platform as a template for contract creation. In the next section, we will better understand what these blueprints are.
What are their advantages?
We can synthesize that nano contracts have four key advantages over conventional smart contracts:
- Affordability
- Usability
- Security
- Scalability
- Efectiveness
Affordability
Nano contracts are more affordable. For developer teams, they optimize the usage of capital and human resources. Some individuals and organizations may lack the money, time, or personnel to develop conventional smart contracts but do have the resources to create nano contracts. This makes blockchain projects accessible to a much broader range of previously overlooked users.
For end users, Hathor's low transaction fees combined with its scalability prevent the incurrence of high gas fees, allowing them to spend less money while using crypto and web3.
Usability
Nano contracts are easier to create and use. For developer teams, creating nano contracts is both practical and convenient. The challenges of contract development — such as code complexity, auditing, and security risks — are all handled by blueprint developers, enabling contract creators to focus solely on the use cases and products they aim to build on the blockchain.
For end users, a flexible fee model allows them to pay gas fees using different tokens, eliminating the need to hold HTR in their wallets solely for paying fees. Additionally, Hathor's official desktop and mobile wallets provide a clear and intuitive interface for directly reading and even executing contracts 1.
Security
Nano contracts are more secure. With conventional smart contracts, it is up to the team to ensure the entire project's security, before deploying it in the blockchain, whereas with nano contracts the project team shares such burden with blueprint developers and Hathor community.
For end users, the mechanism for MEV protection safeguards against economic attacks — e.g., front running — that exploit inherent characteristics of blockchain protocols.
Scalability
Nano contracts are more scalable. On Hathor, the combination of the UTXO model with built-in custom tokens enables a high degree of parallelization in contract execution, especially involving stablecoins and RWAs. This means that on EVM-based blockchain platforms, a transaction involving USDT locks (touches) the entire USDT smart contract, whereas on Hathor, it only locks its own UTXOs.
This is essential for use cases requiring high transaction throughput or a significant number of interrelated transactions, such as in financial markets. For end users, this accelerates trading and reduces slippage.
Efectiveness
Nano contracts are more effective for implementing real-world contracts and financial markets. By ensuring market integrity, nano contracts better meet the compliance and trustworthiness requirements needed to bridge the gap between DeFi and widespread adoption in the broader economy.
The lack of market integrity stems from the possibility of economic attacks, such as front running. These attacks exploit intrinsic characteristics of blockchain protocols, such as the existence of a public mempool and the ability for miners or validators to reorder transactions. For most blockchains, addressing this issue requires implementing solutions that add complexity for both developers and end users. In contrast, Hathor's DAG-based transaction structure enables a solution that is fully transparent to all users.
What are blueprints?
A blueprint is source code present on Hathor platform that is shared among all its instantiated contracts, as a class in object-oriented programming (OOP). Each nano contract has its structure and behavior defined by a single blueprint.
There are two types of blueprints:
- Built-in blueprints
- On-chain blueprints
Built-in blueprints are embedded directly into Hathor full nodes. Hathor platform provides a catalog of blueprints that lists and documents all built-in blueprints. In contrast, on-chain blueprints are deployed on chain by users via transactions.
Even if no existing blueprint fits your use case, it will always be possible to develop new blueprints. In the next subsection, we will explain how this process works.
How to develop them?
Since nano contracts are merely instances of blueprints, "developing nano contracts" actually refers to developing new blueprint(s). Anyone can participate in developing a new blueprint; however, the development processes for built-in and on-chain blueprints are distinct.
Regarding built-in blueprints, their development follows the same process as Hathor protocol; that is, anyone can contribute, the process is supported and coordinated by Hathor Labs, and it requires approval from the entire Hathor Network for deployment.
In turn, on-chain blueprints follow a simpler development process. They can be developed autonomously and deployed independently (via simple user blockchain transaction); that is, anyone can freely deploy an (on-chain) blueprint.
Hathor core provides an SDK for blueprint development. To know how to develop a blueprint, see:
- Develop a blueprint — part 1: hands-on tutorial to assist developers to conceive and design a blueprint.
- Blueprint development — guidelines: main guidelines to consult while developing a blueprint.
- Develop a blueprint — part 2: hands-on tutorial to assist developers to implement and test a blueprint.
- Set up a localnet: for integration testing of blueprints, nano contracts, and DApps.
Once the blueprint is developed, there are two paths for deployment, depending on its type:
- To deploy a built-in blueprint, follow the standard contribution process for Hathor core.
- Currently, the on-chain blueprints feature is still under development and cannot yet be used. Regardless, it is possible to test your blueprint on the public nano-testnet by following the instructions below.
The nano contracts feature (and therefore blueprints) is available on Hathor public nano-testnet and is not yet available on mainnet or primary testnet. To deploy your blueprint on nano-testnet:
- Ensure that you have completed unit and integration testing of your blueprint on a privatenet in your local development environment.
- Add the source code of the blueprint as a single file within
hathor/nanocontracts/blueprints/
, following the same pattern as the existings blueprints. - Open a pull request to the
hathor-core
repository, forking the branchexperimental/nano-testnet-v1.6
.
Why develop them?
Hathor protocol provides direct financial incentives for blueprint developers. The creation and execution of nano contracts require users to pay fees. 30% of these fees are allocated to the developer of the blueprint from which the nano contract was instantiated — i.e., the user who deployed the blueprint on chain.
For example, suppose Alice developed and deployed a blueprint that models auction use cases. Imagine that several auction houses use Alice's blueprint to create DApps. Whenever these auction houses create new nano contracts using Alice's blueprint, she will receive 30% of the fees incurred in this operation. Then, whenever users of these auction houses perform interactions that execute these contracts, Alice will receive 30% of the incurred fees. In summary, whenever Alice's blueprint is used in a nano contract transaction recorded on the blockchain, she will receive 30% of the fees incurred in the operation.
At present, Hathor team is still working on designing the pricing model for nano contracts creation and execution. As such, there is currently no equivalent to the gas table per instruction executed in EVM (namely, opcode and gas costs).
Beyond direct monetization, there are several reasons for independently developing a blueprint:
- Organizations using or planning to use Hathor as their blockchain platform may develop blueprints to create or enhance specific use cases.
- Builders may develop new blueprints to create decentralized applications (DApps) on Hathor platform.
- Community members may want to contribute to the collective effort of enhancing and evolving Hathor technology.
How to use nano contracts?
Nano contracts are supported by the following versions of Hathor official wallet applications:
- Headless v0.29.0
- Desktop v0.30.1
- Mobile v0.30.1
For third-party wallet applications that support Hathor, developers can add support for this feature using Hathor wallet library version 1.14.1 or later.
Key takeaways
- In Hathor, smart contracts are referred to as nano contracts to highlight their unique characteristics.
- The primary distinction between nano contracts and conventional smart contracts is the separation between code and state. The contract's source code is housed in what are called blueprints.
- To create a contract, instead of sending a transaction to deploy the contract code, a user sends a transaction to instantiate a contract by selecting a blueprint already available on Hathor platform.
- Anyone can contribute to the development of new blueprints for Hathor platform.
- Nano contracts offer four key advantages over conventional smart contracts: they are more (1) affordable, (2) easy to use, and (3) secure for both developers and end users; finally, they are more (4) effective at bridging the gap between DeFi and widespread adoption in the broader economy.
What's next?
- How nano contracts work: to understand the conceptual implementation of the nano contracts feature in a use case.
Footnotes
-
Unlike other platforms, end users do not necessarily need to use DApp front ends to interact with contracts. As long as they know the blueprint's API, they can execute contracts directly using Hathor's official wallet application. That said, DApp front ends remain essential for providing a more intuitive user experience and enabling complex operations, such as those involving multiple contracts. ↩