Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/eip7594-peerdas-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"viem": minor
---

Added EIP-7594 (PeerDAS) blob support.

**Breaking Changes**

`blobsToProofs` now returns an array of arrays (`ByteArray[][] | Hex[][]`) instead of a flat array. Each blob gets its own array of proofs to support EIP-7594's cell proofs (128 proofs per blob).

```ts
// Before (EIP-4844 only)
const proofs = blobsToProofs({ blobs, commitments, kzg })
// proofs = [proof1, proof2, ...]

// After (supports both EIP-4844 and EIP-7594)
const proofs = blobsToProofs({ blobs, commitments, kzg, blobVersion: '7594' })
// EIP-4844: proofs = [[proof1], [proof2], ...]
// EIP-7594: proofs = [[proof1, ...proof128], [proof129, ...proof256], ...]
```

**Features**

- Added EIP-7594 blob transaction support with 128 cell proofs per blob
- Automatic blob version detection based on chain ID (Sepolia uses EIP-7594)
- `parseTransaction` now handles 5-element EIP-7594 wrapper arrays with version byte
- `BlobSidecar.proof` type updated to support both single proof and proof arrays
- `serializeTransaction` correctly flattens proof arrays for both EIP standards

**Implementation**

- Updated `blobsToProofs` to use `computeCellsAndKzgProofs` for EIP-7594
- Enhanced `parseTransaction` to detect and parse EIP-7594 wrapper format
- Modified `toBlobSidecars` to handle variable-length proof arrays
- Added chain-based blob version detection (Sepolia = EIP-7594, others = EIP-4844)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.29.7",
"@ethereumjs/rlp": "^5.0.2",
"@paulmillr/trusted-setups": "^0.1.2",
"@paulmillr/trusted-setups": "^0.3.0",
"@pimlico/alto": "0.0.18",
"@size-limit/preset-big-lib": "^11.2.0",
"@types/bun": "^1.2.22",
Expand All @@ -63,7 +63,7 @@
"ethers": "^6.15.0",
"glob": "^10.4.5",
"knip": "^5.64.0",
"micro-eth-signer": "^0.14.0",
"micro-eth-signer": "^0.17.3",
"permissionless": "^0.2.57",
"prool": "0.0.24",
"publint": "^0.2.12",
Expand Down
91 changes: 49 additions & 42 deletions pnpm-lock.yaml

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

5 changes: 4 additions & 1 deletion site/pages/docs/guides/blob-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

Blob Transactions are a new type of transaction in Ethereum (introduced in [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)) that allows you to broadcast BLObs (Binary Large Objects) to the Ethereum network. Blob Transactions are like any other transaction, but with the added ability to carry a payload of Blobs. Blobs are extremely larger than regular calldata (~128kB), however unlike regular calldata, they are not accessible on the EVM. The EVM can only view the commitments of the blobs. Blobs are also transient, and only last for 4096 epochs (approx. 18 days).

To read more on Blob Transactions and EIP-4844, check out these resources:
Viem also supports [EIP-7594](https://eips.ethereum.org/EIPS/eip-7594) (PeerDAS) blobs, which use a different proof format. On Sepolia, EIP-7594 is automatically used, while other chains default to EIP-4844.

To read more on Blob Transactions and EIP-4844, check out these resources:

- [EIP-4844 Spec](https://eips.ethereum.org/EIPS/eip-4844)
- [EIP-7594 Spec](https://eips.ethereum.org/EIPS/eip-7594)
- [EIP-4844 Website](https://www.eip4844.com/#faq)
- [EIP-4844 FAQ](https://notes.ethereum.org/@vbuterin/proto_danksharding_faq#Proto-Danksharding-FAQ)

Expand Down
26 changes: 24 additions & 2 deletions site/pages/docs/utilities/blobsToProofs.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,31 @@ const blobs = toBlobs({ data: '0x...' })
const kzg = setupKzg(cKzg, mainnetTrustedSetupPath) // [!code focus]
const commitments = blobsToCommitments({ blobs, kzg })

const proofs = blobsToProofs({
const proofs = blobsToProofs({
blobs,
commitments,
kzg, // [!code focus]
})
})
```

### blobVersion (optional)

- **Type:** `'4844' | '7594'`
- **Default:** `'4844'`

The blob version to use for proof generation. Defaults to `'4844'` (EIP-4844). Use `'7594'` for EIP-7594 (PeerDAS) blobs.

```ts twoslash
import { blobsToCommitments, blobsToProofs, toBlobs } from 'viem'
import { kzg } from './kzg'

const blobs = toBlobs({ data: '0x...' })
const commitments = blobsToCommitments({ blobs, kzg })

const proofs = blobsToProofs({
blobs,
commitments,
kzg,
blobVersion: '7594', // [!code focus]
})
```
26 changes: 22 additions & 4 deletions site/pages/docs/utilities/toBlobSidecars.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,32 @@ const kzg = defineKzg({} as any)
// ---cut---
import { toBlobSidecars, toBlobs } from 'viem'

const sidecars = toBlobSidecars({
const sidecars = toBlobSidecars({
data: '0x1234',
kzg,
to: 'bytes', // [!code focus]
})
kzg,
to: 'bytes', // [!code focus]
})

sidecars // [!code focus]
// ^?


```

### blobVersion (optional)

- **Type:** `'4844' | '7594'`
- **Default:** `'4844'`

The blob version to use for proof generation. Defaults to `'4844'` (EIP-4844). Use `'7594'` for EIP-7594 (PeerDAS) blobs.

```ts twoslash
import { toBlobSidecars } from 'viem'
import { kzg } from './kzg'

const sidecars = toBlobSidecars({
data: '0x...',
kzg,
blobVersion: '7594', // [!code focus]
})
```
4 changes: 2 additions & 2 deletions src/actions/wallet/sendRawTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ test('default', async () => {
test.skip('4844', async () => {
const client = createClient({
chain: sepolia,
transport: http('https://ethereum-sepolia-rpc.publicnode.com'),
transport: http(process.env.RPC_URL!),
})

const privateKey = '0x'
const privateKey = process.env.PRIVATE_KEY as `0x${string}`
const account = privateKeyToAccount(privateKey)
const blobs = toBlobs({ data: stringToHex(blobData) })
const nonce = await getTransactionCount(client, {
Expand Down
Loading
Loading