In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the principle of Ethernet Square Lightning Network implementation". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Ethernet Square Lightning Network implementation principle is what" it!
Implementation principle of Lightning Network in Ethernet Square
Online direct transfer requires a certain fee, if there are a large number of small transactions, the cost will become unbearable, so Taifang introduced micro-transaction payment channel to solve this problem. Etay Fong provides a bill payment scheme, which mainly relies on an one-to-many billing system implemented by smart contracts. The general implementation process of the billing system is as follows.
1: bill generation, while providing a mechanism to deposit a deposit on the bill.
2: the transaction originates into a negotiable instrument
3: send the bill directly to the recipient
4: the recipient cashes the bill and transfers money from the contract (although a cash may fail, it can eventually be cashed as long as the bill exists).
The advantage of this kind of transaction is that any number of transactions can be sent offline, and only two on-chain transactions (deposit and cash) are needed as long as they are deposited on margin, and any number of transactions are carried out offline through the exchange of notes, thus avoiding frequent online transfers and saving transaction costs.
Code structure. ├── api.go / / external interface ├── cheque.go / / bill ├── cheque_test.go ├── contract │ ├── chequebook.go / / contract go language interface │ ├── chequebook.sol / / contract source │ ├── code.go / / contract byte code │ ├── mortal.sol / / contract termination │ └── owned.sol / / hebe permission └── gencode.go / / contract byte code generation contract layer
The contract itself receives the transfer, and the user can initialize or later increase the amount, and the bill can be cashed through the cash method, and the transfer amount will be saved in the send variable.
Pragma solidity ^ 0.4.18; import ". / mortal.sol"; / / @ title Chequebook for Ethereum micropayments / / @ author Daniel A. Nagy contract chequebook is mortal {/ / Cumulative paid amount in wei to each beneficiary / / already paid can control double flowers and prevent multiple convertibility notes mapping (address = > uint256) public sent; / @ notice Overdraft event event Overdraft (address deadbeat) / / Allow sending ether to the chequebook. Function () public payable {} / @ notice Cash cheque / @ param beneficiary beneficiary address / / @ param amount cumulative amount in wei / @ param sig_v signature parameter v / / @ param sig_r signature parameter r / @ param sig_s signature parameter s / The digital signature is calculated on the concatenated triplet of contract address Beneficiary address and cumulative amount function cash (address beneficiary, uint256 amount, uint8 sig_v, bytes32 sig_r, bytes32 sig_s) public {/ / Check if the cheque is old. / / Only cheques that are more recent than the last cashed one are considered. Require (amount > sent [beneficiary]); / / Check the digital signature of the cheque. Bytes32 hash = keccak256 (address (this), beneficiary, amount); require (owner = = ecrecover (hash, sig_v, sig_r, sig_s)); / / Attempt sending the difference between the cumulative amount on the cheque / / and the cumulative amount on the last cashed cheque to beneficiary. Uint256 diff = amount-sent [beneficiary]; if (diff
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.