lp智慧合約流動性質押挖礦分紅系統開發說明案例

lovei130908發表於2023-03-13

智慧合約是區塊鏈不可或缺的一部分。這些合約是指在滿足特定條件的情況下,在兩個或多個參與者之間執行特定任務的軟體程式。本質上,它就像一個自動執行的常規合約,不需要中介,因為它依賴於它的程式設計值系統開發 180-383I-97Z4。

pragma solidity ^0.4.0;

 

import "./ERC20Interface.sol";

 

contract ERC20 is ERC20Interface{

     string private _name = "MyToken";

     string private _symbol = "MYT";

     uint8 private _decimals = 3;

     uint256 private _totalSupply = 10 * (10 ** uint256(_decimals));

     mapping(address=>uint256) private _balances;

     mapping(address=>mapping(address=>uint256)) private _allowances;

 

     event Transfer(address indexed _from, address indexed _to, uint256 _value);

     event Approval(address indexed _owner, address indexed _spender, uint256 _value);

     function ERC20(){

         _balances[msg.sender] = _totalSupply;

     }

 

     function name() public view returns (string name){

         name = _name;

     }

 

     function symbol() public view returns (string symbol){

         symbol = _symbol;

     }

 

     function decimals() public view returns (uint8 decimals){

         decimals = _decimals;

     }

 

     function totalSupply() public view returns (uint256 totalSupply){

         totalSupply = _totalSupply;

     }

 

     function balanceOf(address _owner) public view returns (uint256 balance){

         balance = _balances[_owner];

     }

 

     function transfer(address _to, uint256 _value) public returns (bool success){

         require(_balances[msg.sender] >= _value);

         _balances[msg.sender] -= _value;

         _balances[_to] += _value;

         Transfer(msg.sender, _to, _value);

         success = true;

     }

 

     function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){

         require(_balances[_from] >= _value);

         require(_allowances[_from][msg.sender] >= _value);

         _balances[_from] -= _value;

         _allowances[_from][msg.sender] -= _value;

         _balances[_to] += _value;

         Transfer(_from, _to, _value);

         success = true;

     }

 

     function approve(address _spender, uint256 _value) public returns (bool success){

         _allowances[msg.sender][_spender] = _value;

         Approval(msg.sender, _spender, _value);

         success = true;

     }

 

     function allowance(address _owner, address _spender) public view returns (uint256 remaining){

         remaining = _allowances[_owner][_spender];

     }

}

智慧合約相當於使用步伐程式設計介面( API),但它不是在平日的web平臺上應用,而是在區塊鏈上使用。應用系統程式程式設計介面(API)允許學生使用者在他們可以使用的平臺上進行資訊互動並引入某些特性。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70021343/viewspace-2939319/,如需轉載,請註明出處,否則將追究法律責任。

相關文章