vatom_wallet_sdk 0.0.1 copy "vatom_wallet_sdk: ^0.0.1" to clipboard
vatom_wallet_sdk: ^0.0.1 copied to clipboard

outdated

Vatom Wallet SDK for flutter.

Vatom™ Flutter Sdk #

Welcome to the SDK to embed the Vatom™ Wallet in Flutter Apps, a powerful tool designed to effortlessly integrate the Vatom™ "w"allet functions directly into your Flutter applications.

This SDK allows you to easily and efficiently incorporate digital asset management into your application, providing your users with a comprehensive experience.

Installation #

pub install vatomWallet

  flutter pub add vatom_wallet_sdk

Usage/Examples #

Integrating our SDK for embedding the Vatom™ Wallet in Flutter projects is both simple and powerful. Initialize the wallet with just a few steps and empower users to effortlessly conduct transactions.

Explore code examples and guides in our documentation to unlock the full potential of financial management capabilities. Elevate your Flutter application to new heights with intuitive and secure wallet features.

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:vatom_wallet_sdk/vatom_wallet_sdk.dart';

main() {

  // Create VatomConfig instance
  final VatomConfig vatomConfig = VatomConfig(
    baseUrl: "your_base_url_here",
    features: VatomConfigFeatures(
      scanner: ScannerFeatures(enabled: false),
      vatom: VatomFeatures(
        hideTokenActions: true,
        disableNewTokenToast: true,
      ),
    ),
  );

  // Create VatomWallet instance
  final VatomWallet wallet = VatomWallet(
    accessToken:"your_access_token_here",
    businessId: "your_business_id_here",
    config: vatomConfig,
  );

  // Use the wallet instance as needed
  // Example: Print the base URL
  print("Base URL: ${wallet.config?.baseUrl}");

  runApp(
    MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Column(
            children: [
              Expanded(
                child: wallet,
              ),

            ],
          ),
        ),
      ),
    ),
  );
}

To effortlessly access SDK methods and properties, you can simply use GlobalKey<VatomWalletState>. When integrated as a widget parameter, establishes a direct and efficient connection with the essential functions of the SDK, providing complete control without complications.

  final vatomKey = GlobalKey<VatomWalletState>();
  final VatomWallet wallet = VatomWallet(
    key: vatomKey,
    accessToken: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpX...",
    businessId: "nQwt...",
  );

  ...

  var user await vatomKey.currentState?.getCurrentUser();

The navigateToTab function allows navigation to a specific tab in the application, providing a tab route and optional parameters.

  await vatomKey.currentState?.navigateToTab("Connect", {"paramKey": "paramValue"});

Parameters #

  • tabRoute (String): The route of the tab to navigate to.
  • params (Map<String, dynamic>, optional): Additional parameters that can be passed to the tab.

Example #

try {
  await vatomKey.currentState?.navigateToTab("Connect", {"paramKey": "paramValue"});
} catch (e) {
  print("Error: $e");
}

getTabs() #

The getTabs function retrieves a list of available tabs for the current business.

List tabs = await vatomKey.currentState?.getTabs();

Return Value #

  • A List of available tabs for the current business.
 [Wallet, Map, Connect]

Example #

try {
  List tabs = await vatomKey.currentState?.getTabs();
  print("Available Tabs: $tabs");
} catch (e) {
  print("Error: $e");
}

performAction() #

The performAction function is intended to be called by the host application to initiate a specific action on a token within the wallet SDK.

Parameters: #

  • tokenId (String): The unique identifier of the token on which the action will be performed.
  • actionName (String): The name of the action to be executed on the token.
  • payload (Object?): An optional payload containing additional data required for the specified action. It can be null if no additional data is needed.

Returns: #

  • Future: A Future representing the result of the action. The host application can await this Future to handle the outcome of the performed action.

Usage: #

await vatomKey.currentState?.performAction('tokenId123', 'activate', {'param': 'value'});

trashToken() #

The trashToken function is designed to be called by the host application to initiate the removal or deletion of a specific token within the wallet SDK.

Parameters: #

  • tokenId (String): The unique identifier of the token to be trashed or deleted.

Usage: #

await vatomKey.currentState?.trashToken('tokenId123');

getToken() #

The getToken function is intended to be called by the host application to retrieve information about a specific token within the wallet SDK.

Parameters: #

  • tokenId (String): The unique identifier of the token for which information is requested.

Returns: #

{
  "id":"320ca...",
  "type":"vatom",
  "parentId":".",
  "owner":"b02...",
  "author":"739f...",
  "lastOwner":"739f..."
  "modified":1697142415000,
  "shouldShowNotification":true,
  "created":1695758987000,
  ...
}

Usage: #

var tokenInfo = await vatomKey.currentState?.getToken('tokenId123');

getPublicToken() #

The getPublicToken function is designed to be called by the host application to retrieve public information about a specific token within the wallet SDK.

Parameters: #

  • tokenId (String): The unique identifier of the token for which public information is requested.

Returns: #

{
  "id":"320ca...",
  "type":"vatom",
  "parentId":".",
  "owner":"b02...",
  "author":"739f...",
  "lastOwner":"739f..."
  "modified":1697142415000,
  "shouldShowNotification":true,
  "created":1695758987000,
  ...
}

Usage: #

var publicTokenInfo = await vatomKey.currentState?.getPublicToken('tokenId123');

listTokens() #

The listTokens function is intended to be called by the host application to retrieve a list of tokens owned by the user within the wallet SDK.

Usage: #

var userTokens = await listTokens();

isLoggedIn() #

The isLoggedIn function allows the host application to check whether the user is currently logged in to the wallet SDK.

Usage: #

var userLoggedIn = await vatomKey.currentState?.isLoggedIn();
if (userLoggedIn) {
  // User is logged in, perform actions accordingly.
} else {
  // User is not logged in, handle the scenario appropriately.
}

getCurrentUser() #

The getCurrentUser function is used to retrieve the current user's data from the wallet SDK. It sends a message to the wallet SDK to fetch the user data and returns a Future containing a UserData object.

Returns: #

{
  "default_business_id": "3D...",
  "default_space_id": null,
  "email": "some@email.com",
  "email_verified": true,
  "location": {
    "country": "USA",
    "latitude": 0.0000000,
    "locality": "Sample City",
    "longitude": 0.0000000,
    "postal_code": "12345",
    "region": "Sample Region"
  },
  "name": "John Doe",
  "phone_number": "+123456789",
  "phone_number_verified": false,
  "picture": "https://example.com/profile.jpg",
  "sub": "sample-sub-id",
  "expires_at": 1234567890,
  "updated_at": 9876543210,
  "wallet_address": "sample-wallet-address",
  "website": "https://example.com",
  "guest": false,
  "deferred_deeplink": null
}

Usage: #

var currentUser = await vatomKey.currentState?.getCurrentUser();
if (currentUser != null) {
  // Use the user data for various purposes.
  print("User Name: ${currentUser.name}");
  print("User Email: ${currentUser.email}");
} else {
  // Handle the scenario where user data retrieval fails.
  print("Error fetching user data.");
}

The navigate function facilitates navigation within the wallet SDK by sending a message to trigger a specific route.

Parameters: #

  • route (String): The route to navigate to within the wallet SDK.
  • params (Map<String, dynamic>) (optional): Additional parameters to be passed along with the navigation request.

Usage: #

// Example 1: Navigate to a route without additional parameters.
vatomKey.currentState?.navigate("home");

// Example 2: Navigate to a route with additional parameters.
vatomKey.currentState?.navigate("profile", {"any": "..."});

openNFTDetail() #

The openNFTDetail function facilitates the navigation to the NFT detail screen within the wallet SDK.

Parameters: #

  • tokenId (String): The unique identifier of the NFT for which the detail screen should be opened.

Usage: #

// Example: Open the NFT detail screen for a specific token.
await vatomKey.currentState?.openNFTDetail("abc123");

logOut() #

The logOut function initiates the log-out process in the wallet SDK by sending a message to trigger the log-out action.

Usage: #

// Example: Initiate the log-out process.
await vatomKey.currentState?.logOut();

openCommunity() #

The openCommunity function facilitates the opening of a community within the wallet SDK. It sends a message to the wallet SDK to navigate to a specific community, and optionally to a specific room within that community.

Parameters: #

  • communityId (String): The unique identifier of the community to be opened.
  • roomId (String, optional): The unique identifier of the room within the community to navigate to.

Usage: #

// Example: Open a community without specifying a room.
await vatomKey.currentState?.openCommunity("communityId");

// Example: Open a specific room within a community.
await vatomKey.currentState?.openCommunity("communityId", roomId: "roomId");