Guest post: Hello everyone! My name is John Caraballo and I am the Director of Software Engineering here at Covey. Today I am going to talk to you a little about smart contracts and how they relate to the future of Covey. Last week, we released the first smart contract for Covey onto our SKALE ethereum chain. We call it the “Covey Ledger”

Gasp

Covey allows anyone to track, share, and monetize their investing ideas. We believe the Analysts should own this track record and monetize it with as little help from us as possible. Today large firms, like JPM or GS, sit in between Analysts and people who value their ideas (Investors). Our hope is that anyone with a good track record can get paid regardless of where they are from or who they know. Covey doesn’t want to become another gatekeeper, instead we want to open the gates to anyone. To do this, we need smart contracts!

Well first of all, smart contracts, what are they? Smart contracts are programs that run inside the ethereum blockchain and can do all sorts of fancy stuff like running a lottery, paying out winners of the said lottery, and keeping track of winners. The cool part about smart contracts is they cut out the middleman for simple tasks like paying out lottery winners. The newest buzzwords of DAOs are basically code (smart contracts) replacing entire organizations. Covey is a long way from being replaced by smart contracts entirely but we are on that journey.

The Covey Ledger is our second step in giving analysts a trusted track record. It allows anyone to post a string of data that will be stored forever.

It is an upgrade to our prior method of storing trade data in transactions (check out our first time we stored data in a transaction). We needed a simple contract to store a user’s trades in an organized manner and have the ability to know as soon as that trade was placed, what positions were placed.

Wallet graphic

Ok! We’re about to get a little technical here so you know exactly how this works so bear with me. The bread and butter of the Covey Ledger is this:

Contract code block

This is a lot but I will break it down in steps so it makes sense. The first thing we do is define a function called createContent and we pass it a string of arbitrary content, in our case a user’s positions that they placed on Covey. A function is simply a piece of code that we can call however many times we want to execute a given action, we can also pass it arguments to change certain things of how the function behaves internally, this is what the stuff between the parenthesis is. Think of it as a restaurant, you have a menu and a server. You tell them what you want from the menu, for example, a hamburger with just cheese and lettuce(here are your arguments) and you get a hamburger back, MAGIC. And now I’m hungry.

The next step is that we are creating a variable to store a user’s content in the smart contract. The variable simply stores the analyst which is whoever sent this transaction to the smart contract, the content itself which in our case is the positions like GOOGL: 0.1, etc. It’s worth noting that the “content” can be anything as long as it is a string! And finally, we store when this was created for record-keeping purposes.

The third step is storing this piece of data inside a mapping called analystContent (we also have an array of allContent but we’re ignoring that for now). A mapping is a key/value pair where the key is the analyst ethereum address and the content is that variable we created getting stored. Think of it as a box with a label of “toys’’ and inside are the toys. The reason we do this is to organize and have a way to easily look up a user’s trades based on their ethereum address which is exactly what we wanted! Now the exciting part is line ten. What the emit keyword does is, well, “emits” the event ContentCreated letting people who listen to this contract know someone created some content. Remember how I told you we had no way of knowing exactly when a user placed trades and what they placed? Well now we do! Once the data is stored we immediately emit the event with who placed these positions and what they were. This is so that we, or anyone listening to this particular event on our contract, know in real-time when this content got created and what that content was so they can do whatever they’d like with that information. In our case, it’s for some super-innovative stuff which we will be talking more about in the future.

And that’s all there is to it! Our smart contract is what we are calling a simple data repository. We store users’ trades on a ledger that we can easily look up and can also respond in real-time when they get placed, which were the main limitations of sending user trades directly to the blockchain. It will also allow us to do more advanced things but we will be revealing more about that in the future. To end this explanation, here is a screenshot showing off a user posting their trades to our contract on the SKALE blockchain explorer (http://rhythmic-tegmen.explorer.mainnet.skalenodes.com/txs):

Transaction example

Finally, I just want to say happy new year! 2022 is going to be a big year for Covey, and hopefully, this article has given you an idea of just how smart contracts will play a part in Covey’s future growth and development. Depending on how this article does I will be doing even more articles explaining how we’re using certain technologies to achieve Covey’s goals.

happy new year

If you want to take a look at our entire smart contract you can do so by going here:
brookerbjb/coveyIO-smart-contract-ledger: trade ledger

Original post: https://medium.com/covey/covey-is-getting-smart-contracts-b2705be882cd by John Carabello

For more information on Covey:

https://covey.io/

For more information on SKALE:

SKALE Website https://skale.network

Dapp Developers interested in utilizing SKALE for a project, please apply to the SKALE innovator program https://skale.network/innovators-signup

Join Discord: https://skale.chat

Documentation on deploying a Dapp to SKALE, can be found in the Developer Portal https://skale.network/docs/

To learn more about the SKALE $SKL token, please visit our SKL Token page https://skale.network/token/