Skip to content

Commit

Permalink
Merge pull request #124 from bcnmy/sponsoruserop-page
Browse files Browse the repository at this point in the history
Sponsoruserop page
  • Loading branch information
himanshugarg06 authored Nov 30, 2023
2 parents e548648 + ec9bdef commit a014788
Showing 1 changed file with 10 additions and 68 deletions.
78 changes: 10 additions & 68 deletions docs/Paymaster/api/sponsoruserop.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,43 @@ You can test this endpoint on our [Paymaster Explorer](/Paymaster/explorer)
All paymaster URL's allow you to use both Sponsorship and Token Paymasters. To switch between paymasters you will simply change the Mode of a specific request. We will highlight both type of requests below.

This endpoint is responsible for calculating the `paymasterAndData` field, if applicable, for the given request.
The API accepts a partial UserOp and an optional token address. By examining the mode parameter in the request, it identifies the type of paymaster associated with the request and handles the processing accordingly, as described in the following.

The API receives a partial `UserOp` and an optional token address. From the mode parameter in request, it checks for the type of paymaster this request is for, and processes the request accordingly, as outlined below.
### Sponsorship Paymaster

**Sponsorship Paymaster**
To determine whether a request can be sponsored by the Sponsorship Paymaster, only consider the partial UserOp object and the sponsorshipInfo. If the request cannot be sponsored, the `paymasterAndData` would return "0x".

To determine whether a request can be sponsored by the Sponsorship Paymaster, only consider the partial UserOp object and the sponsorshipInfo. If the request cannot be sponsored, it would return "0x" as the `paymasterAndData`.

**Token Paymaster**
### Token Paymaster

Consider both the partial `UserOp` and `tokenAddress` parameters in this case. If the `tokenAddress` is absent, an error will be thrown. If both are present, check for the *TokenPaymaster* flow and send the `paymasterAndData` response accordingly. If the `tokenAddress` is not supported, an error will also be thrown. Please see the error response at the end of this document.

## Parameters

Body
**Body**

| Param | Type | Description | Required |
| --------------- | --------------- | --------------- | --------------- |
| method | string | Name of method in this case: pm_getFeeQuoteOrData | Required |
| params | array | An array consisting of the Useroperation object and Paymaster mode information | Required |
| id | string | id for request determined by client for JSON RPC requests | Required |
| jsonrpc | string | JSON RPC version in this case 2.0.0 | Required |


Params Array for Sponsorship requests
<br/>
**Params Array for Sponsorship requests**

| Index | Type | Description | Required |
| --------------- | --------------- | --------------- | --------------- |
| 0 | object | A partial userOperation object for the userOp that needs to be sponsored | Required |
| 1 | object | Mode specified as "SPONSORSHIP" as well as sposorship information which includes any webhook data and smart account information: name and version | Required |

Params Array for ERC20 paymaster requests
<br/>
**Params Array for ERC20 paymaster requests**

| Index | Type | Description | Required |
| --------------- | --------------- | --------------- | --------------- |
| 0 | object | A partial userOperation object for the userOp that needs to be sponsored | Required |
| 1 | object | Mode specified as "ERC20" as well as tokenInfo: a preferred token address and list of tokens to include | Required |


<br/>
:::note
**"MODE"** is mandatory for `pm_sponsorUserOperation` API,

Expand Down Expand Up @@ -176,62 +175,5 @@ Params Array for ERC20 paymaster requests
```



#### 2. Mode is **ERC20** :

> ***POST Request***
```javascript

{
"id": 1,
"jsonrpc": "2.0",
"method": "pm_sponsorUserOperation",
"params": [
{
sender, // address
nonce, // uint256
initCode, // string
callData, // string
maxFeePerGas, // string
maxPriorityFeePerGas, // string

//mandatory fields
callGasLimit, // string
verificationGasLimit, // string
preVerificationGas, // string

},
{
"mode": "ERC20",
"calculateGasLimits" : true,
"expiryDuration": 300 //5mins
"tokenInfo": {
"feeTokenAddress": "0xbf22b04e250a5921ab4dc0d4ced6e391459e92d4"
}
}
],
}
```

> ***Response***

```javascript

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"MODE": "ERC20",
"paymasterAndData": "0xdc91ffb7c4b800d70410a79a5b503ae4391f67e40000000000000000000000007306ac7a32eb690232de81a9ffb44bb346026fab00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041e1f74852c31150f18ef4e472b748148f8ae031849032218b26170414a18c9f99516eb13a4a9bd35d1334194348cccee3d270b6e7bb400b39f0c8d645266ead601c00000000000000000000000000000000000000000000000000000000000000",
"preVerificationGas": "75388",
"verificationGasLimit": 57121,
"callGasLimit": 108848
}
}
```


In response, the result field will contain `paymasterAndData` to be used in UserOp.

0 comments on commit a014788

Please sign in to comment.