77 getBlob ,
88 getBlobs ,
99 hexToBytes ,
10+ unprefixedHexToBytes ,
1011} from '@ethereumjs/util'
1112import { trustedSetup } from '@paulmillr/trusted-setups/fast-peerdas.js'
1213import { 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>
1718const filePath = process . argv [ 2 ]
18- const blobData : string = fs . readFileSync ( filePath , 'ascii' )
19+ const blobData : PrefixedHexString = `0x ${ fs . readFileSync ( filePath , 'ascii' ) } `
1920console . 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
3124const commitment = kzg . blobToKzgCommitment ( blobs [ 0 ] )
3225
@@ -37,6 +30,7 @@ const versionedHash = computeVersionedHash(commitment as PrefixedHexString, blob
3730const blobProof = blobsToProofs ( kzg , blobs , [ commitment as PrefixedHexString ] )
3831const cellProofs = blobsToCellProofs ( kzg , blobs )
3932
33+ console . log ( `Blob size : ${ hexToBytes ( blobData ) . length / 1024 } KiB` )
4034console . log ( `Commitment : ${ commitment } ` )
4135console . log ( `Versioned hash : ${ versionedHash } ` )
4236console . log ( `Blob proof (EIP-4844) : ${ blobProof } ` )
0 commit comments