Skip to content

Commit

Permalink
Log transaction used gas
Browse files Browse the repository at this point in the history
  • Loading branch information
jelacamarko committed Jun 20, 2023
1 parent e292a20 commit c3aad08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion command/rootchain/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ func deployContracts(outputter command.OutputFormatter, client *jsonrpc.Client,

results[i] = newDeployContractsResult(contract.name,
types.Address(receipt.ContractAddress),
receipt.TransactionHash)
receipt.TransactionHash,
receipt.GasUsed)

return nil
}
Expand Down
7 changes: 6 additions & 1 deletion command/rootchain/deploy/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ type deployContractResult struct {
Name string `json:"name"`
Address types.Address `json:"address"`
Hash types.Hash `json:"hash"`
GasUsed uint64 `json:"gasUsed"`
}

func newDeployContractsResult(name string, address types.Address, hash ethgo.Hash) *deployContractResult {
func newDeployContractsResult(name string,
address types.Address,
hash ethgo.Hash, gasUsed uint64) *deployContractResult {
return &deployContractResult{
Name: name,
Address: address,
Hash: types.BytesToHash(hash.Bytes()),
GasUsed: gasUsed,
}
}

Expand All @@ -32,6 +36,7 @@ func (r deployContractResult) GetOutput() string {
vals = append(vals, fmt.Sprintf("Name|%s", r.Name))
vals = append(vals, fmt.Sprintf("Contract (address)|%s", r.Address))
vals = append(vals, fmt.Sprintf("Transaction (hash)|%s", r.Hash))
vals = append(vals, fmt.Sprintf("Transaction (gas used)|%d", r.GasUsed))

buffer.WriteString(helper.FormatKV(vals))
buffer.WriteString("\n")
Expand Down

0 comments on commit c3aad08

Please sign in to comment.