LCDClient

The LCDClient is an object representing a HTTP connection to a Terra LCD node.

Get connected

Create a new LCDClient instance by specifying the URL and chain ID of the node to connect to.

Note

It is common practice to name the active LCDClient instance terra, but this is not required.

>>> from terra_sdk.client.lcd import LCDClient
>>> terra = LCDClient(url="https://lcd.terra.dev", chain_id="columbus-5")
>>> terra.tendermint.node_info()['default_node_info']['network']
'columbus-5'

You can also specify gas estimation parameters for your chain for building transactions.

import requests
from terra_sdk.core import Coins

res = requests.get("https://fcd.terra.dev/v1/txs/gas_prices")
terra = LCDClient(
    url="https://lcd.terra.dev",
    chain_id="columbus-5",
    gas_prices=Coins(res.json()),
    gas_adjustment="1.4"
)

Using the module APIs

LCDClient includes functions for interacting with each of the core modules (see sidebar). These functions are divided and and organized by module name (eg. terra.market), and handle the tedium of building HTTP requests, parsing the results, and handling errors.

Each request fetches live data from the blockchain:

>>> terra.market.parameters()
{'base_pool': '7000000000000.000000000000000000', 'pool_recovery_period': '200', 'min_spread': '0.005000000000000000'}

The height of the last result (if applicable) is available:

>>> terra.last_request_height
89292

Create a wallet

LCDClient can create a Wallet object from any Key implementation. Wallet objects are useful for easily creating and signing transactions.

>>> from terra_sdk.key.mnemonic import MnemonicKey
>>> mk = MnemonicKey()
>>> wallet = terra.wallet(mk)
>>> wallet.account_number()
27

LCDClient Reference

class terra_sdk.client.lcd.LCDClient(url, chain_id=None, gas_prices=None, gas_adjustment=None)[source]

An object representing a connection to a node running the Terra LCD server.

auth: terra_sdk.client.lcd.api.auth.AuthAPI

AuthAPI.

authz: terra_sdk.client.lcd.api.authz.AuthzAPI

AuthzAPI.

bank: terra_sdk.client.lcd.api.bank.BankAPI

BankAPI.

chain_id: str

Chain ID of blockchain network connecting to.

distribution: terra_sdk.client.lcd.api.distribution.DistributionAPI

DistributionAPI.

feegrant: terra_sdk.client.lcd.api.feegrant.FeeGrantAPI

FeeGrant.

gas_adjustment: Union[str, float, int, terra_sdk.core.numeric.Dec]

Gas adjustment factor for automatic fee estimation.

gas_prices: Union[Iterable[terra_sdk.core.coin.Coin], str, Dict[str, Union[str, int, float, decimal.Decimal, terra_sdk.core.numeric.Dec]], Dict[str, terra_sdk.core.coin.Coin]]

Gas prices to use for automatic fee estimation.

gov: terra_sdk.client.lcd.api.gov.GovAPI

GovAPI.

ibc: terra_sdk.client.lcd.api.ibc.IbcAPI

IbcAPI.

ibc_transfer: terra_sdk.client.lcd.api.ibc_transfer.IbcTransferAPI

IbcTransferAPI.

last_request_height: Optional[int]

Height of response of last-made made LCD request.

market: terra_sdk.client.lcd.api.market.MarketAPI

MarketAPI.

mint: terra_sdk.client.lcd.api.mint.MintAPI

MintAPI.

oracle: terra_sdk.client.lcd.api.oracle.OracleAPI

OracleAPI.

slashing: terra_sdk.client.lcd.api.slashing.SlashingAPI

SlashingAPI.

staking: terra_sdk.client.lcd.api.staking.StakingAPI

StakingAPI.

tendermint: terra_sdk.client.lcd.api.tendermint.TendermintAPI

TendermintAPI.

treasury: terra_sdk.client.lcd.api.treasury.TreasuryAPI

TreasuryAPI.

tx: terra_sdk.client.lcd.api.tx.TxAPI

TxAPI.

url: str

URL endpoint of LCD server.

wallet(key)[source]

Creates a Wallet object from a key for easy transaction creating and signing.

Parameters

key (Key) – key implementation

Return type

Wallet

wasm: terra_sdk.client.lcd.api.wasm.WasmAPI

WasmAPI.