Development and learning based on Ethereum

1. Ethereum

Ethereum white paper

APPLY({ Alice: $50, Bob: $50 },“send $70 from Alice to Bob”) = ERROR

The "state" in Bitcoin refers to the collection of all coins that have been mined but not yet spent (technically, "unspent transaction output" or UTXO). Each UTXO has a denomination and an owner (by The 20-byte address definition is essentially an encrypted public key fn. 1). The transaction contains one or more inputs, each of which contains a reference to an existing UTXO and a cryptographic signature generated by the private key associated with the owner’s address, and one or more outputs, each of which contains a new UTXO status.

The state transition function APPLY(S,TX) -> S'can be roughly defined as follows:
1. For each input TX in the:
if the UTXO referenced is not in the S, an error will be returned.
If the provided signature does not match the owner of the UTXO, an error is returned.
2. If the sum of denominations of all input UTXOs is less than the sum of denominations of all output UTXOs, an error will be returned.
3. Return to S'delete all input UTXOs and add all output UTXOs.

2. Ethereum account

In Ethereum, the state is made up of objects called “accounts”, with each account having a 20-byte address and state transitions being direct transfers of value and information between accounts. An Ethereum account contains four fields: (In Ethereum, The state is composed of objects called "accounts". Each account has a 20-byte address. The state transition is the direct transfer of value and information between accounts. An Ethereum account contains four fields:)

At The nonce , A counter Used to the make the Sure the each Transaction CAN only BE Processed Once
at The the Account's Current ether Balance
at The the Account's Contract code , IF Present
at The the Account's Storage (empty by default)
the random number counter is used to ensure that each transaction only once Process
the current Ether balance of the
account The contract code of the account (if any)
The storage space of the account (empty by default)

Generally, there are two types of accounts: externally owned accounts controlled by private keys and contract accounts controlled by their contract codes. Externally owned accounts do not have codes, and messages can be sent from externally owned accounts by creating and signing transactions; in contract accounts, the contract account activates its code every time a message is received, allowing it to read and write to internal storage And send other messages or create contracts in turn.

3. News and transactions

The term "transaction" used in Ethereum refers to a signed data packet used to store messages to be sent from an externally owned account. The transaction includes:

  • Recipient of the message
  • Identify the sender’s signature
  • The amount of ether transferred from the sender to the receiver
  • Optional data field
  • A STARTGAS value, which indicates the maximum number of calculation steps allowed for transaction execution
  • A GASPRICE value, which represents the cost that the sender has to pay for each calculation step

Four, decentralized application DApp

DApp is a kind of "server" application running on the blockchain network, similar to apps running on devices such as Android/iOS, and DApp running on the Ethereum network. Ethereum has a code repository dapp-bin ( https://github.com/ethereum/dapp-bin ) under GitHub , which contains some documents and examples. Before using, you need to look at the recent status of the files, because they will probably have been eliminated.

Five, DApp browser

A DApp browser, as it says literally, is used to make the use of DApp clients (often using JS to interact with Ethereum smart contracts) easier.

The main purpose of the DApp browser is:

Provides a connection to an Ethereum node (or to a local node or a remote node), and a convenient switch between different nodes (or even different networks).

Provide an account (or a wallet) to facilitate user interaction with DApp.

  1. Mist

Mist ( https://github.com/ethereum/mist ) is the official DApp browser of Ethereum. A beautiful interface to interact with Ethereum nodes and send and receive transactions with smart contracts.

  1. Status

Status ( https://status.im/ ) is a DApp browser that can be used on mobile phones.

  1. MetaMask

MetaMask ( https://metamask.io/ ) is a Google browser extension that turns Chrome into a DApp browser. Its core feature is to inject the js client library web3 provided by Ethereum into each interface to allow DApp to connect to the Ethereum node service provided by MetaMask. However, this Chrome extension allows you to manage your wallet and connect to different Ethereum networks (including local development networks).

  1. Parity

Parity is an Ethereum client (also an implementation of a full node), integrated into the web browser and made it a DApp browser.

Sixth, the Ethereum network

Mainnet - Ethereum mainnet , usually the default network for all clients.

Ropsten - Ethereum 's main test network using proof of work. This network is vulnerable to DDOS attacks, fragmentation, or other problems due to low computational load. It was temporarily abandoned after the spam attack and only recently resumed use.

Link: https://github.com/ethereum/ropsten

The test network composed of Kovan-parity clients uses authorization certificates to improve the immunity to spam attacks, and the blocking time lasts for 4 seconds.

Link: https://github.com/kovan-testnet/proposal

The test network composed of Rinkeby-geth clients uses group consensus. Although the amount of calculation is low, it is more resilient to malicious actors.

Link: https://www.rinkeby.io/

You can build your own test network, maybe use
kubernetes ( https://github.com/MaximilianMeister/kuberneteth )

or

docker-composehttps://capgemini.github.io/blockchain/ethereum-docker-compose

But maybe you will soon be able to do it without spending any time.

7. Truffle and Embark
Once you start writing smart contracts, you will repeat a lot of operations, such as compiling the source code into bytecode and abi, deploying to the network, testing and then deploying the contract, etc. You may want to focus more on what you want to achieve.

Truffle and Embark frameworks standardize and automate these trivial tasks. They provide a good development, deployment, and more importantly, the experience of testing smart contracts.

You can start the journey of using Truffle through the official documentation.

You can refer to: Develop the first decentralized application based on Ethereum-Pet Store.

Embark ( https://github.com/embark-framework/embark ) provides similar, slightly different tools that help developers organize projects.

When you first touch the smart contract, you should try not to use the framework. Until you understand the value of using a framework, you should start using it, just as you should not learn HTML through rails new.

Eight, ETHPM

Sharing is caring, so ETHPM is a decentralized smart contract package management resource library (https://www.ethpm.com/registry). With ETHPM, you can associate or connect to a well-known contract or library, reduce code duplication, and ideally provide a good foundation for future development.

The specification here (https://github.com/ethereum/EIPs/issues/190) details the relevant information and background. Both Truffle and Embark can be integrated with it and create a pleasant development experience.

Guess you like

Origin blog.csdn.net/qq_42293496/article/details/103700376