Smart contracts 2.0 now on the Hedera testnet
Jan 20, 2022
by Gehrig Kunz
Product Marketing at Hedera Hashgraph

Smart contracts play a critical role in building the trust layer of the internet. Used to manage autonomous logic that doesn’t rely on a centralized intermediary, server, or custom governance model, smart contracts can power core infrastructure of the future like decentralized finance.

While the Hedera Smart Contract Service is EVM compatible and runs Solidity, with the availability of Smart Contracts 2.0 now on the Hedera testnet it now does so with a few added bonuses as only Hedera and the soon to be open-sourced hashgraph can.

The best of both worlds with Hedera Token Service

Solidity smart contracts on Hedera now support the Hedera Token Service (HTS). This means that as a developer you can choose your own token adventure. Minting an in-app currency for your users? As easy as writing a JavaScript app. Want to programmatically mint an NFT for some cool generative art? Use smart contracts with Hedera Token Service precompile.

This flexibility is unprecedented. As a developer, you can now determine if a smart contract is required for your use case or not and consider the tradeoffs in throughput and cost appropriately. As an ecosystem, we’ll have to work together to better understand user experiences and best practices. We’ve put together a quickstart tutorial to get started with your first smart contract using HTS precompile, but here’s an example of the Solidity file.

Code Snippet Background
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6.12;

import "./HederaTokenService.sol";
import "./HederaResponseCodes.sol";

contract HTS is HederaTokenService {

    function tokenAssociate(address sender, address tokenAddress) external {
        int response = HederaTokenService.associateToken(sender, tokenAddress);

        if (response != HederaResponseCodes.SUCCESS) {
            revert ("Associate Failed");

    function tokenTransfer(address tokenId, address fromAccountId , address toAccountId , int64 tokenAmount) external {
        int response = HederaTokenService.transferToken(tokenId, toAccountId, fromAccountId, tokenAmount);

        if (response != HederaResponseCodes.SUCCESS) {
            revert ("Transfer Failed");

    function tokenDissociate(address sender, address tokenAddress) external {
        int response = HederaTokenService.dissociateToken(sender, tokenAddress);

        if (response != HederaResponseCodes.SUCCESS) {
            revert ("Dissociate Failed");

Low fees, latency, and even lower energy-use

Every Hedera network service has low, predictable fees that are set in USD and paid for in hbars. The efficiency of hashgraph makes this possible and, as to be expected, these fees are still predictable when using smart contracts. Hedera, as an EVM implementation, a Hyperledger Besu EVM one to be precise, does have the notion of gas fees. For those unfamiliar, gas is the cost it takes for the computational resources to use a smart contract.

On other layer-1 networks, gas fees can be highly variable and at times downright unruly.

Variable gas fees on Ethereum
Ethereum hourly gas prices from

On Hedera, gas fees are always predictable. What it takes to perform that smart contract today will be the same at any hour, no more network congestion issues or having to go so far as to create your own device to know when it’s cheaper to deploy a contract (it’s always a $1 to deploy a contract on Hedera).

Next, the performance is fast and scalable. The amount of gas available in an entire block on ethereum, 15 million, is available in a second on Hedera. The transaction is final in seconds. No need to wait for block confirmations or have that internal debate if you should pay a low, medium, or high gas priority fee to speed your transaction up. Stay tuned for more performance results as we go through internal testing. 

And lastly, of course like everything else on Hedera, all smart contract use is carbon negative. Again, the efficiency of hashgraph makes this possible, with Hedera having the lowest energy-use of layer-1 networks with additional carbon offsets made possible through our partner, Terapass

Ready to build

We’re excited to see you try the new Hedera Smart Contract Service and see an emerging smart contract ecosystem spring up around Hedera.  There are some known enhancements already on the roadmap and available as Hedera Improvement Proposals (HIPs), if you have your own suggestions, don't hesitate to submit them. 

According to Electric Capital's web3 developer report, 30% of all web3 developers are working with Solidity and the Ethereum Virtual Machine (EVM). We’re excited to help support the EVM and other layer-1 networks to help that number grow even more. If you’re not familiar yet with solidity, we’ve put together a helpful introduction with some recommended resources. 

From developer tools to DeFi to DAOs we can’t wait to see what gets created. If you’re looking for support to start building or scaling your smart contract project, reach out to the HBAR Foundation.