massa

pub.dev Stars Issues MIT License

Massa is a public blockchain and protocol that aims to deliver decentralization, scale and security for many people. It uses PROOF OF STAKE consensus mechanism to ensures full participation, protection, and high transaction throughput.

Introduction

Massa-dart is an SDK that is able to connect your Dart and Flutter applications to the Massa blockchain, create wallet, send transactions, and work with smart contracts.

Features

This package will allows you to interact with massa blockchain using the folloiwng public and privated grpc and jsonrpc methods.

GRPC Public API (node_ip:33037)

  • x executeReadOnlyCall
  • x getBlocks
  • x getDataStoreEntries
  • x getNextBlockBestParents
  • x getOperations
  • x getScExecutionEvents
  • x getSelectorDraw
  • x getStakers
  • x getStatus
  • x getTransactionThroughput
  • x queryState
  • x newBlocks
  • x newEndorsements
  • x newFilledBlocks
  • x newOperations
  • x newSlotExecutionOutputs
  • x sendBlocks
  • x sendEndorsements
  • x sendOperations
  • x transactionThroughput

GRPC Private API (node_ip:33038)

  • x addToBootstrapBlacklist
  • x addToBootstrapWhitelist
  • x addToPeersWhitelist
  • x addStakingSecretKeys
  • x allowEveryoneToBootstrap
  • x banNodesByIds
  • x banNodesByIps
  • x getBootstrapBlacklist
  • x getBootstrapWhitelist
  • x getMipStatus
  • x getNodeStatus
  • x getPeersWhitelist
  • x removeFromBootstrapBlacklist
  • x removeFromBootstrapWhitelist
  • x removeFromPeersWhitelist
  • x removeStakingAddresses
  • x signMessages
  • x shutdownGracefully
  • x unbanNodesByIds
  • x unbanNodesByIps

JSONRPC Public API (node_ip:33035)

  • execute_read_only_bytecode
  • execute_read_only_call
  • x get_addresses
  • x get_blocks
  • x get_blockclique_block_by_slot
  • x get_cliques
  • get_datastore_entries
  • get_datastore_entry
  • x get_endorsements
  • get_filtered_sc_output_event
  • x get_graph_interval
  • x get_operations
  • x get_stakers
  • x get_status
  • x send_operations - send transaction
  • x send_operations - buy rolls
  • x send_operations - sell rolls
  • x send_operations - execute smart contract
  • send_operations - call smart contract

Getting started

Check usage in /example folder to test some examples: To run the examples, follow the following steps:

  1. Navigate to the example folder and open constants.dart.
  2. Replace grpc address and port, e.g address: test.massa.net', grpc port: 33037. Note this information may be changed as Massa Blockchain Technology development progresses. Check the correct information on Massa Documentation Website. Further note that, testnet or buildernet must be active for some examples to work, depending on your grpc configuration.
  3. Generate private key and address using Massa Station, Bearby, or by running the test in the section below. Please do not use your massa mainnet address for testing purposes.
  4. Request test tokens from massa discord server.
  5. To run a specific example, navigate to the given folder, and run the command dart run example_filename.dart

NOTE that all examples are tested and working with MASSA DEVNET 27.3.

Testing

To run the test cases, navigate to the project root folder and run dart test You need to have flutter/dart sdk installed in your machine. Please note that for grpc test, you need to configure grpc address and port. For some test, e.g getOperation test, you need to provide correct operation. Without proding correct information, grpc test will likely fail.

Usage

View more examples in /example folder.

NOTE: For smart contract examples, all the smart contracts are already deployed on the buildnet, so you do not need to deploy them.

The example below shows how to get list of stakers

import 'package:massa/massa.dart';

Future<void> main() async {
  const ipAddress = 'buildnet.massa.net';
  const port = 33037;
  var grpc = GRPCPublicClient(ipAddress, port);
  final stakers = await grpc.getStakers(limit: Int64(10));
  if (stakers.isEmpty) {
    print('No stakers found');
    return;
  }

  final totalAddresses = stakers.length;
  Int64 totalRolls = Int64(0);
  for (var staker in stakers) {
    print('${staker.address}:${staker.rolls}');
    totalRolls += staker.rolls;
  }
  print('Total addresses: $totalAddresses');
  print('Total rolls: $totalRolls');
  await grpc.shutDown();
}

Additional information

You can get more information about massa by visiting the links below.

Support

This project is supported by massa

Contribute

You can contribute to this package, request new features or report any bug by visiting the package repository at massa-dart

License

The MIT License (MIT). Please see License File for more information.

Libraries

massa