Introduction to Solidity smart contracts | Hedera Hedera Network Services Token Service Mint and configure tokens and accounts. Consensus Service Verifiable timestamps and ordering of events. Smart Contracts Run Solidity smart contracts. HBAR The Hedera network's native cryptocurrency. Insights How It Works Learn about Hedera from end to end. Explorers View live and historical data on Hedera. Dashboards Analyze network activity and metrics. Network Nodes Understand networks and node types. Devs Start Building Get Started Learn core concepts and build the future. Documentation Review the API and build using your favorite language. Developer Resources Integrations Plugins and microservices for Hedera. Fee Estimator Understand and estimate transaction costs. Open Source Hedera is committed to open, transparent code. Learning Center Learn about web3 and blockchain technologies. Grants Grants & accelerators for your project. Bounties Find bugs. Submit a report. Earn rewards. Ecosystem ECOSYSTEM Hedera Ecosystem Applications, developer tools, network explorers, and more. NFT Ecosystem Metrics Analyze on-chain and market NFT ecosystem metrics. CATEGORIES Web3 Applications Connect into the innovative startups decentralizing the web on Hedera. Enterprise Applications Learn about the Fortune 500 companies decentralizing the web on Hedera. Wallets & Custodians Create a Hedera account to manage HBAR, fungible tokens, and NFTs. Network Explorers Hedera mainnet and testnet graphical network explorers. Developer Tooling Third-party APIs, integrations, and plugins to build apps on Hedera. Grants & Accelerators Boost your project with support from the Hedera ecosystem. Partner Program Explore our partners to bring your vision into reality. Hedera Council Over 30 highly diversified organizations govern Hedera. Use Cases Hedera Solutions Asset Tokenization Studio Open source toolkit for tokenizing assets securely. Stablecoin Studio All-in-one toolkit for stablecoin solutions. Hedera Guardian Auditable carbon markets and traceability. Functional Use Cases Data Integrity & AI Reliable, secure, and ethically governed insights. Sustainability Enabling fair carbon markets with trust. Real-World Asset Tokenization Seamless tokenization of real-world assets and digital at scale. Consumer Engagement & Loyalty Mint, distribute, and redeem loyalty rewards. Decentralized Identity Maintain the lifecycle of credentials. Decentralized Logs Scalable, real-time timestamped events. DeFi Dapps built for the next-generation of finance. NFTs Low, fixed fees. Immutable royalties. Payments Scalable, real-time, and affordable crypto-payments. HBAR Overview Learn about Hedera's token, HBAR. Treasury Management Hedera’s report of the HBAR supply. Governance Decentralized Governance Hedera Council See the world's leading organizations that own Hedera. About Meet Hedera's Board of Directors and team. Journey Watch Hedera's journey to build an empowered digital future for all. Transparent Governance Public Policy Hedera's mission is to inform policy and regulation that impact the industry. Meeting Minutes Immutably recorded on Hedera. Roadmap Follow Hedera's roadmap in its journey to build the future. Resources Company What's New Partners Papers Careers Media Blog Technical Press Podcast Community Events Meetups Store Brand Navigation QUICKSTART Introduction to Solidity smart contracts technical Jan 20, 2022 by Waylon Jepsen Developer Evangelist If you have dabbled in web3, you have likely heard about the programing language Solidity. Solidity is the world's most popular way to write smart contracts which are then compiled and deployed to the Ethereum Virtual Machine (EVM). After these programs are deployed, they exist on-chain and can be interacted with by anyone. These contracts make up decentralized exchanges, NFT projects, lending protocols, and a plethora of other decentralized applications.  With Hedera’s testnet update today, we’re able to begin using 'smart contracts 2.0', the EVM compatible Hedera Smart Contract Service for building scalable decentralized applications. If you’re starting out, here is an overview and some helpful resources to jumpstart your journey. If you want to dive in headfirst and get hands-on, check out our deploying your first smart contract tutorial. Ethereum Virtual Machine (EVM) The EVM is a distributed computing environment that executes smart contract logic. It is a virtual machine, an abstraction between executing code and hardware. The EVM executes smart contract logic by compiling the smart contract down to a set of opcodes. Opcodes are low-level instruction sets used by computers to perform basic operations that make up the functionality of computers. If you are curious about the EVM's opcodes check out this full list of them and what they do or get an idea of the Hedera supported opcodes. This is what is happening under the hood when someone is interacting with a smart contract. While the EVM did come out of the Ethereum ecosystem it also runs on a variety of other protocols including Hedera. Hedera uses the open-source Hyperledger Besu EVM. Regardless of the implementation, the demand for distributed computing environments is high. And the demand for developers who can write smart contracts is even higher. The most popular and widely used is solidity, so let's get into it. Development Frameworks When writing a smart contract, you likely want to be able to run tests, deploy to testnets, and make sure things are working before you deploy your contract to the mainnet. This is why almost everyone uses a development framework when writing or programmatically interacting with smart contracts. These frameworks provide us with tools to test, deploy, and interact with smart contracts in a variety of languages. One of the most popular frameworks is HardHat, a JavaScript framework. Others include Brownie (Python) and Foundry (Rust). Foundry is neat because it also supports fuzzing tests with your contracts; a great way to look for security vulnerabilities and anomaly behavior. To start writing the smart contract, pick a development framework that works for you and learn its available tools. Gas When smart contracts are executed, a fee must be paid to the network consensus nodes to execute transactions. The computational unit of measurement used to denote this is called gas. In Ethereum, the price of gas depends on the congestion of the network. This is subject to change in Eth2 and varies depending on the network. Be sure to learn about how the network you are building on determines its gas price. Solidity Contracts All Solidity contract files end in a .sol extension and have a line at the top that specifies what version of solidity they are to be compiled with. For example the line pragma solidity >=0.4.16 <0.9.0; is telling the compiler this contract is written for version 0.4.16 up to but not including version 0.9.0. After the compiler version is specified each contract starts with the contract keyword followed by the name of your contract and an opening and closing curly brace. It has become common practice to have the contract names be camel case. All the logic of the contract will reside within the curly brace. pragma solidity >=0.4.16 <0.9.0;  contract MyContract { # Logic goes here } Copy State Variables State variables are variables that the contract keeps track of internally and change over time as calls are made to the contract. The modification of state variables requires computation and will thus require a transaction fee denominated in gas. Types Solidity is a typed language and includes a variety of built-in data types for our convenience. Some important ones to note are the address type used to specify wallet addresses, the uint32 used to denote unsigned integers of 32 bytes, a boolean bool, and the familiar string data type. There are more included types and if curious I would look at the documentation for a more complete set of the data types included in solidity. public, public view and public payable Functions in solidity are specified by the function keyword and then the function's name. Parts can be specified to have some additional properties in solidity. For example, with the view keyword, the function can just return the information without modifying any state variables. This is nice because it doesn't use any computation and thus doesn't cost anything. An example would be a getter function that looks like this. function get() public view returns(uint32) A function with the public keyword is available for anyone on-chain to call, public view means anyone can call it and it will return some value to be viewed usually public view functions are followed by the returns keyword with the type of the value to be returned. An example of a simple contract with a setter and getter would look like this. pragma solidity >=0.7.0 <0.8.9; contract MyContract { // the message we're storing string message; function set_message(string memory message_) public { // only allow the owner to update the message if (msg.sender != owner) return; message = message_; }  // return a string function get_message() public view returns (string memory) { return message; } } Copy Furthermore, if a function deals with transferring erc20 or erc721 digital assets, the payable keyword is used in the function declaration. Note that the payable keyword only applies to tokens in the ERC standards. If you prefer to transfer a different type of digital asset like a Hedera Token Service minted token, you don't have to use this payable keyword. Additional Resources Solidity is a rapidly evolving ecosystem and growing developer community that we're excited to support. To continue your learning here are a few more recommendations: Foundry Guide Brownie Guide HardHat Guide Solidity By Example Solidity Documentation How does the EVM work? Once you're ready to code, create a Hedera testnet account and follow our getting started with smart contracts tutorial.  Share This Back to blog What is gRPC, gRPC-Web, and Proxies? Ed Marquez Pragmatic Blockchain Design Patterns – Integrating Blockchain into Business Processes Michiel Mulders Zero Cost EthereumTransaction on Success: Hedera's New Fee Model for Relay Operators Oliver Thorn Hedera Adopts Chainlink Standard for Cross-Chain Interoperability To Accelerate Ecosystem Adoption Hedera Team Hedera Developer Highlights March 2025 Michiel Mulders Hedera Release Cycle Overview Ed Marquez View All Posts Sign up for the newsletter CONNECT WITH US Transparency Open Source Audits & Standards Sustainability Commitment Carbon Offsets Governance Hedera Council Public Policy Treasury Management Meeting Minutes LLC Agreement Node Requirements Community Events Meetups HBAR Telegram Developer Discord Twitter Community Support FAQ Network Status Developer Discord StackOverflow Brand Brand Guidelines Built on Hedera Logo Hedera Store About Team Partners Journey Roadmap Careers Contact General Inquiry Public Relations © 2018-2025 Hedera Hashgraph, LLC. All trademarks and company names are the property of their respective owners. All rights in the Deutsche Telekom mark are protected by Deutsche Telekom AG. All rights reserved. Hedera uses the third party marks with permission. Terms of Use  |  Privacy Policy