Skip to content

Commit

Permalink
update tut with rc-5
Browse files Browse the repository at this point in the history
  • Loading branch information
plusminushalf committed Aug 29, 2024
1 parent 6706dd3 commit 6e13fa4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
26 changes: 20 additions & 6 deletions tutorial-1.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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: [
Expand All @@ -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}`)
}

{
Expand Down

0 comments on commit 6e13fa4

Please sign in to comment.