-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
55 lines (43 loc) · 1.47 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { createPublicClient, http, parseEther } from 'viem'
import { createBundlerClient, createPaymasterClient, toCoinbaseSmartAccount } from 'viem/account-abstraction';
import { privateKeyToAccount } from 'viem/accounts';
import { mainnet, base } from 'viem/chains';
const jiffyscanKey = process.env.JIFFYSCAN_KEY as string;
const rpc = process.env.RPC as string;
const pvtKey = process.env.PVT_KEY as `0x${string}`;
const client = createPublicClient({
chain: base,
transport: http(rpc),
});
const owner = privateKeyToAccount(pvtKey);
const paymasterClient = createPaymasterClient({
transport: http("https://paymaster.jiffyscan.xyz/8453", {
fetchOptions: {
headers: { "x-api-key": jiffyscanKey },
},
})
})
const bundlerClient = createBundlerClient({
client,
paymaster: paymasterClient,
transport: http('https://base.jiffyscan.xyz', {
fetchOptions: {
headers: { "x-api-key": jiffyscanKey },
},
}),
});
const account = await toCoinbaseSmartAccount({
client,
owners: [owner]
});
console.log('smart account address - ', account.address);
const hash = await bundlerClient.sendUserOperation({
account,
calls: [{
to: '0xcb98643b8786950F0461f3B0edf99D88F274574D',
value: parseEther('0.000'),
}],
maxFeePerGas: BigInt('106833310'),
maxPriorityFeePerGas: BigInt('10000000'),
}) as string;
console.log('find user op here - https://jiffyscan.xyz/userOpHash/' + hash);