Git Product home page Git Product logo

meerbank-eth's Introduction

meerbank-eth

The smart contract of the Qitmeer on the Ethereum network

Meer-Destroy

The destruction contract is used to permanently lock HLC tokens and record the destruction address. When Meer is online, the corresponding tokens can be returned.

Contract creation

  • symbol : Quantity of token destroyed;
  • token : token contract address;
constructor (address _token ) public {
    symbol = 0;
    token = _token;
}

Burn

  • _sender : Destroyed users address;
  • value : Destroyed token number , need approve destroy contract number;
function burn( address _sender, uint256 value ) public onlyOwner( _sender ) {
    require(ERC20(token).transferFrom( _sender, address(this), value), 'transferFrom erro');
    burnList[_sender].amount = burnList[_sender].amount.add(value);
    symbol = symbol.add(value);
    emit Burn( _sender, value);
}

Confirm meer Address

Batch operations can be used confirmBatchTxid.

  • _meerPKH: meer publickey hash 160;
function fetchMeer( bytes20 _meerPKH ) public {
    burnList[msg.sender].redeemPublicHash = _meerPKH;
}

Query the Recycle Address of the User

  • getSenderNum: Query Recycle Address number;
  • getSender: Query destroyed users meer address;
function getSenderNum( address _sender ) view public returns(uint) {
    return burnList[_sender].redeem.length;
}

function getSender( address _sender, uint i ) view public returns( bytes20 meerPublickeyHash, bytes32 txId, uint256 amount ) {
    BurnList memory burn = burnList[_sender];
    return ( burn.redeem[i].meerPKH, burn.redeem[i].txId, burn.redeem[i].amount );
}

Upload transaction id

After Main Network Stabilization, After returning the Meer to the user, upload the transaction certificate to the contract.

  • _sender: Destroyed users address;
  • txId: meer txid;
  • meerNum: Number of meers returned to users;
function confirmTxid( address _sender, bytes32 txId, uint256 meerNum ) public only(owner) {
    BurnList memory burner = burnList[_sender];
    require( burner.amount > 0 );
    require( burner.redeemPublicHash != 0x0 );
    burnList[_sender].redeem.push(
        Redeem(
            burner.redeemPublicHash,
            txId,
            meerNum
        )
    );
    burnList[_sender].amount = 0;
}

Test

Main

Meer-Bank

Test

meerbank-eth's People

Contributors

zhangyi999 avatar dindinw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.