Skip to content

Commit

Permalink
pay for blob
Browse files Browse the repository at this point in the history
  • Loading branch information
csdtowards committed Jul 16, 2024
1 parent 5616d1a commit 6e14817
Show file tree
Hide file tree
Showing 3 changed files with 2,295 additions and 192 deletions.
9 changes: 9 additions & 0 deletions disperser/contract/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,21 @@ func (c *DAContract) SubmitOriginalData(dataRoots []eth_common.Hash, waitForRece
params[i] = dataRoot
}

blobPrice, err := c.BlobPrice(nil)
if err != nil {
return eth_common.Hash{}, nil, errors.WithMessage(err, "Failed to get blob price")
}

// Submit log entry to smart contract.
opts, err := c.CreateTransactOpts()
if err != nil {
return eth_common.Hash{}, nil, errors.WithMessage(err, "Failed to create opts to send transaction")
}

opts.Value = new(big.Int)
txValue := new(big.Int).SetUint64(uint64(len(dataRoots)))
opts.Value.Mul(blobPrice, txValue)

tx, err := c.DAEntrance.SubmitOriginalData(opts, params)

if err != nil {
Expand Down
Loading

0 comments on commit 6e14817

Please sign in to comment.