Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Created August 7, 2025 16:38
Show Gist options
  • Select an option

  • Save Turupawn/eb39161a20e090283b5280ff7bb5e3ef to your computer and use it in GitHub Desktop.

Select an option

Save Turupawn/eb39161a20e090283b5280ff7bb5e3ef to your computer and use it in GitHub Desktop.

Revisions

  1. Turupawn created this gist Aug 7, 2025.
    51 changes: 51 additions & 0 deletions pimlico.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    import 'dotenv/config'
    import { createPublicClient, http } from 'viem'
    import { scrollSepolia } from 'viem/chains'
    import { toSimpleSmartAccount } from 'permissionless/accounts'
    import { createSmartAccountClient } from 'permissionless'
    import { createPimlicoClient } from 'permissionless/clients/pimlico'
    import { privateKeyToAccount } from 'viem/accounts'

    async function main() {
    const apiKey = process.env.PIMLICO_API_KEY!
    const privateKey: `0x${string}` = process.env.PRIVATE_KEY! as `0x${string}`

    const publicClient = createPublicClient({
    chain: scrollSepolia,
    transport: http('https://sepolia-rpc.scroll.io')
    })

    const pimlicoUrl = `https://api.pimlico.io/v2/${scrollSepolia.id}/rpc?apikey=${apiKey}`
    const pimlicoClient = createPimlicoClient({
    chain: scrollSepolia,
    transport: http(pimlicoUrl)
    })

    const account = await toSimpleSmartAccount({
    client: publicClient,
    owner: privateKeyToAccount(privateKey)
    })
    console.log(`Smart account address: ${account.address}`)

    const smartAccountClient = createSmartAccountClient({
    account,
    chain: scrollSepolia,
    bundlerTransport: http(pimlicoUrl),
    paymaster: pimlicoClient,
    userOperation: {
    estimateFeesPerGas: async () =>
    (await pimlicoClient.getUserOperationGasPrice()).fast
    }
    })

    const txHash = await smartAccountClient.sendTransaction({
    to: '0xb6f5414bab8d5ad8f33e37591c02f7284e974fcb',
    value: 0n,
    data: '0x'
    })
    console.log(`Transaction included: ${txHash}`)
    /*
    */
    }

    main().catch(console.error)