Know About Smart Contracts In Crypto With Examples

Smart Contracts Crypto

Crypto Rishi

2 months ago|7 min read


Write an image caption

Have you ever heard of Kickstarter its where you go, when you have an idea, but you don’t have the money, you 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’s 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 donated it.

1. Smart Contract

A smart contract is exactly like this. It’s a piece of code that does something. The most common smart contracts are written on the Ethereum network using something called Solidity, so 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 give you 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 and 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 certain 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.

2. Coded on Blockchain

That makes them beneficial to everyone; number one they are immutable. This means they cannot change. So 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 just coded 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, if you wanted to, you could just create a new smart contract and tell people not to use the old one. This happens very often. 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”.

3. Execution of Contract

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. You couldn’t hire a lawyer, even if you wanted to. The code is on a bunch of computers around the world. Anyone they wanted to could see your smart contract and how you participated in it. So now we have financial agreements that nobody can argue because they are code, they don’t change and everybody has access to them. Now you might not understand what the power of technology like this is, but to help you get the hang of it.

4. Examples

Let’s go over some examples, number one is a 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 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 so, here’s the catch, all of the money must be paid back. So you may be wondering why would we 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 payback 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.

5. Advantages of Smart Contract

Here’s the kicker, The smart contract can check itself, it can run a simulation of what you programmed and it can see if what you told it to do would 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 and 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 next up we have number two which is 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?

6. Oracles

If farmer john gives us two thousand dollars and if it is more than 95 degrees for four days in a row in Missouri, farmer John would be paid ten thousand dollars, so this is called 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 a smart contract or a piece of code knows what the temperature in Missouri is well with the help of something called Oracles.

7. Importance of Oracles

So 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, You just need to know they send real-world data to a smart contract.

Now 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. 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. Now insurance could be and probably is going to be a very profitable use of smart contracts number three, we have token switching.

8. Different Tokens

So when it comes to smart contracts, one of the most useful 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.

9. Exchange

This way you keep steady value in the pool. This is roughly how a decentralized exchange works and, if you’re curious, about what that is, you can check out something called Uniswap. 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. Token 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 Coinbase. Instead, they could buy a coin that is available and then use the decentralized exchange to swap those tokens. And lastly, our last example of a useful reason to have a smart contract is to buy a house.

10. Blockchain

So 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. It’s owned by whoever has the deed on the Blockchain.

There might be a day when 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 within minutes the other person can accept or deny if they accept you immediately, they own the new deed, but the other person Immediately has your payment now, this would be very useful for anyone wanting to get into the real estate market, but are stopped by the high fees or even banks who want to have a higher profit margin on their mortgages. Imagine if you could buy and sell a house as quickly and easily as you can buy and sell a stock with Blockchain that would be possible.

So as we end this article, we hope that you’ve learned something valuable from it. Thank you guys so much for reading.


Crypto Rishi

Hi, I am an anonymous crypto guy. I am trying to exchange knowledge and build a community around crypto and blockchain. Find all the informational content about crypto and blockchain on my Feeding Trends blog here. If you like the content follow me to get a regular updates.



Read More