Integrate gas fee abstraction into your applications using Shib Paymasters with ERC-4337 standard support
Get API Key
Configure Integration
User Operations
Signature Generation
On-chain Verification
Fee Payment
User Operations
Developer Registration
Contract Deployment
Price Oracle Integration
Clone Repository
Navigate to Project
Install Dependencies
Build Project
Install Yalc
Publish Locally
Add to Your Project
Link Package
Install in Project
Shib4337
class and call its methods:
Property | Description |
---|---|
paymasterUrl | The URL of the paymaster service. Format: https://paymaster.shib.io/shibarium/<api-key> , where the API key is acquired from the developer portal. |
isSponsored | A boolean value to determine if the transactions are sponsored. |
sponsorshipPolicyId | The sponsorship policy ID for the paymaster. |
paymasterAddress | The address of the paymaster contract. |
paymasterTokenAddress | The address of the token used by the ERC20 paymaster. |
amountToApprove | The amount to approve for the ERC20 paymaster. |
createTransaction
method to prepare transactions for execution. You can add multiple transactions to a queue and then create a single user operation (userOp
).
addTransaction
method:
transactionObj
has the following structure:
Key | Value |
---|---|
to | The destination address. |
value | The amount of Ether to send (in wei). |
data | The transaction data (e.g., encoded function call). |
operation | The operation type (0 for call, 1 for delegate call). |
Type | Number | Description |
---|---|---|
NoPaymaster (Default) | 0 | No Paymaster is used; standard transaction fees apply. |
PaymasterContract | 1 | Uses an on-chain Paymaster contract. Requires paymasterAddress. |
VerifyingPaymaster | 2 | Uses a sponsored off-chain Paymaster service. Requires paymasterUrl. |
ERC20Paymaster | 3 | Uses an on-chain ERC-20 Paymaster. Requires paymasterAddress and paymasterTokenAddress. |
OffchainPaymaster | 4 | Uses a non-sponsored off-chain Paymaster service. Requires paymasterUrl and paymasterTokenAddress. |
CustomPaymaster | 5 | Allows custom Paymaster configurations. Requires paymasterAndData. |
options
object should have the following properties:
Property | Required | Description |
---|---|---|
type | YES | The Paymaster type (see above). |
paymasterAndData | For CustomPaymaster, a string specifying custom Paymaster data. | |
amountToApprove | Amount of tokens to approve for the ERC-20 Paymaster. | |
validUntil | Expiry time for the Paymaster (timestamp). | |
validAfter | Start time for the Paymaster (timestamp). | |
feeEstimator | A function or value to estimate fees for the Paymaster. |
Installation Issues
npm cache clean --force
Paymaster Configuration Errors
Transaction Execution Failures