Creating Smart Contracts
Last updated
Was this helpful?
Last updated
Was this helpful?
A is an immutable program consisting of a set of logic (state variables, functions, event handlers, etc.) or rules that can be deployed, stored, and accessed on a such as Hedera. The functions contained within a smart contract can update and manage the state of the contract and read data from the deployed contract. They may also create and call other smart contracts functions on the network. Smart contracts are secure, tamper-proof, and transparent, offering a new level of trust and efficiency.
Hedera supports any language that compiles to the Ethereum Mainnet. This includes and . These programming languages compile code and produce that the can interpret and understand.
To learn more about the Solidity programming language, check out the documentation maintained by the Solidity team .
To learn more about Vyper, check out the documentation maintained by the Vyper team .
In addition, many tools are available to write and compile smart contracts, including the popular and . The Remix IDE is a user-friendly platform that allows you to easily write and compile your smart contracts and perform other tasks such as debugging and testing. Using these tools, you can create powerful and secure smart contracts that can be used for various purposes, from simple token transfers to complex financial instruments.
Example
The following is a very simple example of a smart contract written in the Solidity programming language. The smart contract defines the owner
and message
state variables, along with functions like set_message
(which modifies state details by writing) and get_message
(which reads state details).
Automatic Token Associations
This functionality is exclusively accessible when configuring a ContractCreateTransaction
API through the Hedera SDKs. If you are deploying a contract on Hedera using EVM tools such as Hardhat and the Hedera JSON RPC Relay, please note that this property cannot be configured, as EVM tools lack compatibility with Hedera's unique features.
Admin Key
Max Contract Storage Size
Each contract on Hedera has a storage size limit of 16,384,000 key value pairs (~500MB).
Rent
Transaction and Gas Fees
An auto association slot is one or more slots you approve that allow tokens to be sent to your contract without explicit authorization for each token type. If this property is not set, you must associate each token before it is transferred to the contract for the transfer to be successful via the TokenAssociateTransaction
in the SDKs. Learn more about auto-token associations .
Contracts have the option to have an . This concept is native to Hedera contracts and allows the contract account properties to be updated. Note that this does not impact the contract and does not relate to upgradability. If the admin key is not set, you will not be able to update the following Hedera native properties (noted in protobuf) for your contract once it is deployed:
You cannot set the admin key field if you deploy a contract via tools like Hardhat. This field can be set if desired by deploying a contract using one of the Hedera .
While rent is not enabled for contracts deployed on Hedera today, you will want to be familiar with the concept of rent, as it may potentially impact the costs of maintaining your contract state on the network. Please refer to the Smart Contract Rent documentation .
There are Hedera transaction fees and EVM fees associated with deploying a contract. To view the list of base fees, check out the fees page and the fee estimator calculator .
A smart contract is a program that is written in a language that can be interpreted by the EVM. Please refer to the for more keywords and definitions.
Hedera supports the official and therefore any smart contract language that conforms to standard EVM code, such as Solidity or Vyper.
You can use Remix IDE or other Ethereum ecosystem tools to write, compile, and deploy your smart contract on Hedera. Check out our EVM-compatible tools .
On your favorite trusted Block Explorer (also called Mirror Node Explorer on Hedera). To view community-hosted explorers check out the network explorer tools page .
Hedera supports ERC-20 and ERC-721 token standards and can find the full list of supported standards .