terra_sdk

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

terra sdk

The Official Dart SDK for the Terra Ecosystem (LUNC/USTC/LUNA2)














Explore the Docs »


Example App
·
API Reference
·
Pub Package
·
GitHub

TerraDart is a Dart SDK for writing applications that interact with the Terra blockchain from either the Web or Mobile, or flutter environments and provides simple abstractions over core data structures, serialization, key management, and API request generation.
Features #

Written in Dart, with type definitions
Versatile support for key management solutions
Works with the Flutter Ecosystem, in the browser, and Mobile
Exposes the Terra API through LCDClient
Parses responses into native Dart types

We highly suggest using TerraDart in a code editor that has support for type declarations, so you can take advantage of the helpful type hints that are included with the package.
Installation & Configuration #
Grab the latest version off pub.dev
terra_sdk: latest
copied to clipboard
Inside your Startup Class (Where you initialize your application), please call the following method, and configure your environment
// Here we're targeting the Classic Blockchain
TerraStartup.initializeKernel(TerraEnvironment.classic);
copied to clipboard
That's it! Now you're ready to start communicating with the blockchain!
Usage #
TerraDart can be used for Mobile & Web Developers. Supports all Flutter & Dart Environments.
Getting Blockchain data #
❗ TerraDart can connect to both the terra-classic (LUNC/USTC) and LUNA2 networks. If you want to communicate with the classic chain, you have to set your Enviornment on TerraStartup.InitializeKernel to TerraEnvironment.Classic.
Below we're going to pull balance information on a sample wallet.
void fetchBalanceInformation() async {

//fetch the LCDClient from the Kernel
var lcd = TerraStartup.getLCDClient();

// get the current balance of "terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v"
var balance = await lcd.bank.getBalance("terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v");
print(balance);
}
copied to clipboard
Broadcasting transactions #
First, get some testnet tokens for "terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v", or use LocalTerra.
void broadcastTransaction() async {

//fetch the LCDClient from the Kernel
var lcd = TerraStartup.getLCDClient();

// create a key out of a mnemonic
var mk = MnemonicKey("notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius");

// create a simple message that moves coin balances
var send = MsgSend(
"terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v",
"terra17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp",
new List<Core.Coin>() { new Core.Coin(CoinDenoms.ULUNA, 20) }
);

// Prepare & Configure your wallet
var wallet = lcd.createWallet(PreconfiguredWallets.TEST_NET_WALLET, mk);

// Prepare Transaction for Upload
var tx = await wallet.createTxAndSignTx([send])

// Broadcast the transaction
var broadcast = await wallet.broadcastTx.broadcast(tx);
print("Uploaded Tx Hash ${broadcast.txhash}");
}
copied to clipboard
Require Payment Integration for LUNC/USTC? #
If you need to integrate with an external payment system or gateway like Apple/Google in app purchases, please make sure to install the following library in your project.
License #
This software is licensed under the MIT license. See LICENSE for full disclosure.
© 2022 TerraMystics.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.