First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
This project demonstrates how to migrate from Pimlico to Gelato for Safe Smart Account transactions. Below are the key changes required:
// Create Pimlico client
const pimlicoClient = createPimlicoClient({
transport: http(process.env.NEXT_PUBLIC_PIMLICO_URL || ""),
entryPoint: {
address: entryPoint07Address,
version: "0.7",
},
});
// Create SmartAccountClient with Pimlico
const smartAccountClient = createSmartAccountClient({
account,
chain: baseSepolia,
bundlerTransport: http(process.env.NEXT_PUBLIC_PIMLICO_URL || ""),
paymaster: pimlicoClient,
userOperation: {
estimateFeesPerGas: async () => {
return (await pimlicoClient.getUserOperationGasPrice()).fast;
},
},
});
// Create SmartAccountClient with Gelato
const smartAccountClient = createSmartAccountClient({
account,
chain: baseSepolia,
// Important: Chain transport (chain rpc) must be passed here instead of bundler transport
bundlerTransport: http(),
userOperation: {
estimateFeesPerGas: async () => {
return getUserOperationGasPrice(baseSepolia.id, gelatoApiKey).then(
({ fast }) => fast
);
},
},
}).extend(
gelatoBundlerActions({
payment: sponsored(),
apiKey: gelatoApiKey,
encoding: WalletEncoding.Safe,
})
);
Key Changes:
- Remove Pimlico client creation
- Change
bundlerTransport
from Pimlico URL to chain RPC - Remove
paymaster
configuration - Add
.extend(gelatoBundlerActions())
with Gelato-specific configuration - Use
getUserOperationGasPrice
from Gelato SDK instead of Pimlico client
const hash = await smartAccountClient.sendTransaction({
calls: [
{
to: "0xEEeBe2F778AA186e88dCf2FEb8f8231565769C27",
data: "0xd09de08a",
value: BigInt(0),
},
],
});
const userOpHash = await smartAccountClient.sendUserOperation({
calls: [
{
to: "0xEEeBe2F778AA186e88dCf2FEb8f8231565769C27",
data: "0xd09de08a",
value: BigInt(0),
},
],
});
// Wait for user operation receipt
const receipt = await smartAccountClient.waitForUserOperationReceipt({
hash: userOpHash,
});
// Get transaction hash from receipt
const transactionHash = receipt.receipt.transactionHash;
Key Changes:
- Change
sendTransaction
tosendUserOperation
// Remove this import
import { createPimlicoClient } from "permissionless/clients/pimlico";
import { sponsored, WalletEncoding } from "@gelatonetwork/smartwallet";
import {
gelatoBundlerActions,
getUserOperationGasPrice,
} from "@gelatonetwork/smartwallet/adapter";
The main differences in migrating from Pimlico to Gelato are:
- Client Creation: Replace Pimlico client with Gelato bundler actions
- Method Call: Change from
sendTransaction
tosendUserOperation
- Transaction Handling: Handle user operation hash and wait for receipt