Smart contract: token contract, ordinary contract

statement

This article is: Vue3.0 +Quasar+ ethers.js and Ethereum smart contract interaction  series one of the tutorials

smart contract

As I said in the previous section, what the blockchain wants to create is a completely decentralized data world where anyone can participate in the creation and recording of data, which is open and transparent, and can never be tampered with. And in order for each of us to write data on it, a contract (smart contract) was born.

At this point you can understand the smart contract as: it is a program (APP) running on the blockchain

Because the blockchain is decentralized, the contract can also be called - DAPP (D: Decentralized - decentralized).

In fact, it is no different from ordinary APP, and it also provides various functions for users to use like ordinary APP, but it is different from ordinary APP. All the methods and data of its operation are open and transparent, and it does not Like the apps developed by general companies.

The APP code developed by a general company can only be seen by the company that developed it, and the code of the contract is all open and transparent.

Or an example from the previous section:

Suppose we want to write a novel on the blockchain now, we will create the following contract:

  1. Create a novel when the contract is initialized (because we only write one)
  2. There is a method for creating novel chapters on the contract. We call it on the blockchain browser to create novel chapters and write the chapter content.
  3. After the novel is completed, there is a method on the contract that allows us to complete the settings. We call it on the blockchain browser to complete the settings.

At this point, the interaction between a contract and us is complete, and we use the contract to create data on the blockchain.

token contract, contract

The two types of contracts we commonly see on the market today are divided into token contracts and ordinary contracts. In fact, they are all contracts (DAPP), but their functions are different.

token contract

The main function of the token contract is to operate the token. Generally, all methods or functions on the token contract are for operating the token.

For example, the token contract of Ethereum has functions such as balance query and amount authorization to operate tokens.

It is assumed here that we have an electronic mall, and we need to use eth to pay, so we need to access the eth token contract to perform functions such as amount authorization, balance query, and transfer.

ordinary contract

Ordinary contract is like the novel contract in my example above, it is only developed for specific functions, because there are too many things mentioned above, I won’t say more here.

 

Guess you like

Origin blog.csdn.net/qq_22502303/article/details/126279733