Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofgazso committed Jan 14, 2024
0 parents commit e05474f
Show file tree
Hide file tree
Showing 106 changed files with 10,575 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# production
/dist
/docs/dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# typescript
*.tsbuildinfo
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a the repository for [Pimlico's documentation](https://docs.pimlico.io), created with [Vocs](https://vocs.dev).
35 changes: 35 additions & 0 deletions docs/components/generatePrivateKey.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useEffect, useState } from 'react'
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
import { HomePage } from 'vocs/components'

export function GeneratePrivateKey() {
const [privateKey, setPrivateKey] = useState()

useEffect(() => {
setPrivateKey(generatePrivateKey())
}, [])

return (
<div className='flex flex-col gap-4 p-6'>
<HomePage.Button onClick={async () => { setPrivateKey(generatePrivateKey()) }}>
Generate random private key
</HomePage.Button>

<div className='flex flex-row gap-3 px-2 text-sm'>
<div className='self-center'>Private key:</div>

<div className="font-mono self-center flex-1 text-center break-all">
{privateKey}
</div>
</div>

<div className='flex flex-row gap-3 px-2 text-sm'>
<div className='self-center'>Address:</div>

<div className="font-mono self-center flex-1 text-center break-all">
{privateKey ? privateKeyToAccount(privateKey).address : ""}
</div>
</div>
</div>
)
}
62 changes: 62 additions & 0 deletions docs/pages/bundler/how-to/bundle-a-user-operation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# How to Bundle a User Operation

To bundle a user operation, you need to use your [Pimlico API key](https://dashboard.pimlico.io/apikeys) and make a JSON-RPC request as follows:

::::code-group

```typescript [viem]
import { createPublicClient, http } from "viem"

const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at https://docs.pimlico.io/bundler
const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${pimlicoApiKey}`

const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

const pimlicoClient = createPublicClient({ transport: http(pimlicoEndpoint) })
const userOperationHash = await pimlicoClient.request({
// @ts-ignore
method: "eth_sendUserOperation",
params: [userOperation, entryPoint]
})
```

```typescript [ethers v5]
import { ethers } from "ethers"

const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at https://docs.pimlico.io/bundler
const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${pimlicoApiKey}`

const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

const pimlicoProvider = new ethers.providers.StaticJsonRpcProvider(pimlicoEndpoint)

const userOperationHash = await pimlicoProvider.send(
"eth_sendUserOperation",
[userOperation, entryPoint]
)
```

```typescript [ethers v6]
import { ethers } from "ethers"

const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at https://docs.pimlico.io/bundler
const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${pimlicoApiKey}`

const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

const pimlicoProvider = new ethers.JsonRpcProvider(pimlicoEndpoint)

const userOperationHash = await pimlicoProvider.send(
"eth_sendUserOperation",
[userOperation, entryPoint]
)
```

::::

74 changes: 74 additions & 0 deletions docs/pages/bundler/how-to/estimate-user-operation-gas-limits.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# How to Estimate the Gas Limits for a User Operation

To estimate the gas limits for a user operation, you need to use your [Pimlico API key](https://dashboard.pimlico.io/apikeys) and make a JSON-RPC request as follows:


::::code-group

```typescript [viem]
import { createPublicClient, http } from "viem"

const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at https://docs.pimlico.io/bundler
const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${pimlicoApiKey}`

const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

const pimlicoClient = createPublicClient({ transport: http(pimlicoEndpoint) })
const estimationResult = await pimlicoClient.request({
// @ts-ignore
method: "eth_estimateUserOperationGas",
params: [userOperation, entryPoint]
})

const preVerificationGas = estimationResult.preVerificationGas
const verificationGasLimit = estimationResult.verificationGasLimit
const callGasLimit = estimationResult.callGasLimit
```

```typescript [ethers v5]
import { ethers } from "ethers"

const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at https://docs.pimlico.io/bundler
const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${pimlicoApiKey}`

const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

const pimlicoProvider = new ethers.providers.StaticJsonRpcProvider(pimlicoEndpoint)

const estimationResult = await pimlicoProvider.send(
"eth_estimateUserOperationGas",
[userOperation, entryPoint]
)

const preVerificationGas = estimationResult.preVerificationGas
const verificationGasLimit = estimationResult.verificationGasLimit
const callGasLimit = estimationResult.callGasLimit
```

```typescript [ethers v6]
import { ethers } from "ethers"

const pimlicoApiKey = "YOUR_PIMLICO_API_KEY_HERE"
const chain = "sepolia" // find the list of supported chains at https://docs.pimlico.io/bundler
const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${pimlicoApiKey}`

const userOperation = ...
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"

const pimlicoProvider = new ethers.JsonRpcProvider(pimlicoEndpoint)

const estimationResult = await pimlicoProvider.send(
"eth_estimateUserOperationGas",
[userOperation, entryPoint]
)

const preVerificationGas = estimationResult.preVerificationGas
const verificationGasLimit = estimationResult.verificationGasLimit
const callGasLimit = estimationResult.callGasLimit
```

::::
27 changes: 27 additions & 0 deletions docs/pages/bundler/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Alto Bundler

![Landscape](https://i.imgur.com/qgVAdjN.png)

:::info
**In public beta**.
While Alto is functional, it is still in active development and is not feature-complete. If you would like to contribute, feel free to open a [Github Issue](https://github.com/pimlicolabs/alto/issues) or a [Pull Request](https://github.com/pimlicolabs/alto/pulls)
:::

Alto ⛰️ is a performant, type-safe ERC-4337 bundler written in Typescript.

Our focus is on full type safety, transaction inclusion reliability (even in the case of sudden gas price spikes or chain reorgs), as well as transaction inclusion speed.

## Tutorials

Learning-oriented lessons that take you through a series of steps to complete a project. Most useful when you want to get started with Pimlico. They all involve the Alto Bundler.

- [Tutorial 1](/permissionless/tutorial/tutorial-1) leverages the Alto Bundler to create a simple user operations and have it bundled on-chain.
- [Tutorial 2](/permissionless/tutorial/tutorial-2) leverages the Alto Bundler again, but using the [ERC-20 paymaster](/paymaster) instead of the Verifying Paymaster

## How-To Guides

Step-by-step instructions to accomplish a specific goal. They are useful when you are trying to find out how to do something with Pimlico.

## References

References provide specific technical descriptions. They are most useful when you need detailed information about Pimlico's APIs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Chain is not supported

The chain you are trying to use is not supported by Pimlico.

To see the list of supported chains, take a look at the relevant [bundler](/bundler/reference/supported-chains) and [paymaster](/paymaster/verifying-paymaster/reference/supported-chains) pages.

## Adding new chains

- [Reach out to us](https://t.me/pimlicoHQ) if you would like to see support for a new chain.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Invalid 'apikey' query parameter

The API key you are trying to use is not valid. It either does not exist or has been deleted.

You can find or generate an API key by going to our [dashboard](https://dashboard.pimlico.io).
7 changes: 7 additions & 0 deletions docs/pages/bundler/reference/bundler-errors/unknown-error.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Unknown error from alto bundler

The bundler encountered an unexpected error. This is either an internal 500 error, or an error with sensitive information that can not returned.

## Possible solutions

- [Reach out to us](https://t.me/pimlicoHQ) if you see this error.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# eth_estimateUserOperationGas

:::tip[Tip]
This method will *not* revert if the `signature` field in the user operation fails. However, most account implementations require the signature to be well formed, which usually means it must have the correct length.

For SimpleAccount, you can use the following dummy signature to put in the `signature` field during gas estimation:

```txt
0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c
```
:::

This method simulates the user operation and estimates the appropriate gas limits for it.

If the operation is not successful, it will return an error.

## Request

```json
{
"jsonrpc": "2.0",
"method": "eth_estimateUserOperationGas",
"params": [
{
"sender":"0xa203fDb8bC335F86016F635b85389B62B189E417",
"nonce":"0x35bf2a054f92f3730b87582ef223c8d663f9eb01158154750000000000000000",
"initCode":"0x",
"callData":"0xb61d27f6000000000000000000000000530fff22987e137e7c8d2adcc4c15eb45b4fa752000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000184165398be00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000002fcf1000000000000000000000000000000000000000000000000000000e8d4ac25fd000000000000000000000000000000000000000000000000000001d1a94f86e3000000000000000000000000000000000000000000000000000000e8d4ac13d6000000000000000000000000000000000000000000000000000001d1a94edaef000000000000000000000000000000000000000000000000000000e8d4ac25fa00000000000000000000000000000000000000000000000000000000",
"callGasLimit":"0x115b5c0",
"verificationGasLimit":"0x249f0",
"preVerificationGas":"0xeb11",
"maxPriorityFeePerGas":"0x12a05f200",
"maxFeePerGas":"0x5b08082fa",
"paymasterAndData":"0x",
"signature":"0xa6cc6589c8bd561cfd68d7b6b0757ef6f208e7438782939938498eee7d703260137856c840c491b3d415956265e81bf5c2184a725be2abfc365f7536b6af525e1c"
},
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
],
"id": 1
}
```

## Response

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"preVerificationGas": "0xc178",
"verificationGasLimit": "0x2a768",
"callGasLimit": "0x225ec"
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# eth_getUserOperationByHash

This method fetches the user operation, given the `userOpHash`. If the user operation is not available, it will return `null`.

## Request

```json
{
"jsonrpc": "2.0",
"method": "eth_getUserOperationReceipt",
"params": ["0xa5a579c6fd86c2d8a4d27f5bb22796614d3a31bbccaba8f3019ec001e001b95f"],
"id": 1
}
```

## Response

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"userOperation": {
"sender": "0x8C6bdb488F664EB98E12cB2671fE2389Cc227D33",
"nonce": "0x18554d9a95404c5e8ac591f8608a18f80000000000000000",
"initCode": "0xaee9762ce625e0a8f7b184670fb57c37bfe1d0f1296601cd000000000000000000000000417f5a41305ddc99d18b5e176521b468b2a31b86000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014c982ab3499d854fca39ff8326b27d3b8a9463c5d000000000000000000000000",
"callData": "0x519454470000000000000000000000008eb187a55b701f8990539bf219b7921d5d3bdadd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001647c7efe6b0000000000000000000000000000000000000000000000000000000000000080bfa0715290784075e564f966fffd9898ace1d7814f833780f62e59b0791357460000000000000000000000008c6bdb488f664eb98e12cb2671fe2389cc227d3300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000007677265676f7279000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001b1ec8da9a52488e3f60b7b7af36c2e64f1873e03a047c2c2e9061bbef4d0a9d8f1332b32afb163075273cd462140c2a24b2c9e1276adfaae0b4cb84ef78b95e8a0000000000000000000000000000000000000000000000000000000065a32e4f00000000000000000000000000000000000000000000000000000000",
"callGasLimit": "0x39b2d",
"verificationGasLimit": "0x6fb14",
"preVerificationGas": "0xc6a0",
"maxFeePerGas": "0x974038caf",
"maxPriorityFeePerGas": "0x974038c95",
"paymasterAndData": "0xe3dc822d77f8ca7ac74c30b0dffea9fcdcaaa3210000000000000000000000000000000000000000000000000000000065a3229b00000000000000000000000000000000000000000000000000000000000000009c3e8f934f2ec99974fddae7d38107a6d899c236c1b127e97d3c074cea5bb328023e295bb95254be40c47b82633676f8716c43c81aca3f2e49c2944afd1326371b",
"signature": "0x000000003ea0a3434dfd35a9eb05c4605466a7e05a5c3fc8aaba066c83bf4b43300dfd930e2203725eafa2702f860e5b6c18b4402ffb86b0d9b9c1719f1692254039810b1b"
},
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"transactionHash": "0x57465d20d634421008a167cfcfcde94847dba9d6b5d3652b071d4b84e5ce74ff",
"blockHash": "0xeaeec1eff4095bdcae44d86574cf1bf08b14b26be571b7c2290f32f9f250c103",
"blockNumber": "0x31de70e"
}
}
```
Loading

0 comments on commit e05474f

Please sign in to comment.