pm_validateSponsorshipPolicies
Validates a user operation against an array of sponsorship policies and returns which policies are willing to sponsor the user operation. This method uses 4950 credits from your daily balance.
Parameters
- v0.7 and v0.8 user operation
- v0.6 user operation
-
userOperation
: The user operation object containing the following fields:sender
: (string) - The address of the account making the operation.nonce
: (string) - Unique identifier for the request from this sender. This includes the key and sequence number.factory
: (string) [optional] - The factory contract address that will deploy the smart account if it doesn't exist yet.factoryData
: (string) [optional] - The data passed to the factory contract to deploy the smart account.callData
: (string) [optional] - The data to pass to the sender during the main execution call.callGasLimit
: (string) - The amount of gas to allocate the main execution call.verificationGasLimit
: (string) - The amount of gas to allocate for the verification step.preVerificationGas
: (string) - The amount of gas to pay for to compensate the bundler for pre-verification execution andcalldata
.maxFeePerGas
: (string) - Maximum fee per gas, in wei, the sender is willing to pay per gas.maxPriorityFeePerGas
: (string) - Maximum fee, in wei, the sender is willing to pay per gas above the base fee.paymaster
: (string) [optional] - Address of paymaster sponsoring the transaction, ornull
if none.paymasterVerificationGasLimit
: (string) [optional] - The amount of gas to allocate for the verification step of the paymaster, ornull
if no paymaster.paymasterPostOpGasLimit
: (string) [optional] - The amount of gas to allocate for the post-operation step of the paymaster, ornull
if no paymaster.paymasterData
: (string) [optional] - The data to pass to the paymaster during the verification step, ornull
if no paymaster.signature
: (string) - The signature data.
-
entryPoint
: (string) - The EntryPoint contract address (0x0000000071727De22E5E9d8BAf0edAc6f37da032
). -
sponsorshipPolicyIds
: (array) - An array of sponsorship policy IDs to validate against.
-
userOperation
: The user operation object containing the following fields:sender
: (string) - The address of the account making the operation.nonce
: (string) - Unique identifier for the request from this sender.initCode
: (string) - The initialization code for the smart account if it doesn't exist yet.callData
: (string) [optional] - The data to pass to the sender during the main execution call.callGasLimit
: (string) - The amount of gas to allocate the main execution call.verificationGasLimit
: (string) - The amount of gas to allocate for the verification step.preVerificationGas
: (string) - The amount of gas to pay for to compensate the bundler for pre-verification execution andcalldata
.maxFeePerGas
: (string) - Maximum fee per gas, in wei, the sender is willing to pay per gas.maxPriorityFeePerGas
: (string) - Maximum fee, in wei, the sender is willing to pay per gas above the base fee.paymasterAndData
: (string) - The address of the paymaster contract and the data that will be passed to it.signature
: (string) - The signature data.
-
entryPoint
: (string) - The EntryPoint contract address (0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
). -
sponsorshipPolicyIds
: (array) - An array of sponsorship policy IDs to validate against.
Returns
An array of sponsorship policy objects that are willing to sponsor the user operation.
Each object in the array contains:
sponsorshipPolicyId
: (string) - The ID of the sponsorship policy.data
: (object) - Additional metadata about the sponsorship policy:name
: (string) [optional] - The display name of the sponsorship policy.author
: (string) [optional] - The author or organization behind the sponsorship policy.icon
: (string) [optional] - Base64-encoded image data for the policy icon.description
: (string) [optional] - A description of the sponsorship policy.
Example
Replace <YOUR-API-KEY>
with an API key from your MetaMask Developer dashboard.
Request
- v0.7 and v0.8
- v0.6
curl https://mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "pm_validateSponsorshipPolicies",
"params": [
{
"sender": "0x1234567890123456789012345678901234567890",
"nonce": "0x1",
"factory": "0xd703aaE79538628d27099B8c4f621bE4CCd142d5",
"factoryData": "0x",
"callData": "0x",
"callGasLimit": "0x100000",
"verificationGasLimit": "0x20000",
"preVerificationGas": "0x10000",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x3b9aca00",
"paymaster": null,
"paymasterVerificationGasLimit": null,
"paymasterPostOpGasLimit": null,
"paymasterData": null,
"signature": "0x"
},
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
["sp_crazy_kangaroo", "sp_talented_turtle"]
],
"id": 1
}'
curl https://mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "pm_validateSponsorshipPolicies",
"params": [
{
"sender": "0x1234567890123456789012345678901234567890",
"nonce": "0x1",
"initCode": "0x",
"callData": "0x",
"callGasLimit": "0x100000",
"verificationGasLimit": "0x20000",
"preVerificationGas": "0x10000",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x3b9aca00",
"paymasterAndData": "0x",
"signature": "0x"
},
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
["sp_crazy_kangaroo", "sp_talented_turtle"]
],
"id": 1
}'
Response
{
"jsonrpc": "2.0",
"result": [
{
"sponsorshipPolicyId": "sp_crazy_kangaroo",
"data": {
"name": "Linea Christmas Week",
"author": "Linea",
"icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"description": "Linea is sponsoring the first 10 transactions for existing users between Christmas and New Year's Eve."
}
}
],
"id": 1
}