Android library for interacting with the ethOS Paymaster system. Provides balance management, top-up flows (via Daimo), ERC-4337 gas estimation (via Pimlico), and token price lookups — all wrapped in a clean, synchronous Kotlin API designed for Dispatchers.IO.
Installation
Step 1. Add the JitPack repository to your project's settings.gradle.kts (inside the dependencyResolutionManagement block):
// 1. Create the SDK instance
val paymasterSDK = PaymasterSDK(
context = applicationContext,
bundlerApiKey = "your-pimlico-api-key"
)
// 2. Initialize (connects to the on-device PaymasterProxy service)
withContext(Dispatchers.IO) {
val available = paymasterSDK.initialize()
if (available) {
// 3. Read the cached balance
val balance = paymasterSDK.getBalance() // e.g. "12.50"
// 4. Trigger a fresh balance sync from the backend
paymasterSDK.queryBalanceUpdate()
// 5. Listen for balance changes
paymasterSDK.registerBalanceObserver { newBalance ->
// update your UI
}
// 6. Initiate a top-up (returns a Daimo checkout URL)
val topUp = paymasterSDK.initiateTopUp(
userId = "0xYourWalletAddress",
amount = "10"
)
topUp?.let {
// open it.checkoutUrl in a browser / WebView
}
// 7. Estimate gas for a UserOperation
val gasEstimation = paymasterSDK.estimateGas(userOp, chainId = 8453)
// 8. Fetch token prices for sponsorship
val prices = paymasterSDK.fetchSponsorshipPrices(
listOf("0xTokenAddress1", "0xTokenAddress2")
)
}
}
// 9. Clean up when done (e.g. in onDestroy)
paymasterSDK.cleanup()
Permissions
The SDK declares the following permissions in its own manifest (merged automatically):
Permission
Purpose
INTERNET
Communicate with the Paymaster backend and Pimlico
ACCESS_NETWORK_STATE
Check network availability
No runtime permissions are required — both are normal permissions granted at install time.
API
PaymasterSDK
Constructor
Parameter
Description
context
Application or Activity context
bundlerApiKey
Your Pimlico API key (used for gas estimation & bundler URL)
baseUrl
(Optional) Paymaster backend base URL
Methods
Method
Return Type
Description
initialize()
Boolean
Connect to the on-device PaymasterProxy system service. Returns true if the service is available (ethOS device), false otherwise. Must be called before any other method.
getBalance()
String?
Returns the cached paymaster balance (e.g. "12.50"), or null if unavailable.
queryBalanceUpdate()
Unit
Triggers an asynchronous balance refresh from the backend. Listen for the result with registerBalanceObserver.