DeFi

·

January 23, 2024

What is a smart contract?

Jack Filiba

As the building blocks for DeFi, smart contracts are programs which let crypto transactions to execute based on specific conditions, without the need for a third party mediator.

Smart contracts are the backbone of DeFi. They allow virtually any two people or entities to exchange value without the need for a centralized middleman.

Thanks to smart contracts, we’ve seen the birth of a multibillion-dollar industry centered around decentralized technology and finance. 

Here’s a simple explanation with everything you need to know about smart contracts and how they work.

Smart contracts revolutionize how people exchange value

At their core, smart contracts are just programs. They are pieces of software that are programmed to execute a specific function once set criteria are met.

Using a smart contract to secure funds in a multisignature wallet.
Multisignature wallets are just one of many applications of smart contracts.

What makes smart contracts revolutionary is that they allow virtually any two people or entities to trade value without relying on a third party, making them essential to web3 activities like swapping crypto.

In comparison, when it comes to traditional contracts, the contract itself is typically facilitated by lawyers. It is then up to our court systems to enforce the terms of the agreement. Here, an exchange of value is actioned thanks to third-party intermediaries.

Smart contracts, on the other hand, trim the fat by executing automatically.

Consider the following example:

If you wanted to take out a decentralized loan, you could do so through a smart contract. This would work by locking up your existing assets as collateral in exchange for tokens that are given to you by the protocol. 

Your tokens are returned to you when you send the loaned tokens back plus any interest, per the terms of the smart contract. Since you are locking in an asset as a guarantee, you are able to take a loan out directly from the smart contract without the need for a middleman.

Of course, smart contracts are about much more than lending. But despite being a small-scale example, this illustrates how individual smart contracts operate.

When it comes to the broader world of DeFi, understanding smart contracts allows us to demystify the landscape and view it more simply as a network made up of many automated agreements.

Smart contracts are enforced promises

While smart contracts are most often associated with cryptocurrencies and NFTs, the term is more broadly used today to describe how most decentralized systems operate.

The concept of a smart contract predates the crypto movement. While the first widespread cryptocurrency launched in 2009, smart contracts were first proposed in 1994 by Nick Szabo.

Widely considered one of the forefathers of the DeFi movement, Szabo’s whitepaper, Smart Contracts: Building Blocks for Digital Markets, has itself served as a building block of the modern decentralized landscape.

In Szabo’s words, smart contracts are:

“A set of promises, specified in digital form, including protocols within which the parties perform on these promises."

Smart contracts did not become a key driving force in crypto until the launch of Ethereum. In fact, the original Ethereum whitepaper refers to enabling smart contracts as one of the core reasons for the platform’s existence.

Ethereum’s documentation also makes reference to a more digestible explanation offered by Szabo, who famously compared smart contracts to vending machines.

If we think of a vending machine through this lens, we can understand it as being a pre-programmed agreement like a smart contract. Here, someone puts coins in a machine, selects a snack, and a snack is dispensed. 

In this example, the “promise” of a tasty snack in exchange for money is automatically enforced by the machine itself. But unlike vending machines, smart contracts have limitless potential and - importantly - won’t jam right before your Doritos are dispensed.

Smart contracts reduce counterparty risk in DeFi

The reason why smart contracts are vital in the first place has to do with counterparty risk.

For better or worse, the current world of traditional finance exists because of third party intermediaries. When you buy goods or services using your card, for instance, payment networks and banks confirm that you have enough money and communicate this information to the merchant.

Smart contracts used in an NFT exchange auction
Smart contracts power decentralized exchanges.

Without a payment network in this scenario, the merchant would essentially have little way of knowing if they would actually receive the funds you agreed on.

In this instance, the counterparty risk - i.e. the risk of the other party in a trade not meeting their obligation - is mitigated by banks.

But since the DeFi movement is all about removing intermediaries, counterparty risk in crypto is instead mitigated by smart contracts.

Thanks to the fact that smart contracts are executed automatically, there is no risk of someone flaking on their obligation. In addition, when deployed on a transparent blockchain, the terms of a smart contract can easily be observed before anyone agrees to them.

Further still, since blockchains are traditionally immutable, smart contracts can never be changed once they are deployed. This means that neither party in a transaction has to worry about the terms of the agreement ever being modified.

Through these features, smart contracts serve as a way for any two people or entities to reach an agreement in a peer-to-peer landscape.

How smart contracts work on DEXs and aggregators

Smart contracts play a vital role in the existence of decentralized exchanges.

While many exchanges are centralized and custodial, these types of exchanges are not an ideal solution for most users. This is because letting someone else hold your coins puts your funds at risk, as they can be stolen.

Decentralized exchanges (DEX), on the other hand, are a way to buy or sell cryptocurrencies while always retaining ownership of your coins.

DEX aggregator Matcha

Since DEXs function without centralized intermediaries, they instead use smart contracts to allow exchanges to take place between peers while still mitigating counterparty risk.

Thinking back to our vending machine example, a decentralized exchange simply accepts and dispenses digital assets in order to let users freely trade.

DEX aggregators, which are platforms that can find the best prices for making decentralized trades, also use smart contracts to allow users to make the same trades at the best prices.

Smart contracts power AMMs and liquidity pools

Another key way that smart contracts are used in the DeFi landscape today is as a means of powering decentralized transactions without relying on the systems used by centralized exchanges.

This is done through Automated Market Makers (AMMs), which employ algorithmic processes to enable constant liquidity in the decentralized landscape. They are able to reduce slippage - the difference between tokens you receive and the amount you were quoted, often caused by thin liquidity - while serving as a replacement for the matching systems used by centralized trading platforms.

Instead of relying on centralized entities or individual users to be making constant around-the-clock trades, AMMs use smart contracts to allow transactions to take place between users and liquidity pools.

Functionally, liquidity pools are also a type of smart contract. They store value - just like a vending machine - where funds can be sent or withdrawn. The liquidity within these pools is typically provided by users, who receive financial incentives for contributing to the health and liquidity of a network.

Smart contracts enable wrapped tokens and blockchain bridges

For a long time, a key challenge in DeFi was figuring out how to let individual blockchains interact. This is yet another area in which the industry has greatly benefitted from the use of smart contracts.

Smart contracts allow users to send tokens from one network to another through blockchain bridges and wrapped tokens - or cross chain swaps, which bundle these processes into one trade.

If you hold bitcoin (BTC) but wanted to use a dApp on Ethereum, for example, you could lock your bitcoin in a smart contract. This smart contract could then issue you with a bridged or wrapped version of that token, which ‘represents’ your BTC while being Ethereum-compatible.

However, as we explained in greater depth in our recent article, bridged tokens should not be treated like native cryptocurrencies; they are often centralized and have key limitations and vulnerabilities.

Fortunately, another way that smart contracts can be used to allow you to transact between different networks is through tools like Matcha.

Matcha lets you make cross-chain swaps through APIs which leverage smart contracts to let you buy and sell assets across a range of different blockchain networks. The result is a process that is easy to use, mitigates counterparty risk and slippage, and offers a great price.

If you’re looking to take advantage of more than one blockchain, try Matcha today! 

Contents
Subscribe to our newsletter
By submitting you're confirming that you agree with our Terms and Conditions.
Yay! You’re signed up.
Oops! Something went wrong, but it's not your fault.
DeFi

·

December 14, 2023

What is a smart contract?

What is a smart contract

As the building blocks for DeFi, smart contracts are programs which let crypto transactions to execute based on specific conditions, without the need for a third party mediator.

Smart contracts are the backbone of DeFi. They allow virtually any two people or entities to exchange value without the need for a centralized middleman.

Thanks to smart contracts, we’ve seen the birth of a multibillion-dollar industry centered around decentralized technology and finance. 

Here’s a simple explanation with everything you need to know about smart contracts and how they work.

Smart contracts revolutionize how people exchange value

At their core, smart contracts are just programs. They are pieces of software that are programmed to execute a specific function once set criteria are met.

Using a smart contract to secure funds in a multisignature wallet.
Multisignature wallets are just one of many applications of smart contracts.

What makes smart contracts revolutionary is that they allow virtually any two people or entities to trade value without relying on a third party, making them essential to web3 activities like swapping crypto.

In comparison, when it comes to traditional contracts, the contract itself is typically facilitated by lawyers. It is then up to our court systems to enforce the terms of the agreement. Here, an exchange of value is actioned thanks to third-party intermediaries.

Smart contracts, on the other hand, trim the fat by executing automatically.

Consider the following example:

If you wanted to take out a decentralized loan, you could do so through a smart contract. This would work by locking up your existing assets as collateral in exchange for tokens that are given to you by the protocol. 

Your tokens are returned to you when you send the loaned tokens back plus any interest, per the terms of the smart contract. Since you are locking in an asset as a guarantee, you are able to take a loan out directly from the smart contract without the need for a middleman.

Of course, smart contracts are about much more than lending. But despite being a small-scale example, this illustrates how individual smart contracts operate.

When it comes to the broader world of DeFi, understanding smart contracts allows us to demystify the landscape and view it more simply as a network made up of many automated agreements.

Smart contracts are enforced promises

While smart contracts are most often associated with cryptocurrencies and NFTs, the term is more broadly used today to describe how most decentralized systems operate.

The concept of a smart contract predates the crypto movement. While the first widespread cryptocurrency launched in 2009, smart contracts were first proposed in 1994 by Nick Szabo.

Widely considered one of the forefathers of the DeFi movement, Szabo’s whitepaper, Smart Contracts: Building Blocks for Digital Markets, has itself served as a building block of the modern decentralized landscape.

In Szabo’s words, smart contracts are:

“A set of promises, specified in digital form, including protocols within which the parties perform on these promises."

Smart contracts did not become a key driving force in crypto until the launch of Ethereum. In fact, the original Ethereum whitepaper refers to enabling smart contracts as one of the core reasons for the platform’s existence.

Ethereum’s documentation also makes reference to a more digestible explanation offered by Szabo, who famously compared smart contracts to vending machines.

If we think of a vending machine through this lens, we can understand it as being a pre-programmed agreement like a smart contract. Here, someone puts coins in a machine, selects a snack, and a snack is dispensed. 

In this example, the “promise” of a tasty snack in exchange for money is automatically enforced by the machine itself. But unlike vending machines, smart contracts have limitless potential and - importantly - won’t jam right before your Doritos are dispensed.

Smart contracts reduce counterparty risk in DeFi

The reason why smart contracts are vital in the first place has to do with counterparty risk.

For better or worse, the current world of traditional finance exists because of third party intermediaries. When you buy goods or services using your card, for instance, payment networks and banks confirm that you have enough money and communicate this information to the merchant.

Smart contracts used in an NFT exchange auction
Smart contracts power decentralized exchanges.

Without a payment network in this scenario, the merchant would essentially have little way of knowing if they would actually receive the funds you agreed on.

In this instance, the counterparty risk - i.e. the risk of the other party in a trade not meeting their obligation - is mitigated by banks.

But since the DeFi movement is all about removing intermediaries, counterparty risk in crypto is instead mitigated by smart contracts.

Thanks to the fact that smart contracts are executed automatically, there is no risk of someone flaking on their obligation. In addition, when deployed on a transparent blockchain, the terms of a smart contract can easily be observed before anyone agrees to them.

Further still, since blockchains are traditionally immutable, smart contracts can never be changed once they are deployed. This means that neither party in a transaction has to worry about the terms of the agreement ever being modified.

Through these features, smart contracts serve as a way for any two people or entities to reach an agreement in a peer-to-peer landscape.

How smart contracts work on DEXs and aggregators

Smart contracts play a vital role in the existence of decentralized exchanges.

While many exchanges are centralized and custodial, these types of exchanges are not an ideal solution for most users. This is because letting someone else hold your coins puts your funds at risk, as they can be stolen.

Decentralized exchanges (DEX), on the other hand, are a way to buy or sell cryptocurrencies while always retaining ownership of your coins.

DEX aggregator Matcha

Since DEXs function without centralized intermediaries, they instead use smart contracts to allow exchanges to take place between peers while still mitigating counterparty risk.

Thinking back to our vending machine example, a decentralized exchange simply accepts and dispenses digital assets in order to let users freely trade.

DEX aggregators, which are platforms that can find the best prices for making decentralized trades, also use smart contracts to allow users to make the same trades at the best prices.

Smart contracts power AMMs and liquidity pools

Another key way that smart contracts are used in the DeFi landscape today is as a means of powering decentralized transactions without relying on the systems used by centralized exchanges.

This is done through Automated Market Makers (AMMs), which employ algorithmic processes to enable constant liquidity in the decentralized landscape. They are able to reduce slippage - the difference between tokens you receive and the amount you were quoted, often caused by thin liquidity - while serving as a replacement for the matching systems used by centralized trading platforms.

Instead of relying on centralized entities or individual users to be making constant around-the-clock trades, AMMs use smart contracts to allow transactions to take place between users and liquidity pools.

Functionally, liquidity pools are also a type of smart contract. They store value - just like a vending machine - where funds can be sent or withdrawn. The liquidity within these pools is typically provided by users, who receive financial incentives for contributing to the health and liquidity of a network.

Smart contracts enable wrapped tokens and blockchain bridges

For a long time, a key challenge in DeFi was figuring out how to let individual blockchains interact. This is yet another area in which the industry has greatly benefitted from the use of smart contracts.

Smart contracts allow users to send tokens from one network to another through blockchain bridges and wrapped tokens - or cross chain swaps, which bundle these processes into one trade.

If you hold bitcoin (BTC) but wanted to use a dApp on Ethereum, for example, you could lock your bitcoin in a smart contract. This smart contract could then issue you with a bridged or wrapped version of that token, which ‘represents’ your BTC while being Ethereum-compatible.

However, as we explained in greater depth in our recent article, bridged tokens should not be treated like native cryptocurrencies; they are often centralized and have key limitations and vulnerabilities.

Fortunately, another way that smart contracts can be used to allow you to transact between different networks is through tools like Matcha.

Matcha lets you make cross-chain swaps through APIs which leverage smart contracts to let you buy and sell assets across a range of different blockchain networks. The result is a process that is easy to use, mitigates counterparty risk and slippage, and offers a great price.

If you’re looking to take advantage of more than one blockchain, try Matcha today! 

Subscribe for an instantly better inbox

By submitting you're confirming that you agree with our Terms and Conditions.
Yay! You’re signed up.
Oops! Something went wrong while submitting the form.