Code Monkey home page Code Monkey logo

hedera22-cli's Introduction

Java code to interact with Hedera in TESTNET

Before you start

Accounts

Using your operator account and private (Set them in Accounts), create two other accounts for the participants and update the Accounts.java file. Use CreateAccount to create them

Deploy the contracts

Use DeployERC20 twice with the relevant token info (name, supply) and DeployDLOBEx for the main smart contract.
Note the deployment uses testnet and use your operator account.

Transfer some native HBARs to the participants

For the participants to be able to interact with the native chain, transfer some native HBARs to them using TransferHBARs.
You can then use CLI the with the option "Display balances" to confirm.

Transfer some tokens to the participants.

Same as above, but using TransferTokens

You should see on the CLI:

[main] INFO org.tj.hedera22.CLI - Displaying balances... (gas used: 320000)
[main] INFO org.tj.hedera22.CLI -  Operator: 9560.53196754 ℏ
[main] INFO org.tj.hedera22.CLI -  Participant 1: 200 ℏ, HHBAR Owned: 50000, HUSD Owned: 50000, HHBAR Allowance: 0, HUSD Allowance: 0
[main] INFO org.tj.hedera22.CLI -  Participant 2: 200 ℏ, HHBAR Owned: 50000, HUSD Owned: 50000, HHBAR Allowance: 0, HUSD Allowance: 0

Approve

The next step is to allow the smart contract DeployDLOBEx to spend your tokens post trade.
This is done with ApproveTransfer.

Finally, the last state from the CLI, you should also see the allowance:

[main] INFO org.tj.hedera22.CLI - Displaying balances... (gas used: 320000)
[main] INFO org.tj.hedera22.CLI -  Operator: 9552.52838234 ℏ
[main] INFO org.tj.hedera22.CLI -  Participant 1: 199.27539722 ℏ, HHBAR Owned: 50000, HUSD Owned: 50000, HHBAR Allowance: 50000, HUSD Allowance: 50000
[main] INFO org.tj.hedera22.CLI -  Participant 2: 199.27539722 ℏ, HHBAR Owned: 50000, HUSD Owned: 50000, HHBAR Allowance: 50000, HUSD Allowance: 50000

CLI

Just launch the CLI and enjoy

[main] INFO org.tj.hedera22.CLI - Hedera Menu. Please select an option:
[main] INFO org.tj.hedera22.CLI -  Acting account: 0.0.7599 (Operator)
[main] INFO org.tj.hedera22.CLI -    1. Exit
[main] INFO org.tj.hedera22.CLI -    2. Allow Trading (~ 1ℏ)
[main] INFO org.tj.hedera22.CLI -    3. Stop Trading (~ 1ℏ)
[main] INFO org.tj.hedera22.CLI -    4. Add All Participants (~ 2ℏ)
[main] INFO org.tj.hedera22.CLI -    5. Select participant (free)
[main] INFO org.tj.hedera22.CLI -    6. Display order book (~ 7ℏ)
[main] INFO org.tj.hedera22.CLI -    7. Place Limit Order (~ 1ℏ)
[main] INFO org.tj.hedera22.CLI -    8. Place Market Order (~ 1ℏ)
[main] INFO org.tj.hedera22.CLI -    9. Display balances (~ 8ℏ)
[main] INFO org.tj.hedera22.CLI -    10. Display trading allowed status (~ 0.1ℏ)
[main] INFO org.tj.hedera22.CLI -    11. Display latest debug (~ 0ℏ)
[main] INFO org.tj.hedera22.CLI -    12. Reset

hedera22-cli's People

Contributors

tjdragon avatar nftree721 avatar

Watchers

 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.