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_dart: latest
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);
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
:exclamation: 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);
}
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}");
}
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 TerraRebels.
Libraries
- Client/Lcd/Api/Args/Distribution/Rewards
- Client/Lcd/Api/Args/Tx/Block/Async
- Client/Lcd/Api/Args/Tx/Block/Block
- Client/Lcd/Api/Args/Tx/Block/BlockTxBroadcastResultDataArgs
- Client/Lcd/Api/Args/Tx/Block/CreateTxOptions
- Client/Lcd/Api/Args/Tx/Block/SignerData
- Client/Lcd/Api/Args/Tx/Block/SignerOptions
- Client/Lcd/Api/Args/Tx/Block/Sync
- Client/Lcd/Api/Args/Tx/Block/TxError
- Client/Lcd/Api/Args/Tx/Block/TxResult
- Client/Lcd/Api/Args/Tx/Block/TxResultDataArgs
- Client/Lcd/Api/Args/Tx/Block/TxSuccess
- Client/Lcd/Api/authAPI
- Client/Lcd/Api/authzAPI
- Client/Lcd/Api/bankAPI
- Client/Lcd/Api/baseAPI
- Client/Lcd/Api/distributionAPI
- Client/Lcd/Api/feeGrantAPI
- Client/Lcd/Api/govAPI
- Client/Lcd/Api/Helpers/Staking/DelegationHelper
- Client/Lcd/Api/Helpers/Staking/UnbondingDelegationHelper
- Client/Lcd/Api/ibcAPI
- Client/Lcd/Api/ibcTransferAPI
- Client/Lcd/Api/marketAPI
- Client/Lcd/Api/mintAPI
- Client/Lcd/Api/oracleAPI
- Client/Lcd/Api/slashingAPI
- Client/Lcd/Api/stakingAPI
- Client/Lcd/Api/tendermintAPI
- Client/Lcd/Api/treasuryAPI
- Client/Lcd/Api/txAPI
- Client/Lcd/Api/txBroadcastApi
- Client/Lcd/Api/wasmAPI
- Client/Lcd/Constants/preconfiguredWallets
- Client/Lcd/lcdClient
- Client/Lcd/LCDDefaultConfigs
- Client/Lcd/lcdDefaultConfigs
- Client/Lcd/LocalTerra/localTerra
- Client/Lcd/Models/LCDClientConfig
- Client/Lcd/Models/lcdClientConfig
- Client/Lcd/paginationOptions
- Client/Lcd/wallet
- Core/Auth/baseAccount
- Core/authInfo
- Core/Authz/Authorizations/AuthorizationGrant
- Core/Authz/Authorizations/GenericAuthorization
- Core/Authz/Authorizations/SendAuthorization
- Core/Authz/Authorizations/StakeAuthorization
- Core/Authz/Msgs/MsgExecAuthorized
- Core/Authz/Msgs/MsgGrantAuthorization
- Core/Authz/Msgs/MsgRevokeAuthorization
- Core/Bank/Msgs/MsgMultiSend
- Core/Bank/Msgs/MsgSend
- Core/coin
- Core/compactBitArray
- Core/Constants/AccountsConstants
- Core/Constants/AuthConstants
- Core/Constants/BankConstants
- Core/Constants/CoinDenoms
- Core/Constants/CoinGasPrices
- Core/Constants/CoinTypes
- Core/Constants/CosmosConstants
- Core/Constants/CrisisConstants
- Core/Constants/DistributionConstants
- Core/Constants/FeeGrantConstants
- Core/Constants/GovConstants
- Core/Constants/IBCConstants
- Core/Constants/IBCTransferConstants
- Core/Constants/MarketConstants
- Core/Constants/MsgConstants
- Core/Constants/OracleConstants
- Core/Constants/ProposalConstants
- Core/Constants/SlashingConstants
- Core/Constants/StakingConstants
- Core/Constants/TendermintConstants
- Core/Constants/TerraConstants
- Core/Constants/TxConstants
- Core/Constants/VestingConstants
- Core/Constants/WasmConstants
- Core/Crisis/MsgVerifyInvariant
- Core/deposit
- Core/Distribution/Msgs/MsgFundCommunityPool
- Core/Distribution/Msgs/MsgSetWithdrawAddress
- Core/Distribution/Msgs/MsgWithdrawDelegatorReward
- Core/Distribution/Msgs/MsgWithdrawValidatorCommission
- Core/Distribution/Proposals/CommunityPoolSpendProposal
- Core/enums/AuthorizationGrantType
- Core/Extensions/AuthorizationExtensionsHelper
- Core/Extensions/CoinExtensions
- Core/Extensions/EventsTypeExtensions
- Core/Extensions/HashExtensionsLegacy
- Core/Extensions/PaginationOptionExtensions
- Core/Extensions/ParamChangeExtensions
- Core/Extensions/TerraStringExtensions
- Core/Fee
- Core/fee
- Core/FeeGrant/Allowances/AllowedMessageAllowance
- Core/FeeGrant/Allowances/BasicAllowance
- Core/FeeGrant/Allowances/PeriodicAllowance
- Core/FeeGrant/Msgs/MsgGrantAllowance
- Core/FeeGrant/Msgs/MsgRevokeAllowance
- Core/Gov/Msgs/MsgDeposit
- Core/Gov/Msgs/MsgVote
- Core/Gov/Msgs/MsgVoteWeighted
- Core/Gov/Proposal
- Core/Gov/Proposals/TextPropsoal
- Core/Gov/ProposalsDepositParams
- Core/Gov/ProposalsTallyParams
- Core/Gov/ProposalsVotesParams
- Core/Gov/Vote
- Core/Gov/WeightedVoteOption
- Core/IBC/Core/Channel/PacketID
- Core/IBC/Core/Commitment/MerklePrefix
- Core/IBC/Core/Commitment/MerkleRoot
- Core/IBC/Msgs/Channel/Channel
- Core/IBC/Msgs/Channel/Counterparty
- Core/IBC/Msgs/Channel/MsgAcknowledgement
- Core/IBC/Msgs/Channel/MsgChannelCloseConfirm
- Core/IBC/Msgs/Channel/MsgChannelCloseInit
- Core/IBC/Msgs/Channel/MsgChannelOpenAck
- Core/IBC/Msgs/Channel/MsgChannelOpenConfirm
- Core/IBC/Msgs/Channel/MsgChannelOpenInit
- Core/IBC/Msgs/Channel/MsgChannelOpenTry
- Core/IBC/Msgs/Channel/MsgRecvPacket
- Core/IBC/Msgs/Channel/MsgTimeout
- Core/IBC/Msgs/Channel/MsgTimeoutClose
- Core/IBC/Msgs/Channel/Packet
- Core/IBC/Msgs/Client/ClientConsensusStates
- Core/IBC/Msgs/Client/ConsensusStateWithHeight
- Core/IBC/Msgs/Client/Height
- Core/IBC/Msgs/Client/IdentifiedClient
- Core/IBC/Msgs/Client/MsgCreateClient
- Core/IBC/Msgs/Client/MsgSubmitMisbehavior
- Core/IBC/Msgs/Client/MsgUpdateClient
- Core/IBC/Msgs/Client/MsgUpgradeClient
- Core/IBC/Msgs/Client/Params
- Core/IBC/Msgs/Connection/Counterparty
- Core/IBC/Msgs/Connection/MsgConnectionOpenAck
- Core/IBC/Msgs/Connection/MsgConnectionOpenConfirm
- Core/IBC/Msgs/Connection/MsgConnectionOpenInit
- Core/IBC/Msgs/Connection/MsgConnectionOpenTry
- Core/IBC/Msgs/Connection/Version
- Core/IBC/Proposals/ClientUpdateProposal
- Core/IBCTransfer/DenomTrace
- Core/IBCTransfer/Msgs/MsgTransfer
- Core/Keys/Args/LegacyMultiSignArgs
- Core/Keys/Constants/CosmosKeys
- Core/Keys/Constants/TendermintKeys
- Core/Keys/Constants/TerraPubKeys
- Core/Keys/LegacyAminoMultisigPublicKey
- Core/Keys/SimplePublicKey
- Core/Keys/ValConsPublicKey
- Core/Market/MsgSwap
- Core/Market/MsgSwapSend
- Core/modeInfo
- Core/multiSignature
- Core/Numeric
- Core/numeric
- Core/Oracle/AggregateExchangeRatePrevote
- Core/Oracle/AggregateExchangeRateVote
- Core/Oracle/ExchangeRateTuple
- Core/Oracle/Msgs/MsgAggregateExchangeRatePrevote
- Core/Oracle/Msgs/MsgAggregateExchangeRateVote
- Core/Oracle/Msgs/MsgDelegateFeedConsent
- Core/Params/ParamChange
- Core/Params/Proposals/ParameterChangeProposal
- Core/policyConstraints
- Core/signatureV2
- Core/signatureV2Descriptor
- Core/signatureV2Multi
- Core/SignatureV2Single
- Core/signatureV2Single
- Core/signDoc
- Core/SignerInfo
- Core/signerInfo
- Core/Slashing/Msgs/MsgUnjail
- Core/Staking/Commission
- Core/Staking/CommissionRates
- Core/Staking/Delegation
- Core/Staking/Entry
- Core/Staking/Msgs/MsgBeginRedelegate
- Core/Staking/Msgs/MsgCreateValidator
- Core/Staking/Msgs/MsgDelegate
- Core/Staking/Msgs/MsgEditValidator
- Core/Staking/Msgs/MsgUndelegate
- Core/Staking/Redelegation
- Core/Staking/UnbondingDelegation
- Core/Staking/UnbondingDelegationEntry
- Core/Staking/Validator
- Core/Staking/ValidatorDescription
- Core/Treasury/PolicyConstraints
- Core/tx
- Core/txBody
- Core/txInfo
- Core/txLog
- Core/Upgrade/Plan
- Core/Upgrade/Proposals/CancelSoftwareUpgradeProposal
- Core/Upgrade/Proposals/SoftwareUpgradeProposal
- Core/validatorSet
- Core/Wasm/Msgs/MsgClearContractAdmin
- Core/Wasm/Msgs/MsgExecuteContract
- Core/Wasm/Msgs/MsgInstantiateContract
- Core/Wasm/Msgs/MsgMigrateCode
- Core/Wasm/Msgs/MsgMigrateContract
- Core/Wasm/Msgs/MsgStoreCode
- Core/Wasm/Msgs/MsgUpdateContractAdmin
- Key/CLIKey
- Key/Key
- Key/mnemonicKey
- Key/SignOptions
- terra_dart
- Support for doing something awesome.
- terraEnvironment
- TerraStartup
- terraStartup