What are Smart Contracts in Crypto? (4 Examples)

Have you ever heard of Kickstarter? It’s where when you have an idea, but you don’t have the money, you basically make a page and show off your idea in hopes that other people donate to your project.

For example, I might have an idea for a book that explains cryptocurrency ideas and concepts. Well, I’d create a page and say that I have a goal of getting one thousand dollars in donations.

In turn, for people donating, I’ll give out a book to everyone who donates at least ten dollars. So I run the campaign, and it takes around a week, and I come up with thirteen hundred dollars in donations.

Kickstarter will hold that money for me, and since I reached my goal of one thousand dollars, it’ll give me all of the money that has been donated.

However, if I didn’t reach the one thousand dollar goal because, for example, my grandma didn’t donate or something, then I wouldn’t get anything, and all that money would be returned to the people that granted it.

What Is a Smart Contract?

A smart contract is exactly like this; it’s a piece of code that does something if something else happens.

A lot of people call it if this then that.

The most common smart contracts are written on the Ethereum network using something called solidity. Let’s go over some examples of the purposes of smart contracts. 

You could write a piece of code that says, if you give me five Ethereum, in turn, I will provide you with 20 basic attention tokens. If you have at least 100,000 subscribers by the end of the year, 20 Ethereum will be added to your account.’

If the temperature is over 95 degrees for more than four days in a row this year, farmer john’s account will receive 100,000 as crop insurance.

Now it would be really easy to write a smart contract where people could donate Ethereum to a

specific address, and then if that contract address reached a certain point, maybe say 500 Ethereum, then we could give each donor a portion of online work such as an artistic NFT or access to read an online book or even join a community.

The purposes of smart contracts are endless, but when it comes to smart contracts there are two main things that you need to know that makes them beneficial to everyone:

  • Immutable 

They are immutable. This means they cannot change. You remember how I said some people call them if this than that. It’s because most smart contracts do something when they get triggered.

They are basically just code on the blockchain that gets run, and once it’s on the blockchain, it can never be changed.

Now, the downside of this you might be thinking is that if there is a bug or the code is inefficient, it will be a bug, and it will be inefficient forever.

However, you could just create a new smart contract and tell people not to use the old one if you wanted to. In fact, this happens very often.

  • Distributed 

The second thing you need to know is that they are distributed. This means there are no discrepancies. You can’t hire a lawyer and be like that wasn’t our agreement.

These smart contracts are an agreement between a few parties online that can be automatically executed if certain conditions are met.

Smart contracts are a piece of code designed to remove human error and issues. In fact, you couldn’t hire a lawyer even if you wanted to. The code is on a bunch of computers around the world.

In fact, anyone, if they wanted to, could see your smart contract and how you participated in it.

Now we have financial agreements that nobody can argue because they are code. They don’t change, and everybody has access to them. You might not understand what the power of technology like this is, but to help you get the hang of it, let’s go over some examples:

Flash Loan 

What if I told you that you could borrow 10 million dollars with no money down. Well, on the Ethereum network, you absolutely can, but only if you write a smart contract that pays it back in the exact same minute that it is borrowed.

That’s right; you can borrow millions of dollars to do something for you on the Ethereum network if you know how to code it.

Here’s the catch, all of the money must be paid back, so you may be wondering why we would want to do this.

Well, imagine you could buy some dogecoin for 50 cents on Coinbase and then sell it for 55 cents on Gemini; you could theoretically borrow 10 million dollars and buy a whole bunch of dogecoin on Coinbase and then sell it to Gemini and then pay back the original loan of 10 million dollars with some interest.

This is called a flash loan, and some guy made 360,000 in a few minutes by creating one of these that did pretty much the example that I just described.

Here’s the kicker, the smart contract can check itself. It can simulate what you programmed, and it can see if what you told it to do would actually be able to pay back the lender after it does the code and if it can do that, if it can immediately pay back the lender, it runs the code.

You can borrow those funds to do whatever you want to do.

You could never do this with traditional finance, but you can on the blockchain.

insurance 

Did you know you can create an entire insurance company with just a few smart contracts? We would just write something simple like this; if farmer john gives us two thousand dollars and if it is more than 95 degrees for four days in a row in Missouri, pay farmer john ten thousand dollars.

This is basically insurance farmer john can be sure that if his crops die from a heatwave, the smart contract will know that it happened due to temperature changes and pay him out his 100,000 insurance.

Now, you might be asking how the heck does a smart contract, a piece of code, know what the temperature in Missouri is?

Well, with the help of something called oracles.

Oracles are helpful tools for any smart contract. Essentially they are a trusted source that gives real-world information to anything on the blockchain that requests it.

Now, oracles can get confusing, so we’ll leave those for another article; you just need to know they send real-world data to a smart contract.

Another question you might be wondering is where does the initial one hundred thousand dollars come from?

Well, you’d have to imagine that investors who wanted to start that insurance company would have to pool their money together to be able to front it.

In fact, they would have to lock it up in that smart contract. Whenever farmer john buys it, they cannot do anything with those funds until the end of the summer because, at that moment, the smart contract owns that money.

Then at the end of the summer, if the insurance has not been paid out to farmer john, the initial investment of one hundred thousand dollars plus farmer john’s two thousand dollar premium gets paid back to the investors.

Insurance could be and probably is going to be a very profitable use of smart contracts.

Token Switching

When it comes to smart contracts, one of the most valuable things that you can do is create a pool of money with two different tokens.

You write smart contracts to allow traders to switch out one token for another token, and as one increases in volume, you increase the price of the other token.

This way, you keep steady value in the pool. This is roughly how a decentralized exchange works, and if you’re curious what that is you, can check out our recent post on something called Uniswap. That blog post explains it beautifully.

You can write a smart contract that says if you give me 20 apples, I’ll give you 30 coconuts, except the apples and coconuts are Ethereum and basic attention token. So a smart contract can allow you to switch tokens.

Tokens Switching opens up a whole new world for day traders or investors that want to get into a specific coin that isn’t currently on a major exchange like Binance.

Instead, they could buy a coin that is available and then use the decentralized exchange to swap those tokens.

Lastly, our last example of a useful reason to have a smart contract is to buy a house.

Buying a House

If you haven’t already, you should read our articles on NFTs because you need to understand those and their purpose to get this example.

Imagine you took the house or the apartment that you’re living in, and you took the deed, and you put it on the blockchain. It’s not owned by you anymore or the bank.

In fact, it’s owned by whoever has the deed on the blockchain.

There might be a day where we can use a smart contract to buy and sell a house instead of going through the usual process that takes weeks; you know, advertising the house, securing the funding, using escrow, getting insurance, and the dreaded closing.

You could just send an offer right on the blockchain, and the other person can accept or deny it within minutes.

You immediately own the new deed if they accept, but the other person immediately has your payment. 

This would be very useful for anyone who wants to get into the real estate market but is stopped by the high fees or even banks who wish to have a higher profit margin on their mortgages.

Imagine if you could buy and sell a house as quickly and efficiently as you can buy and sell a stock with blockchain that would be possible.

As I end this article, I hope that you’ve learned something valuable from it and if you have, consider sharing to reward our hard work and possibly subscribing to our newsletter.

Thank you guys so much for reading, and I hope to see you in the next blog post.

We will be happy to hear your thoughts

Leave a reply

Shavuna
Logo