Skip to content

Commit 3d31d4a

Browse files
committed
Add IsZero() for address.
1 parent 05c7e23 commit 3d31d4a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

types/address.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2021 - 2023 Attestant Limited.
1+
// Copyright © 2021 - 2024 Attestant Limited.
22
// Licensed under the Apache License, Version 2.0 (the "License");
33
// you may not use this file except in compliance with the License.
44
// You may obtain a copy of the License at
@@ -28,6 +28,13 @@ const AddressLength = 20
2828
// Address is a 20-byte execution layer address.
2929
type Address [AddressLength]byte
3030

31+
var emptyAddress = Address{}
32+
33+
// IsZero returns true if the address is zero.
34+
func (a Address) IsZero() bool {
35+
return bytes.Equal(a[:], emptyAddress[:])
36+
}
37+
3138
// String returns the EIP-55 string representation of the address.
3239
func (a Address) String() string {
3340
data := []byte(hex.EncodeToString(a[:]))

0 commit comments

Comments
 (0)