@trikon_sdk/custom-paymaster-sdk
v1.0.3
Published
Node.js SDK for Trikon OS APIs
Maintainers
Readme
🧠 CustomPaymasterSDX
The CustomPaymasterSDX is a Node.js SDK to interact with Trikon’s Paymaster Service, a backend service that provides Account Abstraction-powered features such as:
- Anonymous login/signup
- Multichain token portfolio viewing
- ERC-20 and native token transfer (with or without gas sponsorship)
- Token swap across chains
- Token approval checks and gas estimations
This SDK is intended for developers building smart account-based decentralized applications (dApps) that wish to offer seamless user experience with minimal wallet friction.
📦 Installation
npm install node-fetch dotenvConfiguration
You need to first login to https://trikon.io and create an account to get an API key, project id and dapp id. These will be used in further SDK methods.
🔑 Initialization
const CustomPaymasterSDK = require("@trikon_sdk/custom-paymaster-sdk");
const sdk = new CustomPaymasterSDK({
apiKey: 'YOUR_API_KEY_HERE' // replace with actual Trikon API key
});🧪 API Methods and Usage
All methods return a Promise and must be called using await or .then().
✅ testTrikonSDX()
Purpose: To verify if the Trikon SDX system is up and responding.
await sdk.testTrikonSDX();🔐 signUpAnonymous(data)
Purpose: Registers a user anonymously.
await sdk.signUpAnonymous({
userName: 'testuser',
password: 'testpassword'
});🔐 signInAnonymous(data)
Purpose: Signs in an anonymous user and returns their session/token data.
await sdk.signInAnonymous({
userName: 'testuser',
password: 'testpassword',
projectId: 'your_project_id',
dappId: 'your_dapp_id'
});💼 getMultichainPortfolio(address)
Purpose: Retrieves all ERC-20 and native token balances of a wallet across supported chains.
await sdk.getMultichainPortfolio('0xYourAddress');💰 getBalance(data)
Purpose: Fetches the native token balance of a wallet on a specific chain.
await sdk.getBalance({
address: '0xYourAddress',
chainId: '0x89' // Polygon
});🪙 getERC20Balance(data)
Purpose: Returns the balance of a specific ERC-20 token for a wallet.
await sdk.getERC20Balance({
contractAddress: '0xdAC17F...', // token contract (e.g., USDT)
address: '0xYourAddress',
chainId: '0x1' // Ethereum mainnet
});🛡️ checkERC20ApprovalAmount(data)
Purpose: Checks whether the token is approved for transfer to a spender contract.
await sdk.checkERC20ApprovalAmount({
contractAddress: '0xdAC17F...',
userAddress: '0xYourAddress',
spenderAddress: '0xSpenderContract',
chainId: '0x1'
});⛽ approveERC20(data)
Purpose: Approve the transfer of an ERC-20 token via smart account.
await sdk.approveERC20({
cfa: '0xYourSmartAccount',
toAddress: '0xRecipient',
valueInEther: '0.0001',
contractAddress: '0xTokenContract',
projectId: 'your_project_id',
chainId: '0xaa36a7'
});⛽ estimateGasSendERC20Transfer(data)
Purpose: Estimate the gas required to send an ERC-20 token via smart account.
await sdk.estimateGasSendERC20Transfer({
cfa: '0xYourSmartAccount',
toAddress: '0xRecipient',
valueInEther: '0.0001',
contractAddress: '0xTokenContract',
projectId: 'your_project_id',
chainId: '0xaa36a7'
});🚀 sendERC20Transfer(data)
Purpose: Executes the transfer of ERC-20 tokens using the Account Abstraction smart account.
await sdk.sendERC20Transfer({
toAddress: '0xRecipient',
projectId: 'your_project_id',
contractAddress: '0xTokenContract',
valueInEther: '0.0001',
chainId: '0xaa36a7',
cfa: '0xYourSmartAccount'
});⛽ estimateGasSendNative(data)
Purpose: Estimate the gas required to send native tokens (ETH, MATIC, etc.).
await sdk.estimateGasSendNative({
toAddress: '0xRecipient',
valueInEther: '0.00000001',
chainId: '0xaa36a7',
projectId: 'your_project_id',
cfa: '0xYourSmartAccount'
});🚀 sendNative(data)
Purpose: Sends native tokens from the smart account.
await sdk.sendNative({
toAddress: '0xRecipient',
valueInEther: '0.00000001',
chainId: '0xaa36a7',
projectId: 'your_project_id',
cfa: '0xYourSmartAccount'
});📡 getLifiRoutes(data)
Purpose: Fetches token swap route options between two chains.
await sdk.getLifiRoutes({
fromAddress: '0xYourAddress',
fromChainId: 1,
toChainId: 137,
fromTokenAddress: '0xdAC17F...', // USDT
toTokenAddress: '0x0000000000000000000000000000000000000000', // MATIC
fromAmount: '1000000'
});🔄 swapAssets(data)
Purpose: Initiates a cross-chain token swap using LiFi tools (like StargateV2).
await sdk.swapAssets({
fromAddress: '0xYourAddress',
fromChain: 137,
fromToken: '0x0000000000000000000000000000000000000000',
toChain: 8453,
toToken: '0x0000000000000000000000000000000000000000',
fromAmount: '2000000000000',
selectedTool: 'stargateV2',
chainId: '0xaa36a7',
cfa: '0xYourSmartAccount'
});🧠 Notes
- All requests require a valid API key via
x-api-keyheader. - Many requests require projectId, dappId, and cfa (users smart contract wallet).
chainIdshould be in hexadecimal format (e.g.,0xaa36a7for Sepolia).
🧰 Troubleshooting
- Error 400/500: Check if all required parameters are present.
- Authentication Error: Make sure your API key is correct and not expired.
- Token Transfer Fails: Ensure the user has balance, allowance, and correct network selected.
📜 License
MIT © 2025 Trikon
🤝 Support
If you have any questions or need help integrating the SDK, contact the Trikon team.
