"Remember" is the best farewell. How to use blockchain to store information on the chain?

Source: Chained

Dr. Li Wenliang was unfortunately killed by new crown pneumonia in the early morning of the 7th. His premature death has made us very sad.

In December last year, people's understanding of new coronary pneumonia was still very limited. Li Wenliang was able to spread the news and take the lead in sounding alarms among professionals. This is part of his highly professional performance. In later recounts, it was found that he showed respectable medical ethics in his usual work.

The World Health Organization has tweeted today expressing sorrow over the death of Dr. Li Wenliang. Tweet: All of us should praise him for his work on the new coronavirus epidemic.

Someone has built a monument for Dr. Li Wenliang on the Ethereum blockchain, the contract address is

0x6E46D3AB7335FFFB0d14927e0B418CC08fe60505

Block height 9432824. The deeds of Dr. Li Wenliang will always be engraved on the blockchain and cannot be tampered with or deleted.

Anyone who wants to see this monument can visit etherscan.io to search for the contract address. This is a website for viewing Ethereum transactions and contracts.

As a distributed ledger system, Ethereum records transaction information. How is this information recorded?

We know that Ethereum packages transaction data and verification information in a block at regular intervals, and concatenate them in turn to form a chain. This block number is called the block height. The block header (verification information) of each block stores the block header hash value (ParentHash, parent block hash) of the previous block. In this way, the blocks in the blockchain are linked to each other. If we change the content of a block in the front, the hash of the parent block of the subsequent block does not correspond to it, and such a block cannot be consensus. This ensures that the blockchain data cannot be tampered with.

Saving data on the Ethereum blockchain is mainly achieved by additional data in transactions or by deploying smart contracts.

Additional data

In simple terms, each block of Ethereum is divided into two parts. The first is a block header that contains information such as the hash value and time stamp of the parent block. The block header also contains:

ParentHash: the hash of the parent block

Number: block number

Timestamp: timestamp generated by the block

GasUsed: Gas consumed by the transaction

GasLimit: Gas limit

Difficulty: difficulty of POW

Beneficiary: Beneficiary of block packing fees, also known as miners

Nonce: a random number that makes the block header hash meet the requirements of POW

As the block header is produced, the block also contains transaction, status, and receipt information.

The transaction information includes:

Type: The type of transaction

Nonce: the transaction count of the sending address

Value: the amount sent to the target account

ReceiveAddress: recipient address

GasPrice: Gas price paid for the transaction

Gas: Gas paid for the transaction

Data: Additional data for the transaction

VRS: Transaction Signature Structure The Data column contains the information that the user wants to record in the ETH block. This transaction data field was originally used to describe the transaction description, but because it does not occupy Gas, that is, it does not generate any fees, it has become a field for recording content.

According to the characteristics of the blockchain itself, each transaction has a unique ID. With this ID, we can view all historical transactions, including everything mentioned above: transaction type, timestamp, Gas, additional data, etc. Once we know this ID, we can look at the information contained in the block.

for example,

0x802a072a303a1bb19a20065a262526f2cfda0d1ea16eeb3db6500d9d06f65963

By changing the additional data in this transaction to UTF-8 encoding, you can see an article about vaccine quality.

Deploying smart contracts

The smart contract can be simply understood as an executable program fragment. The specific code is written by the publisher using a specific programming language (Ethereum uses the Solidity programming language, similar to JavaScript). Once the coding is completed, the smart contract is Uploaded to the blockchain network, that is, the entire network of verification nodes will receive your smart contract. The Ethereum smart contract can also be understood as a special transaction (including executable code). After being sent out, it will be packaged and recorded by a miner in a certain block. When the smart contract needs to be called, only the smart Send a transaction at the address of the contract. The community-built monument for Dr. Li Wenliang is also preserved in this way.

Another example is at the contract address

0xdc7c743110Ec689d82f050302319AE27aF84f8fa

You can see the Korean version of the famous Panmunjom Declaration. The transaction was recorded in 2018 by Ryu Gi-hyeok, a South Korean developer.

How do I save my information?

If you are an ordinary user who does not understand programming, you can download the MetaMask browser plug-in, make any transaction on the Ethereum mainnet, and convert the information you want to save into a hex code and paste it in the transaction data column. It should be noted that this process requires you to pay some GAS (ie, handling fees).

If you understand the Solidity programming language used by Ethereum, you can attach the content to the code, deploy it on the Ethereum mainnet and make any transaction to save your information on Ethereum.