Skip to content

Commit e21a35b

Browse files
ScottyPoiScottyPoi
authored andcommitted
fix blob example
1 parent 9ec290f commit e21a35b

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

packages/util/examples/blobs.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
getBlob,
88
getBlobs,
99
hexToBytes,
10+
unprefixedHexToBytes,
1011
} from '@ethereumjs/util'
1112
import { trustedSetup } from '@paulmillr/trusted-setups/fast-peerdas.js'
1213
import { KZG as microEthKZG } from 'micro-eth-signer/kzg.js'
@@ -15,18 +16,10 @@ const kzg = new microEthKZG(trustedSetup)
1516

1617
// Use with node ./examples/blobs.ts <file path>
1718
const filePath = process.argv[2]
18-
const blobData: string = fs.readFileSync(filePath, 'ascii')
19+
const blobData: PrefixedHexString = `0x${fs.readFileSync(filePath, 'ascii')}`
1920
console.log(blobData)
20-
console.log(blobData.length)
21-
//blobData = blobData.substring(0, 100)
2221

23-
const blobs = [getBlob(hexToBytes(`0x${blobData}`))]
24-
25-
//const blobData = 'hello'
26-
//const blobs = getBlobs(blobData)
27-
28-
console.log('Created the following blobs:')
29-
//console.log(blobs)
22+
const blobs = [blobData]
3023

3124
const commitment = kzg.blobToKzgCommitment(blobs[0])
3225

@@ -37,6 +30,7 @@ const versionedHash = computeVersionedHash(commitment as PrefixedHexString, blob
3730
const blobProof = blobsToProofs(kzg, blobs, [commitment as PrefixedHexString])
3831
const cellProofs = blobsToCellProofs(kzg, blobs)
3932

33+
console.log(`Blob size : ${hexToBytes(blobData).length / 1024}KiB`)
4034
console.log(`Commitment : ${commitment}`)
4135
console.log(`Versioned hash : ${versionedHash}`)
4236
console.log(`Blob proof (EIP-4844) : ${blobProof}`)

0 commit comments

Comments
 (0)