CandidePaymaster (Advanced)
CandidePaymaster is the client for Candide-hosted paymasters. For one-shot sponsorship and ERC-20 gas, start with the standard Erc7677Paymaster instead. Use CandidePaymaster when you need the EntryPoint v0.9 two-phase commit -> sign -> finalize flow, which lets the user sign while the paymaster prepares its signature, or Candide's token and metadata APIs below.
Methods at a Glance
| Method | Signature | Returns |
|---|---|---|
| constructor | new CandidePaymaster(rpc: string | Transport) | CandidePaymaster |
| createSponsorPaymasterUserOperation | createSponsorPaymasterUserOperation(smartAccount, userOperation, bundlerRpc, sponsorshipPolicyId?, context?, overrides?) | Promise<{ userOperation; sponsorMetadata? }> |
| createTokenPaymasterUserOperation | createTokenPaymasterUserOperation(smartAccount, userOperation, tokenAddress, bundlerRpc, context?, overrides?) | Promise<{ userOperation; tokenQuote? }> |
| fetchSupportedERC20TokensAndPaymasterMetadata | fetchSupportedERC20TokensAndPaymasterMetadata(entrypoint?) | Promise<SupportedERC20TokensAndMetadataWithExchangeRate> |
| calculateUserOperationErc20TokenMaxGasCost | calculateUserOperationErc20TokenMaxGasCost(smartAccount, userOperation, erc20TokenAddress, overrides?) | Promise<bigint> |
| decodeTokenQuote (static) | CandidePaymaster.decodeTokenQuote(userOperation, nodeRpcUrl, overrides?) | Promise<DecodedTokenQuote | null> |
| getPaymasterMetaData | getPaymasterMetaData(entrypoint) | Promise<PaymasterMetadata | null> |
| getSupportedEntrypoints | getSupportedEntrypoints() | Promise<string[]> |
| isSupportedERC20Token | isSupportedERC20Token(erc20TokenAddress, entrypoint?) | Promise<boolean> |
| getSupportedERC20TokenData | getSupportedERC20TokenData(erc20TokenAddress, entrypoint?) | Promise<ERC20Token | null> |
| fetchTokenPaymasterExchangeRate | fetchTokenPaymasterExchangeRate(erc20TokenAddress, entrypoint?) | Promise<bigint> |
Usage
Import
import { CandidePaymaster } from "abstractionkit";
How to Use
Initialize a Paymaster with your RPC URL. Get an API key from the dashboard.
import { CandidePaymaster } from "abstractionkit";
const paymasterRPC = "https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
Then consume Paymaster methods:
const supportedEntryPoints = await paymaster.getSupportedEntrypoints();
Methods
createSponsorPaymasterUserOperation
Returns the paymaster data if the the userOperation has a Gas Policy. Otherwise it returns an error message. Supports two types of Gas Policies:
- Public Gas Policies: These are gas policies provided by third parties, which do not require a sponsorship policy ID.
- Private Gas Policies: These require a sponsorship policy ID and can be used if no public gas policy matches the user operation.
Usage
- example.ts
- Param Type
- Return Type
import { CandidePaymaster } from "abstractionkit";
const paymasterRPC = "https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const sponsorshipPolicyId = '1234';
// Use createUserOperation() to help you construct a userOp
const userOperation = await smartAccount.createUserOperation(/* ... */);
const { userOperation: sponsoredUserOperation, sponsorMetadata } =
await paymaster.createSponsorPaymasterUserOperation(
smartAccount,
userOperation,
bundlerUrl,
sponsorshipPolicyId, // optional
);
| key | type | description |
|---|---|---|
smartAccount | SmartAccountWithEntrypoint | The smart account instance. Used to resolve the EntryPoint address. |
userOperation | UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9 | UserOperation to Sponsor. Supports EntryPoint v0.6, v0.7, v0.8, and v0.9 |
bundlerRpc | string | Transport | Bundler | Bundler URL (or Transport / Bundler instance) to estimate the gas |
sponsorshipPolicyId | string? | Optional sponsorship policy id if using a Private Gas Policy |
context | object | Optional additional context to pass to the paymaster RPC (token, signingPhase). |
context.token | string? | ERC-20 token address, if paying gas in erc-20 tokens (optional) |
context.sponsorshipPolicyId | string? | Sponsorship Policy ID if using a private gas policy (optional) |
context.signingPhase | "commit" | "finalize"? | Opt into the parallel signing two-phase flow (EntryPoint v0.9 only). Use "commit" to request initial paymaster fields and gas limits before the user signs, then "finalize" to attach the final paymaster signature after. |
overrides | GasPaymasterUserOperationOverrides? | Optional overrides for gas limits, multipliers, entrypoint, and state overrides used during gas estimation. |
| key | type | description |
|---|---|---|
userOperation | UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9 | UserOperation with paymaster data included |
sponsorMetadata | object | Information about the Gas Policy Sponsor |
sponsorMetadata.name | string | Name of Sponsor who is sponsoring the Gas Policy |
sponsorMetadata.description | string | A short description of the sponsor |
sponsorMetadata.url | string | Website of the Sponsor |
sponsorMetadata.icons | string[] | Logos or Icons that the Sponsor is using to promote their Gas Policy |
Source code
createSponsorPaymasterUserOperation
fetchSupportedERC20TokensAndPaymasterMetadata
Returns a promise with the supported erc20 tokens and their exchange rate, along with the paymaster metadata
Usage
- example.ts
- Param Types
- Response Type
import { CandidePaymaster, SafeMultiChainSigAccountV1 as SafeAccount } from "abstractionkit";
const paymasterRPC="https://api.candide.dev/public/v3/11155111";
const paymaster = new CandidePaymaster(paymasterRPC);
const supportedERC20Tokens = await paymaster.fetchSupportedERC20TokensAndPaymasterMetadata(SafeAccount.DEFAULT_ENTRYPOINT_ADDRESS);
| key | type | description |
|---|---|---|
entrypoint | string? | EntryPoint Address. Defaults to V0.7 |
| key | type | description |
|---|---|---|
SupportedERC20TokensAndMetadataWithExchangeRate | Promise<SupportedERC20TokensAndMetadataWithExchangeRate> | A promise with the list of supported erc20 tokens and their exchange rate |
SupportedERC20TokensAndMetadataV7WithExchangeRate
| key | type | description |
|---|---|---|
paymasterMetadata | object | The Paymaster metadata |
paymasterMetadata.name | string | The name of the Paymaster. |
paymasterMetadata.description | string | A brief description of the Paymaster. |
paymasterMetadata.icons | string[] | An array of icon URLs representing the Paymaster's brand or logo. |
paymasterMetadata.address | string | The contract address of the Paymaster. |
paymasterMetadata.sponsoredEventTopic | string | The event topic that will be emitted when a UserOperation is sponsored by the Paymaster. |
paymasterMetadata.dummyPaymasterAndData | object | Dummy Paymaster data used for gas estimation. |
paymasterMetadata.dummyPaymasterAndData.paymaster | string | The address of the Paymaster. |
paymasterMetadata.dummyPaymasterAndData.paymasterVerificationGasLimit | bigint | The amount of gas allocated for the Paymaster verification step. |
paymasterMetadata.dummyPaymasterAndData.paymasterPostOpGasLimit | bigint | The amount of gas allocated for the Paymaster post-operation step. |
paymasterMetadata.dummyPaymasterAndData.paymasterData | string | Encoded data for the Paymaster. |
tokens | object | Supported erc20 tokens with Exchange Rate |
tokens.name | string | The name of the ERC20 token. |
tokens.symbol | string | The symbol representing the ERC20 token. |
tokens.address | string | The contract address of the ERC20 token. |
tokens.decimals | number | The number of decimal places for the token. |
tokens.exchangeRate | bigint | The exchange rate of the token. |
SupportedERC20TokensAndMetadataV6WithExchangeRate
| key | type | description |
|---|---|---|
paymasterMetadata | object | The Paymaster metadata |
paymasterMetadata.name | string | The name of the Paymaster. |
paymasterMetadata.description | string | A brief description of the Paymaster. |
paymasterMetadata.icons | string[] | An array of icon URLs representing the Paymaster's brand or logo. |
paymasterMetadata.address | string | The contract address of the Paymaster. |
paymasterMetadata.sponsoredEventTopic | string | The event topic that will be emitted when a UserOperation is sponsored by the Paymaster. |
paymasterMetadata.dummyPaymasterAndData | string | Dummy Paymaster data used for gas estimation. |
tokens | object | Supported erc20 tokens with Exchange Rate |
tokens.name | string | The name of the ERC20 token. |
tokens.symbol | string | The symbol representing the ERC20 token. |
tokens.address | string | The contract address of the ERC20 token. |
tokens.decimals | number | The number of decimal places for the token. |
tokens.exchangeRate | bigint | The exchange rate of the token. |
Example Response
{
tokens: [
{
name: 'Candide Test Token',
symbol: 'CTT',
address: '0xFa5854FBf9964330d761961F46565AB7326e5a3b',
decimals: 18,
exchangeRate: 1000000000000000000n
},
{
name: 'Tether',
symbol: 'USDT',
address: '0xd077a400968890eacc75cdc901f0356c943e4fdb',
decimals: 6,
exchangeRate: 2075579999n
}
],
paymasterMetadata: {
name: 'CANDIDE Paymaster',
description: 'CANDIDE Paymaster a fast, secure and feature-rich 4337 Paymaster',
icons: [],
address: '0xca944fb73fa5191969014ded9bb075381d59c7de',
sponsoredEventTopic: '0xa050a122b4c0e369e3385eb6b7cccd8019638b2764de67bec0af99130ddf8471',
dummyPaymasterAndData: {
paymaster: '0xca944fb73fa5191969014ded9bb075381d59c7de',
paymasterVerificationGasLimit: 70000n,
paymasterPostOpGasLimit: 75000n,
paymasterData: '0x0001000000000000ffff000000000000000000000000000000000000000000000000000000000000ffff010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011c'
}
}
}
createTokenPaymasterUserOperation
Estimates gas limits and returns the user operation with the paymaster data for ERC-20 Token sponsorship.
Some tokens like USDT do not allow changing a non-zero allowance directly. For known tokens (e.g. USDT on Ethereum mainnet), the SDK automatically prepends an approve(0) call before the actual approval. You can also manually trigger this behavior for other tokens by setting resetApproval: true in the overrides.
The overrides parameter also accepts an entrypoint field, which allows you to manually specify the EntryPoint address instead of relying on auto-detection from the UserOperation structure.
By default the prepended approve grants twice the quoted token cost. Set overrides.approveAmount (a bigint in the token's smallest unit) to choose the allowance yourself, for example to cap it at a maximum fee the user agreed to. The method throws a PAYMASTER_ERROR if the amount is below the quoted token cost, with both values in the error's context. The token cost is quoted during the call, so it isn't known beforehand. The finalize signing phase builds no approval and ignores this override.
The returned tokenQuote reports the paymaster the prepended approve was granted to (paymaster) and the allowance it set (approveAmount), so you can compare the spender against your configured paymaster without decoding callData. The method throws a PAYMASTER_ERROR if the final paymaster data is missing a paymaster or names a different one than the approval spender.
Usage
- example.ts
- Param Types
- Response Type
import { SafeMultiChainSigAccountV1 as SafeAccount, CandidePaymaster } from "abstractionkit";
const paymasterRPC="https://api.candide.dev/public/v3/11155111";
const erc20TokenAddress = "0xFa5854FBf9964330d761961F46565AB7326e5a3b"; // CTT test token
const bundlerRPC = "https://api.candide.dev/public/v3/11155111";
const ownerPublicAddress = "0x2Ef844456580b6e1E22e1D584EBbC2467D9298B2"
const smartAccount = SafeAccount.initializeNewAccount([ownerPublicAddress])
// Use createUserOperation() to help you construct a userOp
let userOperation = await smartAccount.createUserOperation(/* ... */);
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const { userOperation: sponsoredUserOperation, tokenQuote } =
await paymaster.createTokenPaymasterUserOperation(
smartAccount,
userOperation,
erc20TokenAddress,
bundlerRPC,
);
userOperation = sponsoredUserOperation;
| key | type | description |
|---|---|---|
smartAccount | PrependTokenPaymasterApproveAccount | The smart account object that created the target userOperation. Must implement prependTokenPaymasterApproveToCallData so the paymaster token approval can be prepended to the callData. |
userOperation | UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9 | The userOperation to sponsor gas with erc-20 paymaster |
tokenAddress | string | The address of the token to approve. |
bundlerRpc | string | Transport | Bundler | The Bundler RPC (URL, Transport or Bundler instance) to estimate the gas |
context | object | Optional additional context to pass to the paymaster RPC. `token` is always derived from `tokenAddress`, so pass `undefined` unless you need other fields (e.g. `signingPhase`). |
context.token | string? | ERC-20 token address, if paying gas in erc-20 tokens (optional) |
context.sponsorshipPolicyId | string? | Sponsorship Policy ID if using a private gas policy (optional) |
context.signingPhase | "commit" | "finalize"? | Opt into the parallel signing two-phase flow (EntryPoint v0.9 only). Use "commit" to request initial paymaster fields and gas limits before the user signs, then "finalize" to attach the final paymaster signature after. |
overrides | object | Overrides for gas limits, multipliers, entrypoint, and the approval reset behavior. |
overrides.entrypoint | string? | Set the EntryPoint address instead of auto-detecting it from the UserOperation structure. |
overrides.resetApproval | boolean? | When true, prepend an approve(0) call before the actual token approval. Required for tokens like USDT that do not allow changing a non-zero allowance directly. Automatically applied for known tokens (e.g. USDT on Ethereum mainnet). |
overrides.approveAmount | bigint? | Token paymaster flows only: the allowance the prepended approve grants, in the token's smallest unit. Replaces the default of twice the quoted tokenCost and is reported back as tokenQuote.approveAmount. Throws PAYMASTER_ERROR if below the quoted tokenCost. Ignored where no approval is built. |
overrides.callGasLimit | bigint | Set the callGasLimit instead of estimating gas using the bundler. |
overrides.verificationGasLimit | bigint | Set the verificationGasLimit instead of estimating gas using the bundler. |
overrides.preVerificationGas | bigint | Set the preVerificationGas instead of estimating gas using the bundler. |
overrides.callGasLimitPercentageMultiplier | number | Set the callGasLimitPercentageMultiplier instead of estimating gas using the bundler. |
overrides.verificationGasLimitPercentageMultiplier | number | Set the verificationGasLimitPercentageMultiplier instead of estimating gas using the bundler. |
overrides.preVerificationGasPercentageMultiplier | number | Set the preVerificationGasPercentageMultiplier instead of estimating gas using the bundler. |
overrides.stateOverrideSetType | object | Pass state overrides for gas estimation, including balance, nonce, code, and state or stateDiff for the account at each address. |
overrides.stateOverrideSetType.[address: string] | object | Overrides for a specific address |
overrides.stateOverrideSetType.[address: string].balance? | bigint | Override the balance of the address |
overrides.stateOverrideSetType.[address: string].nonce? | bigint | Override the nonce of the address |
overrides.stateOverrideSetType.[address: string].code? | string | Override the code of the address |
overrides.stateOverrideSetType.[address: string].state? | Dictionary<string> | Override the storage slots of the address |
overrides.stateOverrideSetType.[address: string].stateDiff? | Dictionary<string> | Apply state differences to the storage slots of the address |
| key | type | description |
|---|---|---|
userOperation | UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9 | The userOperation with paymaster data and token approval prepended |
tokenQuote | object | The exchange rate and maximum token cost the paymaster applied to this UserOperation. Populated on the token-payment flow; absent when called under the `signingPhase: "finalize"` path (no cost recomputation). |
tokenQuote.token | string | ERC-20 token contract address used to pay gas |
tokenQuote.exchangeRate | bigint | Exchange rate scaled by 10^18 (1 ETH expressed in the token's smallest unit) |
tokenQuote.tokenCost | bigint | The UserOperation's maximum gas cost at exchangeRate, in the token's smallest unit. Leaves out the paymaster's post-operation overhead and markup, so the paymaster can charge more: use decodeTokenQuote for the maximum charge (maxTokenCost) |
tokenQuote.paymaster | string | Address the prepended ERC-20 approve was granted to. The SDK verifies it equals the paymaster set on the returned UserOperation |
tokenQuote.approveAmount | bigint | Allowance granted to paymaster by the prepended approve, in the token's smallest unit (tokenCost with a safety multiplier applied) |
TokenQuote
| key | type | description |
|---|---|---|
token | string | ERC-20 token contract address used to pay gas |
exchangeRate | bigint | Exchange rate scaled by 10^18 (1 ETH expressed in the token's smallest unit) |
tokenCost | bigint | The UserOperation's maximum gas cost at exchangeRate, in the token's smallest unit. Leaves out the paymaster's post-operation overhead and markup, so the paymaster can charge more: use decodeTokenQuote for the maximum charge (maxTokenCost) |
paymaster | string | Address the prepended ERC-20 approve was granted to. The SDK verifies it equals the paymaster set on the returned UserOperation |
approveAmount | bigint | Allowance granted to paymaster by the prepended approve, in the token's smallest unit (tokenCost with a safety multiplier applied) |
Example Response
{
userOperation: {
sender: '0x9371252D5001d2aF35b1E69Fd33e268b4357D424',
nonce: 1n,
callData: '0x541d63c8...095ea7b3...',
callGasLimit: 191545n,
verificationGasLimit: 135864n,
preVerificationGas: 150767n,
maxFeePerGas: 82n,
maxPriorityFeePerGas: 60n,
signature: '0x00ffffffffffffffffffffffff47003599ffa7e9...',
factory: null,
factoryData: null,
paymaster: '0xca944fb73fa5191969014ded9bb075381d59c7de',
paymasterVerificationGasLimit: 70000n,
paymasterPostOpGasLimit: 75000n,
paymasterData: '0x0000000000006af4e929...',
eip7702Auth: null
},
tokenQuote: {
token: '0xFa5854FBf9964330d761961F46565AB7326e5a3b',
exchangeRate: 1000000000000000000n,
tokenCost: 51100432n,
paymaster: '0xca944fb73fa5191969014ded9bb075381d59c7de',
approveAmount: 102200864n
}
}
Source code
createTokenPaymasterUserOperation
calculateUserOperationErc20TokenMaxGasCost
Converts a UserOperation's maximum gas cost to the ERC-20 token at the paymaster's current exchange rate. It uses the same calculation as tokenQuote.tokenCost, so it leaves out Candide's post-operation overhead and markup. For the most a finished UserOperation can charge the user, use decodeTokenQuote.
Usage
- example.ts
- Param Types
- Return Types
import { CandidePaymaster } from "abstractionkit";
const erc20TokenAddress = "0xFa5854FBf9964330d761961F46565AB7326e5a3b"; // CTT test token
// Use createUserOperation() to help you construct a userOp
const userOperation = await smartAccount.createUserOperation(/* ... */);
const paymasterRPC="https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const cost = await paymaster.calculateUserOperationErc20TokenMaxGasCost(
smartAccount,
userOperation,
erc20TokenAddress,
);
| key | type | description |
|---|---|---|
smartAccount | SmartAccountWithEntrypoint | The smart account instance. Used to resolve the EntryPoint address. |
userOperation | UserOperationV6 | UserOperationV7 | UserOperationV8 | UserOperationV9 | UserOperation to calculate cost for. Supports EntryPoint v0.6, v0.7, v0.8, and v0.9 |
erc20TokenAddress | string | ERC-20 Token Address |
overrides | { entrypoint?: string | null }? | Optional. Set the EntryPoint address instead of resolving it from the smart account. |
| key | type | description |
|---|---|---|
cost | Promise<bigint> | Returns maximum amount that the operation will cost in the erc-20 token |
Example Response
35424864n
Source code
calculateUserOperationErc20TokenMaxGasCost
decodeTokenQuote
CandidePaymaster.decodeTokenQuote is the same static method as Erc7677Paymaster.decodeTokenQuote. See decodeTokenQuote on the Paymaster page.
Advanced Methods
getPaymasterMetaData
Returns the metadata associated with the Paymaster, along with dummyPaymasterAndData useful for gas estimates
Usage
- example.ts
- Param Type
- Return Type
import { CandidePaymaster, SafeMultiChainSigAccountV1 as SafeAccount } from "abstractionkit";
const paymasterRPC="https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const paymasterResult = await paymaster.getPaymasterMetaData(SafeAccount.DEFAULT_ENTRYPOINT_ADDRESS);
| key | type | description |
|---|---|---|
entrypoint | string | Target EntryPoint Contract Address |
| key | type | description |
|---|---|---|
paymastermetadata | Promise<PaymasterMetadataV7 | PaymasterMetadataV6 | null> | Returns a promise with the paymaster metadata associated with the target entrypoint |
PaymasterMetadataV7
| key | type | description |
|---|---|---|
name | string | The name of the Paymaster. |
description | string | A brief description of the Paymaster. |
icons | string[] | An array of icon URLs representing the Paymaster's brand or logo. |
address | string | The contract address of the Paymaster. |
sponsoredEventTopic | string | The event topic that will be emitted when a UserOperation is sponsored by the Paymaster. |
dummyPaymasterAndData | object | Dummy Paymaster data used for gas estimation. |
dummyPaymasterAndData.paymaster | string | The address of the Paymaster. |
dummyPaymasterAndData.paymasterVerificationGasLimit | bigint | The amount of gas allocated for the Paymaster verification step. |
dummyPaymasterAndData.paymasterPostOpGasLimit | bigint | The amount of gas allocated for the Paymaster post-operation step. |
dummyPaymasterAndData.paymasterData | string | Encoded data for the Paymaster. |
PaymasterMetadataV6
| key | type | description |
|---|---|---|
name | string | The name of the Paymaster. |
description | string | A brief description of the Paymaster. |
icons | string[] | An array of icon URLs representing the Paymaster's brand or logo. |
address | string | The contract address of the Paymaster. |
sponsoredEventTopic | string | The event topic that will be emitted when a UserOperation is sponsored by the Paymaster. |
dummyPaymasterAndData | string | Dummy Paymaster data used for gas estimation. |
Example Response
{
name: 'CANDIDE Paymaster',
description: 'CANDIDE Paymaster a fast, secure and feature-rich 4337 Paymaster',
icons: [],
address: '0xca944fb73fa5191969014ded9bb075381d59c7de',
sponsoredEventTopic: '0xa050a122b4c0e369e3385eb6b7cccd8019638b2764de67bec0af99130ddf8471',
dummyPaymasterAndData: {
paymaster: '0xca944fb73fa5191969014ded9bb075381d59c7de',
paymasterVerificationGasLimit: 70000n,
paymasterPostOpGasLimit: 75000n,
paymasterData: '0x0001000000000000ffff000000000000000000000000000000000000000000000000000000000000ffff010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101011c'
}
}
source code
getSupportedEntrypoints
Returns the supported Entrypoints by the paymaster
Usage
- example.ts
- Return Type
import { CandidePaymaster } from "abstractionkit";
const paymasterRPC="https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const paymasterResult = await paymaster.getSupportedEntrypoints();
| key | type | description |
|---|---|---|
entrypoint addresses | Promise<string[]> | A promise of a list of entrypoints addresses |
Example Response
[
'0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789',
'0x0000000071727de22e5e9d8baf0edac6f37da032',
'0x4337084d9e255ff0702461cf8895ce9e3b5ff108',
'0x433709009b8330fda32311df1c2afa402ed8d009'
]
source code
isSupportedERC20Token
Checks if a particular ERC-20 token is accepted as gas payment by the paymaster. Returns a boolean
Usage
- example.ts
- Param Types
- Response Type
import { CandidePaymaster } from "abstractionkit";
const paymasterRPC="https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const erc20TokenAddress = "0xFa5854FBf9964330d761961F46565AB7326e5a3b"; // CTT on sepolia testnet
const isSupported = await paymaster.isSupportedERC20Token(erc20TokenAddress);
| key | type | description |
|---|---|---|
erc20TokenAddress | string | ERC-20 Token Address |
entrypoint? | string | Target EntryPoint Address. Defaults to ENTRYPOINT_V7 |
| key | type | description |
|---|---|---|
isSupported | Promise<boolean> | Returns true if the erc20 token is supported |
Example Response
true
Source
getSupportedERC20TokenData
Returns the token data given an erc20 address
Usage
- example.ts
- Param Types
- Return Type
import { CandidePaymaster } from "abstractionkit";
const paymasterRPC = "https://api.candide.dev/public/v3/11155111";
const erc20TokenAddress = "0xFa5854FBf9964330d761961F46565AB7326e5a3b";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const erc20TokenData = await paymaster.getSupportedERC20TokenData(erc20TokenAddress);
| key | type | description |
|---|---|---|
erc20TokenAddress | string | ERC-20 Token Address |
entrypoint? | string | Target EntryPoint Address. Defaults to ENTRYPOINT_V7 |
| key | type | description |
|---|---|---|
ERC20Token | Promise<ERC20Token | null> | ERC-20 Token |
| key | type | description |
|---|---|---|
name | string | The name of the ERC20 token. |
symbol | string | The symbol representing the ERC20 token. |
address | string | The contract address of the ERC20 token. |
decimals | number | The number of decimal places for the token. |
Example Response
{
name: 'Candide Test Token',
symbol: 'CTT',
address: '0xFa5854FBf9964330d761961F46565AB7326e5a3b',
decimals: 18
}
Source code
fetchTokenPaymasterExchangeRate
Fetches the current exchange rate for an ERC-20 token from the paymaster. The exchange rate represents the token cost per unit of native currency, used to calculate how much of the token is needed to cover gas fees.
Usage
- example.ts
- Param Types
- Return Type
import { CandidePaymaster } from "abstractionkit";
const paymasterRPC = "https://api.candide.dev/public/v3/11155111";
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
const erc20TokenAddress = "0xFa5854FBf9964330d761961F46565AB7326e5a3b"; // CTT on sepolia testnet
const exchangeRate = await paymaster.fetchTokenPaymasterExchangeRate(erc20TokenAddress);
| key | type | description |
|---|---|---|
erc20TokenAddress | string | ERC-20 Token Address |
entrypoint | string? | EntryPoint Address that the paymaster is supporting. Defaults to ENTRYPOINT_V7 |
| key | type | description |
|---|---|---|
exchangeRate | Promise<bigint> | Returns the exchange rate to the native token |
Example Response
1000000000000000000n
Source code
fetchTokenPaymasterExchangeRate
createPaymasterUserOperation
CandidePaymaster.createPaymasterUserOperation is a private helper, not part of the public API. Use createSponsorPaymasterUserOperation for gas sponsorship or createTokenPaymasterUserOperation for ERC-20 token payment instead.
Erc7677Paymaster exposes a public method with the same name; that one is the recommended entry point for the standard ERC-7677 flow and is documented on the Paymaster page.
Source code
Error Handling
CandidePaymaster throws the same errors as Erc7677Paymaster. See Error Handling on the Paymaster page.