Giter VIP home page Giter VIP logo

jigu's Introduction

 

Jigu (지구)

The Python SDK for Terra.


diagram

Installation

Jigu requires Python 3.7+. Install the latest version of Jigu with pip on PyPI:

$ pip install -U jigu

Pretty Printing

Many objects in Jigu are pretty-printable by their ._pp property.

        
Python 3.7.6 (default, Dec 30 2019, 19:38:26) >>> from jigu import Terra >>> terra = Terra("columbus-3", "https://lcd.terra.dev/") >>> terra.market.params()._pp ╒═════════════════════════╤═════════════════╕ │ pool_recovery_period │ 14400 │ ├─────────────────────────┼─────────────────┤ │ base_pool │ 250000000000 │ ├─────────────────────────┼─────────────────┤ │ min_spread │ 0.02 │ ├─────────────────────────┼─────────────────┤ │ tobin_tax │ 0.0025 │ ├─────────────────────────┼─────────────────┤ │ illiquid_tobin_tax_list │ ╒══════╤══════╕ │ │ │ │ umnt │ 0.02 │ │ │ │ ╘══════╧══════╛ │ ╘═════════════════════════╧═════════════════╛

works by default in Jupyter ...

jupyter

My First Transaction

Connect to Soju testnet

Once you've installed Jigu, fire up an interactive Python shell and connect to the Soju testnet using the official Soju node provided by Terraform Labs.

from jigu import Terra

soju = Terra("soju-0013", "https://soju-lcd.terra.dev")
assert soju.is_connected()

Create an account

Before we can make any transactions, we have to have an account. Enter in the above to create an account and print its account address.

from jigu.key.mnemonic import MnemonicKey

wallet = soju.wallet(MnemonicKey.generate())
wallet.address
# terra17w4ppj92dwdf93jjtply08nav2ldzw3z2l3wzl

Top off with testnet funds

Great, now that we have an address, let's get some testnet funds. Head over to the Soju Faucet and top off some Luna.

After that's done, you should have 10,000 LUNA in your account. To confirm this, you can enter the following:

wallet.balance("uluna")
# Coin('uluna', 10000000000)

Create a transaction

Let's send 23 Testnet Luna to your friend at the following address:

terra1wg2mlrxdmnnkkykgqg4znky86nyrtc45q336yv

We'll need to create a transaction containing a MsgSend alongside a short memo (note) "Hello Jigu!" -- our version of Hello World.

from jigu.core import Coins, StdFee
from jigu.core.msg import MsgSend

send = MsgSend(
    from_address=wallet.address,
    to_address="terra1wg2mlrxdmnnkkykgqg4znky86nyrtc45q336yv",
    amount=Coins(uluna=23_000_000)
)

fee = StdFee.make(50000, uluna=1000) # include a small fee..

tx = wallet.create_and_sign_tx(send, memo="Hello Jigu!", fee=fee)
res = wallet.broadcast(tx)

See it on the blockchain

It should take around 6 seconds to finalize. If everything went well, you should get a result object with the height and TX hash after about 6 seconds.

print(f"TX Hash: {res.txhash}")
# TX Hash: 82D5440A4C4CAB5B74EE3C98CE7F755372CD92E945425A572654179A4A0EE678

Copy the TX hash and enter it on Finder, selecting the chain soju-0013.

Learn more

Check out the official documentation at https://jigu.terra.money.

License

This software is licensed under the MIT license. See LICENSE for full disclosure.

© 2020 Terraform Labs, PTE.


 

Powering the innovation of money.

jigu's People

Contributors

ouiliame avatar etienne-napoleone avatar

Watchers

James Cloos avatar  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.