ATOM
  • About ATOM Network
    • Introduction
    • Tokenomics
    • Roadmap
  • ATOM Blockchain - EVM * Cosmos
    • Introduction
    • Join Mainnet
    • Create Localnet
    • Gas & Fees
    • Manage Validators
      • Validators Overview
      • Run Validator on Mainnet
      • Validator FAQ
      • Validator Security
  • Development
    • Getting Started
    • Development Libraries
      • IONIC
      • IONICDart
Powered by GitBook
On this page
  • Introduction
  • Getting started
  • Send your first transaction from Dart
  1. Development
  2. Development Libraries

IONICDart

Introduction

IONIC is a pure Dart package allowing you to easily integrate your Dart-based project with the IONIC Network blockchain.

Getting started

To start using this library inside your project, just edit your pubspec.yml file, adding the following lines:

dependencies:  IONIC: "<version>"

You can even use a specific GitHub tag or branch if you want:

dependencies:  IONIC:    git:      url: "git://github.com/IONICNetwork/ionic.dart.git"      ref: "<branch or tag>"

Send your first transaction from Dart

import 'package:ionic/ionic.dart';import 'package:ionic/proto/cosmos/bank/v1beta1/export.dart' as bank; final networkInfo = NetworkInfo.fromSingleHost(  bech32Hrp: 'ionic',  host: 'https://grpc.my_ionic_grpc_node',  httpHost: 'https://lcd.my_ionic_lcd_node',  grpcPort: 9090,  httpPort: 1317,);final mnemonic = 'federal injury annual melt near scan daughter before nut catalog spend decade';final wallet = HdWallet.fromMnemonic(  mnemonic,  prefix: networkInfo.bech32Hrp,); final recipient = '0x70207819eC28FB8cc692A4327C80282006E6476A';final message = bank.MsgSend.create()  ..fromAddress = wallet.accounts[0].bech32Address  ..toAddress = hexToBech32Address(      networkInfo.bech32Hrp, recipient)  ..amount.add(Coin.create()    ..denom = 'attoionic'    ..amount = '1000000000000000000');final fee = Fee()  ..gasLimit = 200000.toInt64()  ..amount.add(Coin.create()    ..denom = 'attoionic'    ..amount = '200000000000000'); final signer = TxSigner.fromNetworkInfo(networkInfo);final tx = await signer.createAndSign(    wallet, wallet.accounts[0].bech32Address, [message],    fee: fee); final txSender = TxSender.fromNetworkInfo(networkInfo);final response =    await txSender.broadcastTx(tx, mode: BroadcastMode.BROADCAST_MODE_BLOCK); if (response.isSuccessful) {  print('Tx sent successfully. Response: ${response}');} else {  print('Tx errored: ${response}');}
PreviousIONIC

Last updated 1 year ago