Welcome to Polkadart
Seamlessly develop multiplatform blockchain apps using Dart and Flutter for the innovative Polkadot ecosystem.
import 'package:polkadart/polkadart.dart';
void main() async {
final uri = Uri.parse('wss://rpc.polkadot.io');
final provider = Provider.fromUri(uri);
final stateApi = StateApi(provider);
final runtimeVersion = await stateApi.getRuntimeVersion();
print(runtimeVersion.toJson());
}
Polkadart is a powerful Dart library designed for developers looking to build decentralized applications (dApps) on Polkadot. It leverages the capabilities of Dart and the robust architecture of Polkadot for seamless development of blockchain applications.
Concentrate on what truly counts with user-friendly tools that simplify the development lifecycle.
Eliminate type-related issues with type-secure APIs that ensure stability and precision in your projects.
Develop applications that operate smoothly across mobile, web, and desktop platforms utilizing a singular codebase.
Experience improved performance without excessive load, making it ideal for environments with limited resources.
Effortlessly deploy and interact with ink! smart contracts, enhancing the functionality of your dApps.
Access thorough guides, tutorials, and API documentation to empower you in your development journey.
Advantages of Using Dart and Polkadot
By combining Dart's straightforward syntax and Polkadot's innovative features, developers can create high-performance dapps that stand out in the blockchain ecosystem.
Polkadart is designed with a developer-centric philosophy, providing robust tools and utilities that enhance productivity and streamline the workflow.
import 'package:demo/generated/polkadot/polkadot.dart'; import 'package:polkadart/polkadart.dart' show Provider; Future<void> main(List<String> arguments) async { final provider = Provider.fromUri(Uri.parse('wss://rpc.polkadot.io')); final polkadot = Polkadot(provider); final runtime = await polkadot.rpc.state.getRuntimeVersion(); print(runtime.toJson()); }
import 'package:polkadart_keyring/polkadart_keyring.dart'; Future<void> main(List<String> arguments) async { final keyring = Keyring(); final keyPair = await keyring.fromUri('//Alice'); print('Alice address: ${keyPair.address}'); }
Polkadart ensures your application remains aligned with runtime modifications, featuring auto-generated types and compile-time error detection for intelligent debugging.
dart pub add polkadart polkadart_cli
polkadart: output_dir: lib/generated chains: polkadot: wss://rpc.polkadot.io
dart run polkadart_cli:generate -v
import 'package:polkadart/polkadart.dart'; import 'package:ss58/ss58.dart'; import './generated/polkadot/polkadot.dart'; import './generated/polkadot/types/frame_system/account_info.dart'; Future<void> main(List<String> arguments) async { final address = '1zugcag7cJVBtVRnFxv5Qftn7xKAnR6YJ9x4x3XLgGgmNnS'; final provider = Provider.fromUri(Uri.parse('wss://rpc.polkadot.io')); final api = Polkadot(provider); Address wallet = Address.decode(address); AccountInfo accountInfo = await api.query.system.account(wallet.pubkey); print(""" Free balance: ${accountInfo.data.free} Reserved balance: ${accountInfo.data.reserved} Nonce: ${accountInfo.nonce} """); }
Polkadart functions flawlessly with Polkadot, Kusama, and any blockchain developed using the Polkadot-SDK, adapting to chain-specific functionalities while maintaining a cohesive interface.
import 'package:polkadart/provider.dart'; import './generated/assethub/assethub.dart'; import './generated/people/people.dart'; import './generated/polkadot/polkadot.dart'; Future<void> main(List<String> arguments) async { final polkadot = Polkadot(Provider.fromUri(Uri.parse('wss://rpc.polkadot.io'))); final people = People(Provider.fromUri(Uri.parse('wss://polkadot-people-rpc.polkadot.io'))); final assetHub = Assethub(Provider.fromUri(Uri.parse('wss://polkadot-asset-hub-rpc.polkadot.io'))); print('${await polkadot.query.session.validators()}'); print('${await people.query.identity.registrars()}'); print('${await assetHub.query.assets.nextAssetId()}'); }
Learn how to deploy and interact with ink! smart contracts through Polkadart, enhancing the capabilities of your decentralized applications.
import 'dart:typed_data'; import 'package:polkadart/polkadart.dart'; import 'generated_flipper.dart'; Future<void> main(List<String> arguments) async { final contract = Address.decode('5DXR2MxThkyZvG3s4ubu9yRdNiifchZ9eNV8i6ErGx6u1sea') final provider = Provider.fromUri(Uri.parse('ws://127.0.0.1')); final contract = Contract( provider: provider, address: contract.pubkey, ); // Call the get method print('Get value: ${await contract.get()}'); }
Create responsive applications that adapt seamlessly across mobile, tablet, and desktop. Our framework provides built-in utilities to help you create the perfect layout for every device.
import 'package:flutter/material.dart';
import 'package:polkadart_keyring/polkadart_keyring.dart';
class PolkadotApp extends StatefulWidget {
const PolkadotApp({super.key});
@override
State<PolkadotApp> createState() => _PolkadotAppState();
}
class _PolkadotAppState extends State<PolkadotApp> {
final keyring = Keyring();
List<Account> accounts = [];
generateNewAccount() async {
final derivationPath =
'//Alice${accounts.isNotEmpty ? '//${accounts.length}' : ''}';
final wallet = await keyring.fromUri(derivationPath, addToPairs: true);
final account = Account(wallet.address, derivationPath);
setState(() {
accounts.add(account);
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: MaterialColor(0xFFFF2670, <int, Color>{
50: polkadotPink,
100: polkadotPink,
200: polkadotPink,
300: polkadotPink,
400: polkadotPink,
500: polkadotPink,
600: polkadotPink,
700: polkadotPink,
800: polkadotPink,
900: polkadotPink,
}),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: polkadotPink,
textStyle: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
),
home: Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 3),
child: Text('Generate wallets by clicking on the button'),
),
Divider(),
Expanded(
child: ListView.builder(
itemCount: accounts.length,
itemBuilder: (BuildContext context, int index) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
minTileHeight: 10,
enabled: true,
title: Text(
accounts[index].encodedAddress,
style: const TextStyle(fontSize: 13),
),
subtitle: Text(
accounts[index].derivationPath,
style: TextStyle(fontSize: 10),
),
),
const Divider(),
],
);
},
),
),
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: ElevatedButton(
onPressed: () async => await generateNewAccount(),
child: const Text('Generate a new account'),
),
),
],
),
),
);
}
}
class Account {
final String encodedAddress;
final String derivationPath;
Account(this.encodedAddress, this.derivationPath);
}
Color polkadotPink = const Color(0xFFFF2670);
void main() {
runApp(const PolkadotApp());
}
Kickstart your development journey with Polkadart and explore the benefits of building dApps on Polkadot
Dive into the official documentation or visit our GitHub to contribute.