Client #

The Dart client is available from Heroic Labs. Contact us to request access.

Once you have received the client:

  1. Add it into your Dart project’s lib folder.
  2. Import it into your project import 'hiro-client.dart';
Import Nakama
Don’t forget to also import Nakama using import 'package:nakama/nakama.dart';

Setting up your initial script to run Hiro #

Define the global variables:

1
2
3
late final NakamaRestApiClient _nakamaAPIClient;
late final HiroClient hiro;
Session? session;

Initialize the Nakama RestAPI Client

1
2
3
4
5
6
7
const String host = "127.0.0.1";
const String serverKey = "defaultkey";

_nakamaAPIClient = NakamaRestApiClient.init(host: host, serverKey: serverKey, ssl: false);


hiro = HiroClient(_nakamaAPIClient);

To start making RPC calls, authenticate the client:

1
2
3
4
5
session = await _nakamaAPIClient.authenticateEmail(
        email: 'test@example.com',
        password: 'password123',
        create: true
      );

You are now able to use the Hiro Client, for example, to make an Economy Grant:

1
2
3
4
5
6
var request = EconomyGrantRequest();
      request.currencies = {
          "coins": "100"
      };

var grant = await hiro.economyGrant(session!, request);