Skip to content

Commit cd52ef3

Browse files
committed
Added Hex methods
1 parent 142e812 commit cd52ef3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎common/types.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func HexToHash(s string) Hash { return BytesToHash(FromHex(s)) }
2727
func (h Hash) Str() string { return string(h[:]) }
2828
func (h Hash) Bytes() []byte { return h[:] }
2929
func (h Hash) Big() *big.Int { return Bytes2Big(h[:]) }
30+
func (h Hash) Hex() string { return "0x" + Bytes2Hex(h[:]) }
3031

3132
// Sets the hash to the value of b. If b is larger than len(h) it will panic
3233
func (h *Hash) SetBytes(b []byte) {
@@ -65,6 +66,7 @@ func (a Address) Str() string { return string(a[:]) }
6566
func (a Address) Bytes() []byte { return a[:] }
6667
func (a Address) Big() *big.Int { return Bytes2Big(a[:]) }
6768
func (a Address) Hash() Hash { return BytesToHash(a[:]) }
69+
func (a Address) Hex() string { return "0x" + Bytes2Hex(a[:]) }
6870

6971
// Sets the address to the value of b. If b is larger than len(a) it will panic
7072
func (a *Address) SetBytes(b []byte) {

0 commit comments

Comments
 (0)