This repository serves as a template for working with the Okto SDK in TypeScript. It provides two main approaches for integrating with Okto:
- TypeScript SDK Integration - A simple, direct way to interact with Okto services
- Direct API Integration - Detailed examples for direct API interactions with Okto
- 🔐 Authentication with Google Sign-In
- 💼 Wallet Management for crypto assets
- 💸 Token Transfers for sending tokens
- 🖼️ NFT Transfers for sending NFTs
- 📝 Raw Transaction support for custom blockchain interactions
- 🔑 Delegated Actions for advanced use cases
The main entry point for the TypeScript SDK is src/index.ts
. This file demonstrates how to:
- Initialize the Okto client
- Authenticate users with Google OAuth
- Retrieve wallet information
- Check portfolio balances
- Get supported chains and tokens
- Transfer tokens and NFTs
To use the TypeScript SDK in your own project, simply import the required functions from the Okto SDK package:
import { OktoClient } from "@okto_web3/core-js-sdk";
import { tokenTransfer, nftTransfer } from "@okto_web3/core-js-sdk/userop";
For more details on how to use the TypeScript SDK, please refer to the TypeScript SDK Setup Guide.
This template also provides detailed examples for direct API integration with Okto. These examples are located in the following files:
src/oktoAuthenticate_template.ts
- Authentication and token generationsrc/tokenTransferIntent_template.ts
- Token transfer implementationsrc/nftTransferIntent_template.ts
- NFT transfer implementationsrc/rawTransactionIntent_template.ts
- Raw transaction implementationsrc/delegatedActions_template.ts
- Delegated actions implementation
Each file contains detailed comments explaining the implementation steps.
- Authentication: First, authenticate and generate an auth token using the process in
oktoAuthenticate_template.ts
- Perform Actions: After authentication, you can perform any of the following actions:
- Token transfers
- NFT transfers
- Raw transactions
- Delegated actions
The repository includes several helper and utility functions:
- Helper Functions (
src/helper/
): Generic functions for data conversion, serialization, and encoding - Utility Functions (
src/utils/
): Okto-specific functions for generating paymaster data, session keys, and other Okto-related operations
The following environment variables are required:
# Okto environment ("sandbox" or "production")
OKTO_ENVIRONMENT=sandbox
# Okto API credentials (from Developer Dashboard)
OKTO_CLIENT_PRIVATE_KEY=
OKTO_CLIENT_SWA=
# Google authentication (optional, only for Google auth)
GOOGLE_ID_TOKEN=
# For testing intents or delegated access
USER_SWA=
SESSION_PUBLIC_KEY=
SESSION_PRIVATE_KEY=
OKTO_AUTH_TOKEN=
Contributions are welcome! Please take a moment to review our CONTRIBUTING.md guidelines before submitting any Pull Requests. Your contributions are invaluable to the Okto community.
- Okto Documentation
- Okto Developer Dashboard
- For support, join the Okto Discord Server