Smart Contract - The nervous system of the blockchain
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".
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.
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.
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.
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
- Qué es WAX, para qué se utiliza y cómo crear una cuenta
- Tokens: Introducción a los valores digitales de moda (FT/NFT/NTT)
- InterPlanetary File System (PPFS)