Smart contracts are codes that run in computers and are used to ensure that participants execute their commitments. Generally, ordinary contracts record all aspects of the relationship terms between Party A and Party B, and are usually passed through are enforced or protected by law, whereas “smart contracts” use passwords or keys to enforce relationships. To understand it from a more direct perspective, the program content of the "smart contract" will be 100% executed as set by everyone at the beginning, and there will be zero errors.
For example, an Ethereum user can use a smart contract to send 10 ether to a friend on a specific date. In this case, the user can create a contract and then push the program into the contract to perform special calculations so that it can execute the required commands. Ethereum is a platform that specifically focuses on this matter.
Bitcoin is the first resource currency to support "smart contracts" because the value of the network lies in transferring value or data from one point or person to another. The network of nodes only validates when certain conditions are met, however, Bitcoin is limited to monetary use cases. Instead, Dafang replaced Bitcoin’s rather restrictive programming language with a language that allowed developers to write their own programs. Ethereum allows developers to write their own "smart contracts," or "autonomous agents," as the ETH white paper calls them. The programming language is "Turing complete," meaning it supports a broader set of computing instructions. What can smart contracts do?
1. "Multi-signature" account function, funds can only be used when a certain proportion of people agree. This feature is often used in campaigns similar to crowdfunding or fundraising.
2. Manage agreements signed between users. For example, one party purchases insurance services from another party 3. Provides utility for other contracts.
4. Store information about the application, such as "domain registration information" or "member information record". The concept is sometimes obscure. Let’s take an example of a fundraising smart contract to help understand: Suppose we want to initiate a donation to all network users, then we can first define a smart account, which has three states: current total donation amount, donation target and the address of the recipient, and then define two functions for it: the receiving function and the donating function.
Each time the fundraising function receives a transfer request, it first checks whether the sender has enough money (EVM will provide the address of the requester, and the program can obtain the person's current address through the address. (blockchain financial status), and then every time the fundraising call is called, it will compare the current total amount of donations with the donation target. If the target is exceeded, all donations currently received will be sent to the designated recipient address. , otherwise, only the current total donation status value will be updated.
The donation function sends all donations to the saved recipient address and clears the current donation total to zero. Everyone who wants to raise funds uses his or her ETH address to initiate a transfer to the smart account and specifies that the function to accept the donation should be called. So we have a fundraising smart contract. People can donate into it. When the limit is reached, the money will be automatically sent to the designated account. Miners all over the world are calculating and guaranteeing this contract, and there is no need for people to keep an eye on it. There is no misappropriation, this is the charm of smart contracts.