diff options
Diffstat (limited to 'accounts/abi/abi.go')
-rw-r--r-- | accounts/abi/abi.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 7229a67bf..cbcf4ca92 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -17,6 +17,7 @@ package abi import ( + "bytes" "encoding/json" "fmt" "io" @@ -133,3 +134,14 @@ func (abi *ABI) UnmarshalJSON(data []byte) error { return nil } + +// MethodById looks up a method by the 4-byte id +// returns nil if none found +func (abi *ABI) MethodById(sigdata []byte) *Method { + for _, method := range abi.Methods { + if bytes.Equal(method.Id(), sigdata[:4]) { + return &method + } + } + return nil +} |