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.
- JS/TS client
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:
- Connect to Web3 provider - Uses
createWeb3ProviderEvmKeyStore
to integrate with MetaMask - Get FT4 accounts - Retrieves accounts associated with the Web3 provider
- Create session - Establishes an authenticated FT4 session
- Call operations - Executes custom dapp operations with proper authentication
Learn more
- FT4 client documentation — covers account management and FT4 operations.
- Account management — understanding FT4 accounts and authentication.
- JavaScript/TypeScript client — covers setup, connection, and usage patterns.