init static method

Future<TikiTrail> init(
  1. String publishingId,
  2. String origin,
  3. TikiIdp idp,
  4. Key key,
  5. CommonDatabase database, {
  6. int maxTransactions = 1,
  7. Duration blockInterval = const Duration(minutes: 1),
  8. String? customerAuth,
})

Returns a new initialized TikiTrail instance.

Parameters:

publishingId - Sign up for a free developer account at https://console.mytiki.com to get a Publishing ID.

origin - The default origin to use during TitleRecord creation. Follow a reverse-DNS syntax. i.e. com.myco.myapp

keyStorage - Platform-specific, encrypted, private key persistence.

id - The id mapped to the wallet's address and private keys. Private key MUST be previously registered in the provided keyStorage. Use withId.

database - Platform-specific sqlite3 implementation. Always open beforehand.

maxTransactions - The maximum number of transactions to bundle in a block. Use in combination with blockInterval. Default is 1.

blockInterval - The duration before a block is automatically created if there are any pending transactions AND the maxTransactions limit has not been reached. Use in combination with blockInterval. Default is 1 minute.

customerAuth - A customer provided Authorization Token (JWT) for use in id registration. Use customerAuth to add user identity verification. Configure in console

Implementation

static Future<TikiTrail> init(String publishingId, String origin, TikiIdp idp,
    Key key, CommonDatabase database,
    {int maxTransactions = 1,
    Duration blockInterval = const Duration(minutes: 1),
    String? customerAuth}) async {
  StorageService storageService = StorageService(key.id, idp);

  Registry registry =
      await idp.register(key.id, key.address, token: customerAuth);

  NodeService nodeService = NodeService()
    ..blockInterval = blockInterval
    ..maxTransactions = maxTransactions
    ..transactionService =
        TransactionService(database, idp, appKeyId: registry.appKeyId)
    ..blockService = BlockService(database)
    ..xChainService = XChainService(storageService, idp, database)
    ..key = key;
  nodeService.backupService = await BackupService(
          storageService, idp, database, nodeService.getBlock, key)
      .init();
  await nodeService.init();

  return TikiTrail(origin, nodeService, idp);
}