Skip to main content

How to call operations with FT4 authentication

This recipe demonstrates how to call dapp operations that require FT4 authentication using a Web3 provider (e.g., MetaMask). This is essential for interacting with custom dapp operations that need authenticated user accounts.

Prerequisites

  • Node.js
  • Web3 provider (e.g., MetaMask browser extension)
  • FT4 client: npm install @chromia/ft4
  • Postchain client: npm install postchain-client

Demo script

Key Features

This recipe includes examples for:

  • Web3 integration - Using injected Web3 providers like MetaMask for key management
  • FT4 authentication - Creating authenticated sessions for operation calls
  • Custom operations - Calling arbitrary dapp operations that require user authentication
  • Session management - Handling FT4 session creation and operation execution

Authentication Flow

The recipe demonstrates this flow:

  1. Connect to Web3 provider - Uses createWeb3ProviderEvmKeyStore to integrate with MetaMask
  2. Get FT4 accounts - Retrieves accounts associated with the Web3 provider
  3. Create session - Establishes an authenticated FT4 session
  4. Call operations - Executes custom dapp operations with proper authentication

Learn more