What Are Smart Contracts in Cryptocurrency?
Many, or all, of the products featured on this page are from our advertising partners who compensate us when you take certain actions on our website or click to take an action on their website. However, this does not influence our evaluations. Our opinions are our own. Here is a list of our partners and here's how we make money.
The investing information provided on this page is for educational purposes only. NerdWallet, Inc. does not offer advisory or brokerage services, nor does it recommend or advise investors to buy or sell particular stocks, securities or other investments.
Smart contracts are important building blocks for products in the cryptocurrency and blockchain space. A smart contract is a way to settle a transaction once a verifiable event, such as a payment, has taken place.
Smart contracts play out in the background of many consumer crypto products, so chances are you’ve used them if you’re doing anything other than buying and holding crypto. Applications of smart contracts include NFTs, decentralized exchanges and stablecoins.
NerdWallet rating 4.8 /5 | NerdWallet rating 4.5 /5 | NerdWallet rating 4.6 /5 |
Fees $0 per online equity trade | Fees $0 per trade | Fees $0 |
Account minimum $0 | Account minimum $0 | Account minimum $0 |
Promotion None no promotion available at this time | Promotion 1 Free Stock after linking your bank account (stock value range $5.00-$200) | Promotion Earn up to $10,000 when you transfer your investment portfolio to Public. |
Which cryptocurrencies support smart contracts?
Smart contracts are a feature of second-generation cryptocurrencies — notably Ethereum, which popularized the concept when it was introduced in 2015. Other examples include Cardano, Solana and Polkadot.
Bitcoin and other earlier cryptocurrency blockchains do not generally support complex smart contracts.
Smart contract example
Because smart contracts tend to operate in the background of the end-user experience, it can be helpful to understand them through an example.
Say you want to trade one kind of cryptocurrency for another, and you find someone who will trade. But you don’t know this person, and you want to make sure that when you send them cryptocurrency, they’ll hold up their end of the deal.
You and your counterpart could make a smart contract that ensures the deal won't happen unless you both get paid. It could work something like this:
You send cryptocurrency to an address associated with the smart contract you’ve created.
The contract’s code checks to see whether you’ve sent the agreed-upon amount.
The code then checks to see whether your counterpart has sent the agreed-upon amount.
Once the code verifies that both of you have paid, it releases the proceeds to each of you.
If both parties have not paid within a certain time frame, all crypto that has been contributed goes back to the original owner.
This is a relatively simple example, though. Decentralized exchanges such as Uniswap and PancakeSwap do similar tasks using more complicated smart contracts.
In theory, smart contracts can automate many steps for which you may need a trusted intermediary. Developers and entrepreneurs have been exploring applications across a variety of sectors, including logistics, insurance, finance and gaming.
Limitations of smart contracts
Any smart contract that runs on a blockchain faces one major limitation: It can rely only on information stored in the records of that blockchain. And cryptocurrency blockchains tend to mostly contain information related to the circulation of that specific cryptocurrency and related assets.
For instance, you could write a smart contract that holds digital assets to be paid to a contractor once she finishes the work on your house. But who decides when the work is “finished?”
Without some way to reliably insert mutually verifiable information about the progress of construction, a smart contract wouldn’t be much help in a dispute over whether the project was done to satisfaction. You’d need a third party to give the computer program a green light to release the funds.
To address this issue, blockchain developers have created a concept known as an “oracle,” which feeds external information into a blockchain system.
In the example of the contractor, say this was an HVAC project. Data from a thermostat or sensor may be able to verify that the work has been completed as described.
Learn how to write a smart contract
Any user of a blockchain network that supports smart contracts can write their own.
You’ll have to know some computer coding skills and be comfortable with blockchain technology. If you do it wrong, you could risk losing your crypto by locking it up irretrievably or sending it to the incorrect place.
If you’re interested in how to write smart contracts, some blockchain projects have test networks where you can carry out trial transactions without sending real money. Various cryptocurrencies have courses and guides that offer help; one place to start is Ethereum.org’s “Learn by Coding” section.
And if you want to see how smart contracts work in the wild, you can look at blockchain explorers such as Etherscan — though you’ll need some serious computer chops to understand what you’re seeing.
The more you learn about smart contracts, the better you’ll be able to evaluate the technology you’re using.
The author owned Ethereum, Bitcoin, Cardano, Solana and Chainlink at the time of publication. The editor owned Bitcoin.
On a similar note...