Skip to content

Getting Started with ink! Smart Contracts

The Polkadart ink! packages provide tools for interacting with ink! smart contracts from Dart and Flutter applications. You can use these packages to parse contract metadata, generate type-safe bindings, deploy contracts and interact with them.

Installation

Add the following to your pubspec.yaml file:

pubspec.yaml
dependencies:
ink_abi: any
ink_cli: any

Get the dependencies by running:

Terminal window
dart pub get

Sample usage

demo.dart
import 'dart:convert';
import 'dart:io';
import 'package:ink_abi/ink_abi.dart';
import 'package:ink_cli/ink_cli.dart';
Future<void> main() async {
// Parse contract metadata
final json = jsonDecode(File('flipper.json').readAsStringSync());
final abi = InkAbi(json);
// Generate Dart bindings
final generator = TypeGenerator(
abiFilePath: 'flipper.json',
fileOutput: FileOutput('generated_flipper.dart')
);
generator.generate();
print('Contract ABI loaded and bindings generated');
}

This will load the Flipper contract metadata and generate type-safe Dart bindings for interacting with the contract.

The ink! packages allow you to work with smart contracts in a type-safe way, making contract interactions more reliable and maintainable.