MMM(3M)互助公排dapp系统开发合约部署技术流程

简介: MMM(3M)互助公排dapp系统开发合约部署技术流程

任何人都可以编写智能合约并将其部署到区块链网络上。 您只需要学习如何用智能合约语言编码,并有足够的以太币来部署您的合约。 部署智能合约在技术上是一笔交易,因此就像你需要为简单的以太币转账支付燃料费一样,你也需要为部署智能合约支付燃料费。 但是,合约部署的燃料成本要高得多。


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);
}
相关文章
|
6天前
|
存储 算法 分布式数据库
持币生息DAPP系统开发|模式方案|源码
区块链将所有信息存储在分类账系统中。此外,任何类型的数据交换都称为“交易”
|
6天前
|
存储 安全 区块链
dapp去中心化互助公排系统开发模式
Web3是基于区块链技术实现,那就拥有了区块链里面智能合约的机制,一切都是可以被灵活定义的
|
6月前
|
存储 安全 区块链
DAPP互助公排智能合约系统开发方案与需求
智能合约是需要区块链开发者用区块链编程语言写出来的一串代码,根据不同场景构思逻辑后开发出来的信任机制
|
7月前
|
存储 安全 区块链
dapp去中心化大小公排互助系统开发模式方案
在编写完智能合约之后,需要将其部署到区块链网络上
|
7月前
|
区块链 数据安全/隐私保护 算法
DAPP互助公排系统开发|DAPP三三复制系统开发(模式)
Web3.0的主要特点是开放、隐私和去中心化。
|
8月前
|
存储 设计模式 开发框架
DAPP排单互助公排系统开发智能合约模式
智能合约开发:学习使用智能合约开发语言(如Solidity),熟悉智能合约的编写
|
9月前
|
供应链 Java 关系型数据库
dapp排单公排互助系统开发|dapp合约公排系统开发案例|详情代码
Web3生态系统的核心是智能合约和去中心化应用程序private List<DiffOrders>
|
10月前
|
存储 开发框架 前端开发
BSC链Defiswap丨IPPswap丨NFTswap丨OMNIswap智能合约去中心化项目系统开发成熟技术/项目案例/源码说明
  区块链是一个分布式账本,使用密码学原理来记录数据,并且按照时间顺序进行记录。在区块链中,数据可以进行高度地分散,因为数据分布在不同的节点上。当一个区块链被添加到一个新的区块上时,它将包含以前的所有交易记录。
|
存储 安全 区块链
MMM排单互助智能合约开发系统部署技术
目前实现的方式根据存储区分有各种各样的模式,但是都离不开一个最底层的机制,就是使用delegatecall的特性去实现可升级的合约,达到合约可持续优化更改的效果
MMM排单互助智能合约开发系统部署技术