🚨🚨Smart contract expiry and auto renewal are currently disabled. Smart contracts will not be charged auto renewal fees or expire.🚨🚨
Since Hedera's whitepaper, the network has focused on building an economically sustainable and increasingly decentralized network. Transaction fees and storage fees have always been a part of this equation.
In the coming months, Hedera will begin charging renewal fees for smart contracts as denoted on our public roadmap. The renewal fee will be defined by the state size the smart contract keeps.
Smart contract state storage fees, commonly referred to as charging rent, are an oft-discussed topic for layer 1 networks and advocated by Vitalik, Leemon, and others. As part of HIP-16: Entity Auto Renewal and its small update HIP-372: Entity Auto-Renewals and Expiry Window, we’re pushing progress to pioneer smart contract rent.
In this post, we want to help Solidity smart contract developers and the users who interact with them understand how this may impact their design and use of smart contracts.
How does a smart contract pay rent?
There are two ways in which a smart contract on Hedera will be able to pay for its renewal fees.
- Self funded. Renewal fees are paid by the hbar held by the smart contract.
- [Not yet enabled] External funded. Hbars from a defined Hedera account are able to pay a smart contract's renewal fees.
At the time of this writing, and when renewal fees are first switched on, the second option to use funds directly from a Hedera account will not be enabled. We can however deploy our smart contract to have a payable function, more on this later.
What happens if we don’t pay?
As covered in more detail in HIP-16, your smart contract, consistent with all Hedera entities has a status lifecycle from Active to Removed. This lifecycle looks as follows:
All entities can move through these stages. Once your active smart contract reaches its expirationTime the network will attempt to renew the contract by charging it the renewal fee based on the contract’s set autorenewPeriod. This period, per HIP-372 can be set to a max of 8000001 seconds (~92 days) and a minimum of 2592000 seconds (~30 days).
If this auto-renewal attempt fails, the entity turns to expired status and begins its grace period. This is the period in which an entity, our smart contract in this case is disabled, but not yet removed from the ledger and thus able to still be renewed. Although yet to be determined, Hedera will offer a generous grace period to remove some immediate worry. The example offered in HIP-16 is a 30 day grace period.
Once the grace period expires, the network removes the entity, meaning it is permanently removed from the ledger. To get a more complete view of the proposed implementation read HIP-16.
Designing for the long, immutable haul
Most Solidity developers will aim to deploy an immutable, trustless, and composable smart contract. The code is law, as they say. And this code can often be used by other applications or smart contracts without the worry of it being modified or removed from the network.
Charging rent, or having renewal fees for smart contracts presents itself with important considerations as you both code and interact with smart contracts. Factors to consider may be:
- How much human intervention is ok to be relied on?
- Is it acceptable to encourage the community, or perhaps a DAO governing the contracts to fund the contracts via a treasury?
- Is that trust model strong enough or do we need the contract to be fully self-funding without requiring any outside, responsible parties, at all?
The right answer may ultimately depend on your use case. To help, we put together a few basic economic models to consider with Solidity examples.
The simplest. Rely on the community to dedicate hbar to the smart contract on an ongoing basis. This could be facilitated by the creator of the contract, a community of active users, or a DAO treasury account.
In Hedera's current implementation, it is important to add a function to your Solidity file like the transfer below. This will perhaps be less relevant once an external account can pay renewal fees as mentioned above.