Git Product home page Git Product logo

token-bind-tool's Introduction

token-bind-tool

Tool to bind BEP2 tokens and BEP20 tokens. please refer to document for detail bind mechanism.

Compile

Compile token bind tool:

make build

Preparation for binding tokens

  1. Generate temp account (Deploy contract on Binance Smart Chain):

    ./build/token-bind-tool initKey --network-type {testnet/mainnet}

    Example response:

    Temp account: 0xde9Aa1d632b48d881B50528FC524C88474Ec8809, Explorer url: https://bscscan.com/address/0xde9Aa1d632b48d881B50528FC524C88474Ec8809
    
  2. Transfer 1 BNB to the temp account.

    2.1 Cross chain transfer

     bnbcli bridge transfer-out --expire-time `expr $(date +%s) + 3600` \
     --chain-id Binance-Chain-Tigris --from {keyName} --node http://dataseed4.binance.org:80 \
     --to {temp account address} --amount 100000000:BNB

    Example command:

    bnbcli bridge transfer-out --expire-time `expr $(date +%s) + 3600` \
    --chain-id Binance-Chain-Tigris --from bep2TokenIssuer --node http://dataseed4.binance.org:80 \
    --to 0xde9Aa1d632b48d881B50528FC524C88474Ec8809 --amount 100000000:BNB

    2.2 You can also transfer BNB from other Binance Smart Chain account with Metamask.

Bind BEP2 token with BEP20 token

Case 1

Suppose you have already issued a BEP2 token, and you want to deploy a BEP20 token and bind it with existing BEP2 token:

  1. Import bep2 token owner key(Send bind transaction on Binance Chain):

    1.1 From ledger: connect ledger to your computer and open Binance Chain App

    bnbcli keys add bep2TokenIssuer --ledger --index {your ledger key index}

    1.2 From mnemonic:

    bnbcli keys add bep2TokenIssuer --recover
  2. Prepare BEP20 contract code

    2.1 You can refer to BEP20 Template and modify it according to your own requirements.

    NOTE 1: Ensure the BEP20 symbol is identical to the prefix of a BEP2 token symbol. Suppose a BEP2 token symbol is ABC-123, then the BEP20 symbol must be ABC.

    NOTE 2: Ensure the total supply equals to the BEP2 token total supply. As we know, the decimals of BEP2 tokens are 8, if the BEP20 decimal is 18, then the BEP20 total supply must be BEP2_total_supply*10^10.

    NOTE 3: If your BEP2 token is mintable, then you'd better implement mint in BEP20 contract. Otherwise, you'd better remove mint in BEP20 contract.

    2.2 Compile your contract with Remix and get contract byte code: img

  3. Edit script/contract.json to add contract byte code:

    {
      "contract_data": ""
    }

    Fill contract byte code to contract_data

  4. Deploy contract, bind and transfer ownership:

    ./script/bind.sh {mainnet/testnet} {bep2TokenIssuerKeyName} {password, for ledger key, use empty string: ""} {peggyAmount} {bep2 token symbol} {token owner} {path to bnbcli or tbnbcli}

    Example command:

    ./script/bind.sh testnet bep2TokenIssuer "12345678" 0 ABC-D9B 0xaa25Aa7a19f9c426E07dee59b12f944f4d9f1DD3 $HOME/go/bin/tbnbcli

Case 2

Suppose you have already issued BEP2 token, deployed BEP20 contract and sent bind transaction, now you just want to approve bind from your Ledger device:

  1. Connect ledger to your machine and open Ethereum app.
  2. Execute this command to approve bind:
./build/token-bind-tool approveBindFromLedger --bep2-symbol {bep2 symbol} --bep20-contract-addr {bep20 contract address} \
--ledger-account-index {ledger key index} --peggy-amount {peggy amount} --network-type {mainnet/testnet}

Case 3

Suppose you just want to deploy a BEP20 contract and transfer all token and ownership to your owner account, then you can try this command:

./build/token-bind-tool deployBEP20ContractTransferTotalSupplyAndOwnership --bep20-owner {bep20 owner} \
--config-path {contract byte code path, refer to `script/contract.json`} --network-type {mainnet/testnet}

Refund rest BNB on temp account

./build/token-bind-tool refundRestBNB --network-type {mainnet/testnet} --recipient {bsc account}

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.