The 0xGasless AA SDK offers two initialization options based on your integration requirements. Choose the appropriate initialization method for your use case:
For Telegram Login Integration
If you intend to use Telegram login and authentication, use the "AA0xGaslessTG" initialization method. This option is suitable when you want to enable users to log in using Telegram accounts and wallets attached to Telegram.
import { AA0xGaslessTG, TelegramClientOptions } from '@0xgasless/0xgasless-aa-sdk';
const apiKey = 'YOUR_API_KEY'; // Replace with your API key
const clientOptions: TelegramClientOptions = {
chainId: 1, // Required: Replace with the desired chain ID
telegramUserId: 'YOUR_TELEGRAM_USER_ID', // Required: Specify the Telegram user ID
walletAddress: 'YOUR_WALLET_ADDRESS', // Required: Provide the wallet address
rpcUrl: 'YOUR_RPC_URL', // Optional: Specify your custom RPC URL if needed
isSponsoredTrx: false, // Optional: Set to true if using sponsored transactions
paymasterEndpoint: 'PAYMASTER_ENDPOINT', // Optional: Specify your custom paymaster endpoint
paymaster: 'PIMLICO', // Optional: Choose a paymaster type ("PIMLICO" or "STACKUP")
};
const client = new AA0xGaslessTG(apiKey, clientOptions);
const address = await client.init(provider);
console.log("Smart account address", address);
For Other Integration Methods
For other integration methods like Metamask, Social Logins, Private Key based initialization and use cases, you can use the "AA0xGasless" initialization method. This option provides flexibility when integrating the SDK into your application.
import { AA0xGasless } from '@0xgasless/0xgasless-aa-sdk';
const apiKey = 'YOUR_API_KEY'; // Replace with your API key
const client = new AA0xGasless(apiKey);
const options = {
chainId: 1, // Required: Replace with the desired chain ID
privateKey: 'YOUR_PRIVATE_KEY', // Optional: Provide your private key if needed
rpcUrl: 'YOUR_RPC_URL', // Optional: Specify your custom RPC URL if needed
isSponsoredTrx: false, // Optional: Set to true if using sponsored transactions
paymasterEndpoint: 'PAYMASTER_ENDPOINT', // Optional: Specify your custom paymaster endpoint
paymaster: 'PIMLICO', // Optional: Choose a paymaster type ("PIMLICO" or "STACKUP")
};
const address = await client.init(provider, options);
console.log("Smart account address", address);
Now that you've successfully initialized the 0xGasless AA SDK, you're ready to start building your application and harness the power of account abstraction and blockchain interactions.
Enjoy using the SDK and refer to the rest of the documentation for more advanced features and guides!