Giter Site home page Giter Site logo

ergpy's Introduction

ergpy

A python-jvm wrapper for interacting with the Ergo blockchain.

Usage

  • Requires Java 8 or higher to be installed on system
pip install ergpy
  • There are helper methods created to do simple transactions
    • Please checkout the examples.py (on github) to see how to use them.
    • Simple Send is available
      • Allows sending ERG to one address or multiple addresses in ONE transactions
    • Get wallet addresses is available
      • This gives derivations of wallet addresses given the mnemonic
      • If specified 2, a list of two addresses will be printed in the console
    • Get Box Info is available
      • Given the index and address, the selected box will be printed
    • Send Token is available
      • Allows sending token(s) to one or multiple addresses
      • The token id paramter must be given as a 2D array
      • Remember that tokens/nfts are seen as the same when transacting with them
    • Create NFT is available
      • Allows creating NFTs
      • One mint is one transaction
      • There are helper methods as well to get the sha-256 hash required while minting
        • SHA256 caster
          • Put the hash as a string and this will be converted into bytes
        • String Hasher
          • Input a string and this will be converted into a hash (only for testing purposes)
        • File Hasher
          • Input the file name and the hash will be generateed
    • Create Token is available
      • Allows a token to be minted
    • Custom
      • A bit more customization is available using methods from appkit.py
      • To truly have custom transactions appkit.py must be edited

Github usage

git clone https://github.com/mgpai22/ergpy && cd ergpy
pip3 install -r requirements.txt
python -m stubgenj --convert-strings --classpath "./ergpy/ergo.jar" org.ergoplatform java
  • If using an ide such as pycharm , make sure the root folder is ergpy
    • This allows code completion via stubgenj to work properly
  • This method is recommended for developer as it allows for direction customizations in appkit.py

Roadmap

  • This is the begining of python support for Ergo! Contributions are essential for this to continue.
  • Ergoscript support.
  • Better documentation and packaging (first time creating a package).
    • Would love some help with this!

Credits

ergpy's People

Contributors

acosmrkas avatar mgpai22 avatar rafidini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ergpy's Issues

Console does not exit

Whenever the code is run I notice that something does not properly exit.

Try this code out:

from ergpy import helper_functions, appkit

node_url: str = "http://213.239.193.208:9052/"  # MainNet or TestNet
ergo = appkit.ErgoAppKit(node_url=node_url)
wallet_mnemonic = "what stadium typical spell rate truly pen tongue fuel intact fluid strike vibrant city shine"
receiver_addresses = [
    "3WwdXmYP39DLmDWJ6grH9ArXbWuCt2uGAh46VTfeGPrHKJJY6cSJ",
    "3WwuG9amNVDwkJdgT5Ce7aJCfeoafVmd9tag9AEiAZwgPi7pYX3w",
    "3Wxk5oofZ3Laq2CpFW4Fi9YQiaep9bZr6QFg4s4xpzz4bi9tZq2U"
]

amount = [0.22, 0.33, 0.11]

tx = helper_functions.simple_send(ergo=ergo, amount=amount, wallet_mnemonic=wallet_mnemonic, receiver_addresses=receiver_addresses)

data = f'Transaction: {str(tx)}'
with open('demo.text', 'w') as file:
    file.write(data)
print("wrote to file")

This will write the txid to file and print to console. However if you want to exit to run other commands in the console you must exit with ctrl + c. I tried including sys.exit(0) and quit() in the code but it does not help.

Any ideas @rafidini ?

Thank you

Check CLI in parallel

Is your feature request related to a problem? Please describe.
No problem, but @mgpai22 can you check issue no. #20 in my branch and also the wiki to confirm it?

Sub-tasks

Among the helper function here are the ones we need to validate with the CLI :

Subcommand version

Subcommand get

Subcommand send

Subcommand create

  • create nft
  • create token
  • create gensis-box
  • create issuer-box

PEP 8 โ€“ Style for Python Code

Is your feature request related to a problem? Please describe.
As this project is meant to become a Python package, it is highly recommended to make it follow the PEP 8 - Style Guide for Python Code.

Source : PEP 8 โ€“ Style Guide for Python Code

Describe the solution you'd like
Make all source code more PEP 8-friendly.

Additional context

A python-jvm wrapper for interacting with the Ergo blockchain.

So we have to be careful of not following Java standards (at least try not to).

Logging

I tested everything with various scenarios and they work well!

I am thinking of adding some sort of optional parameter to the ergo connection object to enable or disable logging. What do you think @rafidini ?

Originally posted by @mgpai22 in #4 (comment)

No more than 16384 headers can be requested

Hello @mgpai22, let us go back on track ๐Ÿš€

I committed some changes to the logs issue (#11), for now, it is very simple and I only added it to a new example (example_7_*.py) to make sure the feature works properly.

But I have an issue running the example, this is my output:

Screenshot 2022-09-18 at 13 22 40

I'll create a new issue to separate it from this feature ๐Ÿ”ง

Originally posted by @rafidini in #11 (comment)

Command-line interface

Is your feature request related to a problem? Please describe.
In order to make it easy to interact with the package, a CLI might be needed.

Describe the solution you'd like
Call CLI like the following examples :

  • ergpy send simple <addr1> <addr2>
  • ergpy send token <id> <addr1> <addr2>
  • ergpy get wallet-addresses --no-addresses 2
  • ergpy get box-info <index> <addr>

Warning
@mgpai22 I will need your help defining the commands' behavior.

Additional context

  • argparse โ€” Parser for command-line options, arguments and sub-commands

More admin rights

Hi, can you please give me more admin rights to make this repo alive? I would like to add many things such as :

  • Actions to automate tests
  • Discussions to create polls and decide on the direction of this repo
  • ... (still thinking of the rest)

You can also consider transforming your account into an organization.

Restructuring repository

Hi, I was looking for repositories I could contribute to so I discovered this one here.

I am creating this issue in order to restructure it a bit the repo and you will tell me what you think about it.

Automated tests

Is your feature request related to a problem? Please describe.
In order to validate our developments, tests are needed and if they are automated it would be the best

Describe the solution you'd like
GitHub Actions allows us to execute code on runners hosted by GitHub.

We can write some tests in a /tests folder in order to validate the whole behavior of the package by writing deterministic code and checking with assert statements.

Additional context

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.