This is example showcase how to deploy a Safe account while sponsoring its transactions gas fees using a private gas policy with Candide Paymaster.
- Create an API key and setup a Gas Policy on Candide's Dashboard
- Create a .env file from .env.example
cp .env.example .env
npm install
npm start
Note: Viem tend to overestimate gas prices for AA User Operations. To get a more accurate estimate, we use the
estimateFeesPerGas
method to fetch the current gas prices and add them to the overrides when sending the user operation. This approach ensures you pay a fair block price for gas.
import { estimateFeesPerGas } from "viem/actions"
const {
maxFeePerGas,
maxPriorityFeePerGas
} = await estimateFeesPerGas(client);