1+ import { resolve } from 'node:path' ;
12import { config } from 'dotenv' ;
2- import { resolve } from 'path' ;
33
44// Load root .env first (defaults)
55config ( { path : resolve ( __dirname , '../../../../.env' ) } ) ;
66
77// Load local .env to override (optional)
88config ( { override : true } ) ;
99
10- import { createGelatoBundlerClient , sponsored } from '@gelatocloud/gasless' ;
11- import { toKernelSmartAccount } from 'permissionless/accounts' ;
12- import { createPublicClient , type Hex , http } from 'viem' ;
10+ import { createGelatoBundlerClient , sponsored , toGelatoSmartAccount } from '@gelatocloud/gasless' ;
11+ import { createPublicClient , type Hex , http , type SignedAuthorization } from 'viem' ;
1312import { generatePrivateKey , privateKeyToAccount } from 'viem/accounts' ;
1413import { baseSepolia } from 'viem/chains' ;
1514
@@ -30,11 +29,9 @@ const main = async () => {
3029 transport : http ( )
3130 } ) ;
3231
33- const account = await toKernelSmartAccount ( {
32+ const account = toGelatoSmartAccount ( {
3433 client,
35- owners : [ owner ] ,
36- useMetaFactory : false ,
37- version : '0.3.3'
34+ owner
3835 } ) ;
3936
4037 const bundler = await createGelatoBundlerClient ( {
@@ -45,7 +42,22 @@ const main = async () => {
4542 pollingInterval : 100
4643 } ) ;
4744
45+ const deployed = await account . isDeployed ( ) ;
46+
47+ let authorization : SignedAuthorization | undefined ;
48+
49+ if ( ! deployed ) {
50+ const nonce = await client . getTransactionCount ( { address : owner . address } ) ;
51+
52+ authorization = await owner . signAuthorization ( {
53+ address : account . authorization . address ,
54+ chainId : chain . id ,
55+ nonce
56+ } ) ;
57+ }
58+
4859 const hash = await bundler . sendUserOperation ( {
60+ authorization,
4961 calls : [
5062 {
5163 data : '0xd09de08a' ,
0 commit comments