Smart contracts help you conduct business on the blockchain. And while they have many advantages, smart contracts still come with their own unique set of challenges compared to standard software development.

As you delve deeper into the world of decentralized finance (DeFi), you’ll inevitably run into the term smart contract.  

If you’re going to conduct business and transactions on the blockchain, there’s a good chance you’ll be using a smart contract to guarantee the deal is executed properly. 

In our article we review the basic definition of a smart contract, advantages and disadvantages of the technology, and how they function on popular blockchains like Ethereum.  

What are smart contracts? 

Smart contracts describe computer code stored on a blockchain-based platform

The code automatically executes when a circumstance outlined in the code triggers, either when a function is called or a predetermined event occurs. 

What are examples of smart contracts?

Some examples of popular smart contracts are NFTs such as CryptoKitties, DeFi platforms like Uniswap, and ERC-20 tokens.

What are the advantages of a smart contract?

There are many advantages to smart contracts including: 

  • Permanence. Smart contracts can’t be deleted by default; any interaction with a smart contract is irreversible.
  • No trusted third parties. Smart contracts allow for credible transactions to occur without the requirement of a third party—whom both intermediaries trust—to review the transaction.
  • Public availability. Smart contracts are programs committed to the blockchain; they’re publicly available and verifiable to anyone with access to the chain.
  • Transparency. Anyone with read-access to the blockchain is able to watch the contract activity which makes it fully transparent and auditable. 

What are the disadvantages of smart contracts? 

Smart contracts come with their own unique set of challenges compared to standard software development.

Some of these challenges include: 

  • Permanence 
  • Gas fees
  • Potential security risks

Permanence 

Any smart contract deployed on a blockchain can’t be changed. 

If bugs are found post-deployment, a new smart contract has to be re-deployed to a new contract address. 

While there are some upgrade patterns—such as the proxy pattern—which could help alleviate this issue, they could also cause potential trust and security risks.

Gas fees 

Gas fees could also be called transaction fees; they facilitate cryptocurrency transfers and smart contract executions. Much like vehicles need gas to travel, transactions on a blockchain require fees to compensate miners for validating transactions. The higher the demand for a particular blockchain network, the greater the cost of a gas fee. 

Since all calls in a transaction cost gas to run, the code needs to be as efficient as possible. 

You pay gas when deploying a smart contract as well as when you invoke a function in a contract. 

There are gas limits for deploying contracts, so if your smart contract’s compiled size is too large, you won’t be able to deploy it.

Potential security risks

If your smart contract exists on a public network, anyone can call its functions; this availability poses some severe security risks including: 

  • Reentrancy
  • Integer overflow or underflow
  • Access control

Reentrancy 

Calling an external contract from your contract is dangerous because the external code can take over the control flow and make data changes that the calling function wasn’t expecting. The major DAO attack that led to the fork between Ethereum and Ethereum Classic was due to a reentrancy bug.

Integer overflow or underflow 

If the smart contracting language uses units, like Solidity for Ethereum does, you must protect against arithmetic issues like integer overflow and underflow where the operation tries to create a value outside of the range that can be represented with a given number of digits. For example, a uint8 holds 8 digits. If you attempt to add 1 to the uint8 value 99999999, the number becomes 1, which is probably not the value you were expecting. Note: Solidity automatically protects against integer overflow/underflow in compiler version .8 and above.

Access control 

Although this issue isn’t limited to smart contract development, controlling who’s able to call certain functions is an essential aspect of development on a public blockchain. 

For example, if an initialization function is included in a smart contract, you must be extremely careful with who’s allowed to invoke it. Setting the access permissions for important functions can prevent someone from taking over your contract and gaining access to sensitive functionalities. The Parity Wallet attack happened because of poor access control and resulted in a loss of 513,743 ether (ETH)—worth over $1 billion as of the beginning of 2022.

What is the Ethereum Virtual Machine? 

Ethereum is one of the most popular blockchains that runs smart contracts, and the Ethereum Virtual Machine (EVM) is the environment where all its smart contracts live. 

There are two kinds of accounts in Ethereum which share this space: 

  • External accounts driven by humans and controlled by public-private key pairs 
  • Contract accounts controlled by the code stored together with the account

The address of a contract is determined at the time the contract is created; it’s derived from the creator address and the number of transactions sent from that address, also known as nonce.

How do smart contracts function in EVM? 

A transaction is a message that is sent from one account to another account; it can include binary data, known as the payload, and ETH.

Upon creation, each transaction is charged with a certain amount of gas, whose purpose is to limit the amount of work that is needed to execute the transaction and to pay for this execution at the same time. While the EVM executes the transaction, the gas is gradually depleted according to specific rules.

If some gas is left after the execution, it’s refunded to the creator.

If the gas is used up at any point, an out-of-gas exception is triggered and reverts all modifications made to the contract in the current call frame.

Final thoughts

Smart contracts elevate blockchain technology. Rather than just supporting basic coin movements, smart contracts allow complex transactions to occur on the blockchain. 

Smart contracts are made to reduce friction and eliminate middlemen from transactions and decentralize the control we see in current technological institutions. Their code is guaranteed to run when prompted thus eliminating the need for trusted third-party intermediaries. 

As the Web3 ecosystem grows, more uses for smart contracts will be developed and become more ingrained in our everyday technologies. Headway is being made to bring finance, ticketing, proof of ownership, voting, social media, file storage, and many other common activities to the blockchain.

Other Resources: 

Check out additional articles in our crypto education series: 

About Taxbit 

Keeping up with all the paperwork and reporting regulations for digital asset transactions can be laborious and time-consuming. The more complex your crypto portfolio becomes, the more complicated your tax liabilities can get.

Taxbit helps track your crypto transactions and fills out your tax forms automatically.

We also recognize the need to support your DeFi activity, and each day we’re actively working on expanding DeFi support to popular blockchains.

The initial version of our DeFi support allows you to sync in any transfers, trades, and approvals you’ve made on a DeFi platform involving ERC-20 tokens on the Ethereum network, or BEP-20 tokens on the Binance Smart Chain network.

Ready to try out the updates for yourself? Create an account or login to start.

Sign Up To Newsletter