diff --git a/structs.go b/structs.go index 699d5899..c5b0c156 100644 --- a/structs.go +++ b/structs.go @@ -148,6 +148,7 @@ type Block struct { Transactions []*Transaction TransactionsHashes []Hash Uncles []Hash + BaseFee *big.Int } func (b *Block) Copy() *Block { diff --git a/structs_marshal.go b/structs_marshal.go index b88e079e..a8f2ec11 100644 --- a/structs_marshal.go +++ b/structs_marshal.go @@ -66,6 +66,10 @@ func (t *Block) MarshalJSON() ([]byte, error) { o.Set("mixHash", a.NewString("0x"+hex.EncodeToString(t.MixHash[:]))) o.Set("nonce", a.NewString("0x"+hex.EncodeToString(t.Nonce[:]))) + if t.BaseFee != nil { + o.Set("baseFee", a.NewString(fmt.Sprintf("0x%x", t.BaseFee))) + } + // uncles if len(t.Uncles) != 0 { uncles := a.NewArray() diff --git a/structs_unmarshal.go b/structs_unmarshal.go index a3f28c0b..66c14d9c 100644 --- a/structs_unmarshal.go +++ b/structs_unmarshal.go @@ -67,6 +67,11 @@ func (b *Block) UnmarshalJSON(buf []byte) error { if b.ExtraData, err = decodeBytes(b.ExtraData[:0], v, "extraData"); err != nil { return err } + if b.BaseFee, err = decodeBigInt(b.BaseFee, v, "baseFee"); err != nil { + if err.Error() != "field 'baseFee' not found" { + return err + } + } b.TransactionsHashes = b.TransactionsHashes[:0] b.Transactions = b.Transactions[:0]