archethic_messaging_lib_dart 0.0.13 copy "archethic_messaging_lib_dart: ^0.0.13" to clipboard
archethic_messaging_lib_dart: ^0.0.13 copied to clipboard

Archethic dart library for Flutter for Node and Browser. This library aims to provide a easy way to manage Archethic Messaging Features

CI Pub Platform

Archethic's Messaging Dart SDK #

Archethic Messaging SDK developped on Dart

Usage #

This library aims to provide a easy way to manage a decentralized messaging platform on the Archethic Public Blockchain. With the help of a smart contract, you can manage discussions and associated messages.

API #

All API are available in messaging_service.dart file.

Installation #

To use the MessagingService class, you should include the archethic_lib_dart and archethic_messaging_lib_dart packages in your Dart project. Add the following dependencies to your pubspec.yaml file:


dependencies:
  archethic_lib_dart: ^<version>
  archethic_messaging_lib_dart: ^<version>

Initialization #


import 'package:archethic_lib_dart/archethic_lib_dart.dart' as archethic;
import 'package:archethic_messaging_lib_dart/archethic_messaging_lib_dart';

void main() {
  // Initialize your keychain and API service as needed.
  archethic.Keychain keychain = ...; // Initialize your keychain
  archethic.ApiService apiService = ...; // Initialize your API service

  // Create an instance of MessagingService
  MessagingService messagingService = MessagingService(
    logsActivation: true, // Set to true to enable logging
  );
}

Discussion #

Create a New Discussion

Creates a new discussion on the blockchain.

Future<({
  archethic.Transaction transaction,
  archethic.KeyPair previousKeyPair
})> createDiscussion({
  required archethic.Keychain keychain,
  required archethic.ApiService apiService,
  required List<String> membersPubKey,
  required String discussionName,
  required List<String> adminsPubKey,
  required String adminAddress,
  required String serviceName,
})

Parameters:

  • keychain: Keychain used to send transactions to the blockchain.
  • apiService: API service with blockchain integration.
  • membersPubKey: List of public keys of all discussion members.
  • discussionName: Name of the discussion.
  • adminsPubKey: List of public keys of all discussion administrators.
  • adminAddress: Address of the admin who wants to add members (provisions the SC's chain to manage fees).
  • serviceName: Service name in the current keychain (admin).
  • Returns a future with transaction and previous key pair information.

Update an Existing Discussion

Updates an existing discussion on the blockchain.

Future<({
  archethic.Transaction transaction,
  archethic.KeyPair previousKeyPair
})> updateDiscussion({
  required archethic.Keychain keychain,
  required archethic.ApiService apiService,
  required String discussionSCAddress,
  required List<String> membersPubKey,
  required String discussionName,
  required List<String> adminsPubKey,
  required String adminAddress,
  required String serviceName,
  required archethic.KeyPair adminKeyPair,
  bool updateSCAESKey = false,
})

Parameters:

  • keychain: Keychain used to send transactions to the blockchain.
  • apiService: API service with blockchain integration.
  • membersPubKey: List of public keys of all discussion members.
  • discussionName: Name of the discussion.
  • adminsPubKey: List of public keys of all discussion administrators.
  • adminAddress: Address of the admin who wants to add members (provisions the SC's chain to manage fees).
  • serviceName: Service name in the current keychain (admin).
  • Returns a future with transaction and previous key pair information.

Update an Existing Discussion

Updates an existing discussion on the blockchain.

Future<({
  archethic.Transaction transaction,
  archethic.KeyPair previousKeyPair
})> updateDiscussion({
  required archethic.Keychain keychain,
  required archethic.ApiService apiService,
  required String discussionSCAddress,
  required List<String> membersPubKey,
  required String discussionName,
  required List<String> adminsPubKey,
  required String adminAddress,
  required String serviceName,
  required archethic.KeyPair adminKeyPair,
  bool updateSCAESKey = false,
})

Parameters:

  • keychain: Keychain used to send transactions to the blockchain.
  • apiService: API service with blockchain integration.
  • discussionSCAddress: Smart contract's address for the discussion.
  • membersPubKey: List of public keys of all discussion members.
  • discussionName: Name of the discussion.
  • adminsPubKey: List of public keys of all discussion administrators.
  • adminAddress: Address of the admin who wants to add members (provisions the SC's chain to manage fees).
  • serviceName: Service name in the current keychain (admin).
  • adminKeyPair: Key pair of the admin.
  • updateSCAESKey: Update the AES key if set to true.
  • Returns a future with transaction and previous key pair information.

Get a Discussion

Retrieves a discussion from its address on the blockchain.

Future<AEDiscussion?> getDiscussion({
  required archethic.ApiService apiService,
  required String discussionSCAddress,
  required archethic.KeyPair keyPair,
})

Parameters:

  • apiService: API service with blockchain integration.
  • discussionSCAddress: Smart contract's address for the discussion.
  • keyPair: Key pair of the requester to check if the discussion's content can be decrypted.
  • Returns an AEDiscussion object or null if not found.

Get the last properties of a discussion

Future<String> getDiscussionLastProperties({
    required archethic.ApiService apiService,
    required String discussionSCAddress,
    required archethic.KeyPair readerKeyPair,
  })

Parameters:

  • apiService: API service with blockchain integration.
  • discussionSCAddress: Smart contract's address for the discussion.
  • readerKeyPair: Key pair of the reader to check if the discussion's content can be decrypted.

Messages #

Read Messages in Existing Discussion

Reads messages in an existing discussion on the blockchain.

Future<List<AEMessage>> readMessages({
  required archethic.ApiService apiService,
  required String discussionSCAddress,
  required archethic.KeyPair readerKeyPair,
  int limit = 0,
  int pagingOffset = 0,
})

Parameters:

  • apiService: API service with blockchain integration.
  • discussionSCAddress: Smart contract's address for the discussion.
  • readerKeyPair: Key pair of the reader.
  • limit: Limit the number of messages to retrieve (default is 0, which retrieves all).
  • pagingOffset: Offset for paging through messages.
  • Returns a list of AEMessage objects.

Send Messages in Existing Discussion

Sends a message in an existing discussion on the blockchain.

Future<({
  archethic.Address transactionAddress,
  archethic.KeyPair previousKeyPair
})> sendMessage({
  required archethic.Keychain keychain,
  required archethic.ApiService apiService,
  required String discussionSCAddress,
  required String messageContent,
  required String senderAddress,
  required String senderServiceName,
  required archethic.KeyPair senderKeyPair,
})

Parameters:

  • keychain: Keychain used to send transactions to the blockchain.
  • apiService: API service with blockchain integration.
  • discussionSCAddress: Smart contract's address for the discussion.
  • messageContent: Content of the message (not encrypted).
  • senderAddress: Address of the member who wants to send the message.
  • senderServiceName: Service name in the current keychain (sender).
  • senderKeyPair: Key pair of the sender.
  • Returns a future with transaction address and previous key pair information.

Build a message

  Future<({
        archethic.Transaction transaction,
        archethic.KeyPair previousKeyPair
      })> buildMessage({
    required archethic.Keychain keychain,
    required archethic.ApiService apiService,
    required String discussionSCAddress,
    required String messageContent,
    required String senderAddress,
    required String senderServiceName,
    required archethic.KeyPair senderKeyPair,
  })

Parameters:

  • keychain: Keychain used to send transactions to the blockchain.
  • apiService: API service with blockchain integration.
  • discussionSCAddress: Smart contract's address for the discussion.
  • messageContent: Content of the message (not encrypted).
  • senderAddress: Address of the member who wants to send the message.
  • senderServiceName: Service name in the current keychain (sender).
  • senderKeyPair: Key pair of the sender.
  • Returns a future with transaction address and previous key pair information.

Running the tests #

dart test --exclude-tags noCI
0
likes
80
pub points
62%
popularity

Publisher

verified publisherarchethic.net

Archethic dart library for Flutter for Node and Browser. This library aims to provide a easy way to manage Archethic Messaging Features

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

AGPL-3.0 (LICENSE)

Dependencies

archethic_lib_dart, archive, freezed_annotation

More

Packages that depend on archethic_messaging_lib_dart