Skip to content

Commit

Permalink
Add IsZero() for address.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Oct 28, 2024
1 parent 05c7e23 commit 3d31d4a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion types/address.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 - 2023 Attestant Limited.
// Copyright © 2021 - 2024 Attestant Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -28,6 +28,13 @@ const AddressLength = 20
// Address is a 20-byte execution layer address.
type Address [AddressLength]byte

var emptyAddress = Address{}

// IsZero returns true if the address is zero.
func (a Address) IsZero() bool {
return bytes.Equal(a[:], emptyAddress[:])
}

// String returns the EIP-55 string representation of the address.
func (a Address) String() string {
data := []byte(hex.EncodeToString(a[:]))
Expand Down

0 comments on commit 3d31d4a

Please sign in to comment.