diff --git a/package-lock.json b/package-lock.json index 93f841c..076258c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "dotenv": "^16.3.1", - "permissionless": "0.0.0-v0-2.20240827T152549", + "permissionless": "0.0.0-v0-2.20240828T162812", "viem": "2.20.0" }, "devDependencies": { @@ -554,11 +554,11 @@ } }, "node_modules/permissionless": { - "version": "0.0.0-v0-2.20240827T152549", - "resolved": "https://registry.npmjs.org/permissionless/-/permissionless-0.0.0-v0-2.20240827T152549.tgz", - "integrity": "sha512-ASyBxqR0mLq3MVabYcxojazbTXJyKis4oGvwImOvlFW7oTrz5oyhcdglTGBSyvFtxjWfqq9OSaUHgFS1XaUkag==", + "version": "0.0.0-v0-2.20240828T162812", + "resolved": "https://registry.npmjs.org/permissionless/-/permissionless-0.0.0-v0-2.20240828T162812.tgz", + "integrity": "sha512-zWtgUzKDtyQhLOzBewsp8hupsBBmjTbUoDO6k1C8q0Ot1ziRiHg12c3FXfo356QkOMKWZJGohb/mb5BSliOnrQ==", "peerDependencies": { - "viem": "^2.18.0" + "viem": "^2.20.0" } }, "node_modules/resolve-pkg-maps": { diff --git a/package.json b/package.json index 720e272..2752d5b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "license": "MIT", "dependencies": { "dotenv": "^16.3.1", - "permissionless": "0.0.0-v0-2.20240827T152549", + "permissionless": "0.0.0-v0-2.20240828T162812", "viem": "2.20.0" }, "devDependencies": { diff --git a/tutorial-1.ts b/tutorial-1.ts index 31747d2..669f50f 100644 --- a/tutorial-1.ts +++ b/tutorial-1.ts @@ -5,7 +5,8 @@ import { Hex, createPublicClient, http } from "viem" import { generatePrivateKey, privateKeyToAccount } from "viem/accounts" import { sepolia } from "viem/chains" import { createPimlicoClient } from "permissionless/clients/pimlico" -import { createBundlerClient, createPaymasterClient, entryPoint07Address } from "viem/account-abstraction" +import { createBundlerClient, entryPoint07Address } from "viem/account-abstraction" +import { createSmartAccountClient } from "permissionless" const apiKey = process.env.PIMLICO_API_KEY if (!apiKey) throw new Error("Missing PIMLICO_API_KEY") @@ -49,26 +50,91 @@ const pimlicoClient = createPimlicoClient({ } }) -const smartAccountClient = createBundlerClient({ - account, - chain: sepolia, - transport: http(pimlicoUrl), - paymaster: pimlicoClient, - userOperation: { - estimateFeesPerGas: async () => { - return (await pimlicoClient.getUserOperationGasPrice()).fast - }, - } -}) +{ + const smartAccountClient = createSmartAccountClient({ + account, + chain: sepolia, + bundlerTransport: http(pimlicoUrl), + paymaster: pimlicoClient, + userOperation: { + estimateFeesPerGas: async () => { + return (await pimlicoClient.getUserOperationGasPrice()).fast + }, + } + }) -const userOpHash = await smartAccountClient.sendUserOperation({ - calls: [{ + const txHash = await smartAccountClient.sendTransaction({ to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", value: 0n, data: "0x1234", - }] -}) -const receipt = await smartAccountClient.waitForUserOperationReceipt({hash:userOpHash}) + }) + + console.log(`User operation included: https://sepolia.etherscan.io/tx/${txHash}`) + + const txHashMultiple = await smartAccountClient.sendTransaction({ + calls: [ + { + to: "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc", + value: 0n, + data: "0x1234", + }, + { + to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", + value: 0n, + data: "0x1234", + } + ], + }) + + console.log(`User operation included: https://sepolia.etherscan.io/tx/${txHashMultiple}`) +} + +{ + const bundlerClient = createBundlerClient({ + account, + chain: sepolia, + transport: http(pimlicoUrl), + paymaster: pimlicoClient, + userOperation: { + estimateFeesPerGas: async () => { + return (await pimlicoClient.getUserOperationGasPrice()).fast + }, + } + }) + + const userOpHash = await bundlerClient.sendUserOperation({ + calls: [{ + to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", + value: 0n, + data: "0x1234", + }] + }) + + const receipt = await bundlerClient.waitForUserOperationReceipt({ + hash: userOpHash, + }) + + console.log(`User operation included: https://sepolia.etherscan.io/tx/${receipt.receipt.transactionHash}`) + + const txHashMultiple = await bundlerClient.sendUserOperation({ + calls: [ + { + to: "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc", + value: 0n, + data: "0x1234", + }, + { + to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", + value: 0n, + data: "0x1234", + } + ], + }) + + const receipt2 = await bundlerClient.getUserOperationReceipt({ + hash: txHashMultiple, + }) -console.log(`User operation included: https://sepolia.etherscan.io/tx/${receipt.receipt.transactionHash}`) + console.log(`User operation included: https://sepolia.etherscan.io/tx/${receipt2.receipt.transactionHash}`) +} diff --git a/tutorial-3.ts b/tutorial-3.ts index 513641d..2621d98 100644 --- a/tutorial-3.ts +++ b/tutorial-3.ts @@ -77,7 +77,7 @@ const smartAccountClient = createSmartAccountClient({ client: publicClient, account, chain: sepolia, - transport: http(pimlicoUrl), + bundlerTransport: http(pimlicoUrl), paymaster: { async getPaymasterData(parameters) { const gasEstimates = await pimlicoClient.estimateUserOperationGas({