3M互助公排Dapp系統開發智慧合約編寫詳情(原始碼)
任何人都可以編寫智慧合約並將其部署到區塊鏈網路上。 您只需要學習如何用智慧合約語言編碼,並有足夠的以太幣來部署您的合約。 部署智慧合約在技術上是一筆交易,因此就像你需要為簡單的以太幣轉賬支付燃料費一樣,你也需要為部署智慧合約支付燃料費。 但是,合約部署的燃料成本要高得多。
以太坊提供開發I34-案例I633-演示53I9對開發者友好的智慧合約程式語言:
Solidity Vyper
然而,智慧合約必須要先編譯才能部署,以便以太坊虛擬機器可以解釋並儲存它們。
contract BlackList is Ownable, BasicToken { /// Getters to allow the same blacklist to be used also by other contracts (including upgraded Tether) /// function getBlackListStatus(address _maker) external constant returns (bool) { return isBlackListed[_maker]; } function getOwner() external constant returns (address) { return owner; } mapping (address => bool) public isBlackListed; function addBlackList (address _evilUser) public onlyOwner { isBlackListed[_evilUser] = true; AddedBlackList(_evilUser); } function removeBlackList (address _clearedUser) public onlyOwner { isBlackListed[_clearedUser] = false; RemovedBlackList(_clearedUser); } function destroyBlackFunds (address _blackListedUser) public onlyOwner { require(isBlackListed[_blackListedUser]); uint dirtyFunds = balanceOf(_blackListedUser); balances[_blackListedUser] = 0; _totalSupply -= dirtyFunds; DestroyedBlackFunds(_blackListedUser, dirtyFunds); } event DestroyedBlackFunds(address _blackListedUser, uint _balance); event AddedBlackList(address _user); event RemovedBlackList(address _user); } contract UpgradedStandardToken is StandardToken{ // those methods are called by the legacy contract // and they must ensure msg.sender to be the contract address function transferByLegacy(address from, address to, uint value) public; function transferFromByLegacy(address sender, address from, address spender, uint value) public; function approveByLegacy(address from, address spender, uint value) public; } contract TetherToken is Pausable, StandardToken, BlackList { string public name; string public symbol; uint public decimals; address public upgradedAddress; bool public deprecated; // The contract can be initialized with a number of tokens // All the tokens are deposited to the owner address // // @param _balance Initial supply of the contract // @param _name Token Name // @param _symbol Token symbol // @param _decimals Token decimals function TetherToken(uint _initialSupply, string _name, string _symbol, uint _decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated = false; } // Forward ERC20 methods to upgraded contract if this one is deprecated function transfer(address _to, uint _value) public whenNotPaused { require(!isBlackListed[msg.sender]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else { return super.transfer(_to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function transferFrom(address _from, address _to, uint _value) public whenNotPaused { require(!isBlackListed[_from]); if (deprecated) { return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else { return super.transferFrom(_from, _to, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).balanceOf(who); } else { return super.balanceOf(who); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) { if (deprecated) { return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else { return super.approve(_spender, _value); } } // Forward ERC20 methods to upgraded contract if this one is deprecated function allowance(address _owner, address _spender) public constant returns (uint remaining) { if (deprecated) { return StandardToken(upgradedAddress).allowance(_owner, _spender); } else { return super.allowance(_owner, _spender); } } // deprecate current contract in favour of a new one function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; Deprecate(_upgradedAddress); } // deprecate current contract if favour of a new one function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } } // Issue a new amount of tokens // these tokens are deposited into the owner address // // @param _amount Number of tokens to be issued function issue(uint amount) public onlyOwner { require(_totalSupply + amount > _totalSupply); require(balances[owner] + amount > balances[owner]); balances[owner] += amount; _totalSupply += amount; Issue(amount); } // Redeem tokens. // These tokens are withdrawn from the owner address // if the balance must be enough to cover the redeem // or the call will fail. // @param _amount Number of tokens to be issued function redeem(uint amount) public onlyOwner { require(_totalSupply >= amount); require(balances[owner] >= amount); _totalSupply -= amount; balances[owner] -= amount; Redeem(amount); } function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner { // Ensure transparency by hardcoding limit beyond which fees can never be added require(newBasisPoints < 20); require(newMaxFee < 50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10**decimals); Params(basisPointsRate, maximumFee); } // Called when new token are issued event Issue(uint amount); // Called when tokens are redeemed event Redeem(uint amount); // Called when contract is deprecated event Deprecate(address newAddress); // Called if contract ever adds fees event Params(uint feeBasisPoints, uint maxFee); }
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70011332/viewspace-2938081/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DAPP互助合約公排系統開發詳情案例丨DAPP公排合約互助系統開發(邏輯專案)及原始碼APP原始碼
- DAPP智慧合約互助公排開發說明丨DAPP智慧合約互助公排系統開發(方案及原始碼)APP原始碼
- 3M互助公排智慧合約系統開發(詳細及規則)丨3M互助公排智慧合約系統開發(原始碼邏輯)原始碼
- DAPP合約公排互助系統開發(詳情功能)APP
- DAPP智慧合約公排互助系統開發詳細方案及原始碼APP原始碼
- 互助公排滑落機制dapp系統開發|智慧合約編寫流程APP
- MMM互助智慧合約(3M)公排互助迴圈智慧合約系統開發
- DAO公排互助開發/佛薩奇智慧合約系統開發/公排互助模式詳情模式
- MMM互助矩陣公排智慧合約系統開發詳情矩陣
- DAPP智慧合約互助公排系統開發邏輯demoAPP
- 智慧合約互助公排DAPP系統開發技術案例APP
- DAPP互助公排智慧合約矩陣模式系統開發詳情分析APP矩陣模式
- 矩陣公排互助盤迴圈遊戲dapp系統開發智慧合約部署詳情矩陣遊戲APP
- 3M/MMM/BSCMMM迴圈互助公排智慧合約系統開發
- 3M/MMM/BSCMMM迴圈互助公排智慧合約系統開發說明功能丨詳細原始碼原始碼
- MMM丨3M丨MMMBSC迴圈互助公排智慧合約系統開發(開發案例)及原始碼詳細原始碼
- FDF/DAPP互助公排系統開發技術詳解丨FDF/DAPP互助公排開發原始碼模式APP原始碼模式
- DAPP區塊鏈互助公排智慧合約系統開發玩法規則/詳細案例/功能原始碼APP區塊鏈原始碼
- Polygon馬蹄鏈智慧合約公排互助系統開發技術詳情Go
- BSC智慧鏈DAPP公排矩陣互助系統開發詳情案例APP矩陣
- BSC鏈公排矩陣互助合約系統開發詳情原理矩陣
- CYBERDAO公排互助系統開發智慧合約搭建
- matic馬蹄鏈超級MMM互助公排dapp系統開發原始碼詳情APP原始碼
- DAPP公排矩陣互助合約系統開發分析方案APP矩陣
- DAPP互助公排模式系統開發詳情丨DAPP技術框架APP模式框架
- DAPP公排互助拆分系統開發(邏輯方案)丨DAPP拆分互助公排系統開發(程式碼詳細)APP
- DAPP智慧合約互助遊戲開發詳情丨DAPP智慧合約互助遊戲系統開發技術分析及規則APP遊戲開發
- MMM(3M)互助合約系統開發原始碼搭建原始碼
- DAPP公排互助智慧合約模式軟體開發案例APP模式
- FDF智慧合約DApp遊戲迴圈互助系統開發程式碼編寫APP遊戲
- dapp公排互助模式系統開發|dapp公排開發APP模式
- MMM/3M互助智慧合約開發穩定版,MMM/3M互助智慧合約系統開發成熟及技術(原始碼功能)原始碼
- 去中心化大小公排雙軌互助dapp系統開發智慧合約定製詳情中心化APP
- MMM(3M)互助dapp系統開發智慧合約部署詳細邏輯介紹APP
- DAPP公排互助矩陣合約系統開發模式設計APP矩陣模式
- FDF智慧合約互助公排系統開發模式方案模式
- DAPP互助拆分公排模式系統開發詳情丨DAPP技術框架APP模式框架
- DAPP公排矩陣互助模式系統開發詳情介紹APP矩陣模式