From 6e13fa41b1f607957dbb763f946361079cd15226 Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Thu, 29 Aug 2024 10:50:23 +0100 Subject: [PATCH] update tut with rc-5 --- package-lock.json | 8 ++++---- package.json | 2 +- tutorial-1.ts | 26 ++++++++++++++++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 076258c..8a0f579 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.20240828T162812", + "permissionless": "0.2.0-rc-5", "viem": "2.20.0" }, "devDependencies": { @@ -554,9 +554,9 @@ } }, "node_modules/permissionless": { - "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==", + "version": "0.2.0-rc-5", + "resolved": "https://registry.npmjs.org/permissionless/-/permissionless-0.2.0-rc-5.tgz", + "integrity": "sha512-aZhr7/jrXSjYk5yBKXtragikFxsDBL+LaUrbjPmAqbOcsNz3lQk96ga4QOcAJUQZbBs0ZGtZ4IM7l6qp1MUDcA==", "peerDependencies": { "viem": "^2.20.0" } diff --git a/package.json b/package.json index 2752d5b..670770a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "license": "MIT", "dependencies": { "dotenv": "^16.3.1", - "permissionless": "0.0.0-v0-2.20240828T162812", + "permissionless": "0.2.0-rc-5", "viem": "2.20.0" }, "devDependencies": { diff --git a/tutorial-1.ts b/tutorial-1.ts index 669f50f..ec7763e 100644 --- a/tutorial-1.ts +++ b/tutorial-1.ts @@ -1,7 +1,7 @@ import "dotenv/config" import { writeFileSync } from "fs" import { toSafeSmartAccount } from "permissionless/accounts" -import { Hex, createPublicClient, http } from "viem" +import { Hex, createPublicClient, getContract, http } from "viem" import { generatePrivateKey, privateKeyToAccount } from "viem/accounts" import { sepolia } from "viem/chains" import { createPimlicoClient } from "permissionless/clients/pimlico" @@ -70,7 +70,20 @@ const pimlicoClient = createPimlicoClient({ }) - console.log(`User operation included: https://sepolia.etherscan.io/tx/${txHash}`) + console.log(`User operation with single transaction included: https://sepolia.etherscan.io/tx/${txHash}`) + + const contract = getContract({ + address: "0x6D7A849791a8E869892f11E01c2A5f3b25a497B6", + abi: [{"inputs":[],"name":"getLastGreeter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greet","outputs":[],"stateMutability":"nonpayable","type":"function"}], + client: { + public: publicClient, + wallet: smartAccountClient, + } + }) + + const txHash2 = await contract.write.greet() + + console.log(`User operation with contract call included: https://sepolia.etherscan.io/tx/${txHash2}`) const txHashMultiple = await smartAccountClient.sendTransaction({ calls: [ @@ -80,14 +93,15 @@ const pimlicoClient = createPimlicoClient({ data: "0x1234", }, { - to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", - value: 0n, - data: "0x1234", + abi: [{"inputs":[],"name":"getLastGreeter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greet","outputs":[],"stateMutability":"nonpayable","type":"function"}], + functionName: "greet", + args: [], + to: "0x6D7A849791a8E869892f11E01c2A5f3b25a497B6" } ], }) - console.log(`User operation included: https://sepolia.etherscan.io/tx/${txHashMultiple}`) + console.log(`User operation with multiple transactions included: https://sepolia.etherscan.io/tx/${txHashMultiple}`) } {