Smart Contract - The nervous system of the blockchain

in #blockchain6 months ago

We can define, very briefly, that a blockchain is a digital chain of blocks linked to each other that contain transactions between accounts as if it were a logbook. When two people reach an agreement they usually leave the agreement and conditions reflected in some kind of medium commonly known as a "contract". The contract defines the terms of the agreement as to what affects each party and under what conditions the agreement will be completed. The completion of that agreement is what we will call a "transaction".

cytonn-photography-n95VMLxqM2I-unsplash.jpg
Photo by Cytonn Photography on Unsplash

As I said, the blockchain is made up of blocks containing transactions and those transactions contain the execution of "agreements" or "contracts".

Smart Contracts are computer programs that are stored in the blockchain nodes and will be used to carry out these agreements between parties; between accounts.

The contracts seen by the users

From a user's point of view, a contract can be designed to perform one or several actions following the "if this happens... do this..." paradigm. In order to do this, the contract needs to receive certain input information and what the action or actions to be performed will be.

It would be ideal if contracts had some kind of trigger, or trigger, that would launch the action by itself when certain conditions are met, but this is something that is still under study and development. For now, it is the particular applications that must take control of the conditions or simply wait to be called.

Let's imagine the case of a contract between the members of a music group. Every time someone buys one of your songs and pays with cryptomoney into the account associated with the sales contract, it would be ideal if the contract distributed the dividends among the members of the band as stipulated in the conditions of the contract and without any mediation by other parties. This is what would really give security and reliability to the blockchains and their contracts. Unfortunately, the intervention of one party is still necessary for the action of the contract to be executed. For example, a program that would call for profit sharing action once every 7 days or once a month. This is not a bad solution, but it implies the need to trust the third party.

viktor-talashuk-1qprurcABtI-unsplash.jpg
Photo by Viktor Talashuk on Unsplash

The contracts seen by the developers

WAX contracts and their actions are defined within a class that inherits directly from the eosio::contract class.

The contract usually contains the actions, the permissions, the data you need to perform, which may be persistent or not, and the "dispatchers" who will register the actions so that they can be called.

Ashampoo_Snap_lunes, 6 de julio de 2020_18h04m09s_002_.png

When we register a contract in the blockchain, it is associated with the account with which it has been registered and its public elements can be seen and used from some blockchain browsers.

This is the aspect that shows the list of "actions" of the Simple Assets contract for the management of its FT, NFT and NTT tokens.

Ashampoo_Snap_lunes, 6 de julio de 2020_18h45m29s_004_.png

Throughout this series of publications we will be analyzing many of these actions and we will see how we can implement them within the code of our programs. At the time of preparing these tutorials the new NFT has been released by Atomic Assets, so I will try to include their contract in the next tutorials as well.

You may also be interested in

If you like my work please, consider using one of your votes to support me as a witness:
image.png

Sort:  

One of the coolest articles I read thanks

Excelente post amigo

Muchas tracias!

Hola @marcosdk necesito hacerle una consulta a modo urgente, no se si sea posible contactarlo por discord..
Tenga buenas noches..

Por supuesto. Puedes encontrarme en https://discord.gg/d9JH87

Coin Marketplace

STEEM 0.20
TRX 0.03
JST 0.030
BTC 36404.95
ETH 1226.26
USDT 1.00
SBD 3.24