Skip to main content

The Python SDK for Terra

Project description

About

Terra python sdk

Installation

pip install terra_sdk

Usage

1. Creating, Signing, Broadcasting tx
2. Exposes the Terra API through LCDClient

Example

  • Transfer

    from terra_sdk.core.common.coin import Coin
    from terra_sdk.client import Terra, wallet
    from terra_sdk.key.mnemonic import MnemonicKey
    from terra_sdk.core.bank import MsgSend
    
    
    LCD_URI = "http://localhost:1317"
    CHAIN_ID = "localterra"
    MNEMONIC = "satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn"
    
    # Recover key from mnemonic
    key = MnemonicKey(MNEMONIC)
    
    # terra client
    terra = Terra(chain_id=CHAIN_ID, lcd_url=LCD_URI)
    
    # get user wallet
    wallet = terra.wallet(key)
    
    # Build Msg
    send_msg = MsgSend(
        from_address=wallet.address,
        to_address="terra1dcegyrekltswvyy0xy69ydgxn9x8x32zdtapd8",
        amount=[Coin(denom="uluna", amount="100000000")],
    )
    
    # Sign tx
    signed_tx = wallet.create_and_sign_tx(send_msg, memo="Hi from Terra")
    
    # Broadcast tx
    
    resp = wallet.broadcast(signed_tx)
    
    # Print txhash
    print(resp.txhash)
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terra-sdk-0.0.2.tar.gz (38.3 kB view hashes)

Uploaded Source

Built Distribution

terra_sdk-0.0.2-py3-none-any.whl (81.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page