https://github.com/dbadoy/signature
Go implementation of the Ethereum 4byte, openchain API client
https://github.com/dbadoy/signature
4byte 4bytes ethereum ethereum-lists openchain signature
Last synced: 30 days ago
JSON representation
Go implementation of the Ethereum 4byte, openchain API client
- Host: GitHub
- URL: https://github.com/dbadoy/signature
- Owner: dbadoy
- License: bsd-3-clause
- Created: 2023-05-15T08:43:21.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-07T13:36:06.000Z (almost 3 years ago)
- Last Synced: 2025-04-21T01:10:28.388Z (about 1 year ago)
- Topics: 4byte, 4bytes, ethereum, ethereum-lists, openchain, signature
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# signature
signature is a client implemented in Go that can query signatures from [4byte.directory](https://www.4byte.directory/), [ethereum-lists](https://github.com/ethereum-lists/4bytes), [openchainxyz](https://openchain.xyz/signatures).
`e.g. "0xa9059cbb" -> transfer(address,uint256)`
'ethereum-lists' is tied to '4byte.directory', and the difference is that '4byte.directory' is more real-time('ethereum-lists' has fewer signatures than '4byte.directory'). However, it's better for API users to have more endpoint options than one (4byte.directory, github.com, openchain.xyz).
### They have (2023-05-15)
ethereum-lists: `915,173`
4byte.directory: `1,210,015`
openchain: method `2,361,806`, event `372,441`
# Usage
## Install
```bash
$ go get -u github.com/dbadoy/signature
# OR `go mod tidy`
$ go get -u github.com/dbadoy/signature/file
$ go get -u github.com/dbadoy/signature/fourbytes
$ go get -u github.com/dbadoy/signature/openchain
```
### file client
Get the signature from the [ethereum-lists](https://github.com/ethereum-lists/4bytes) repository.
```go
package main
import (
"fmt"
"github.com/dbadoy/signature/file"
)
func main() {
client, err := file.New(0)
if err != nil {
panic(err)
}
// [transfer(address,uint256)]
fmt.Println(client.Signature("0xa9059cbb"))
fmt.Println(client.Signature("a9059cbb"))
}
```
### fourbytes client
Get the signature from the [4byte.directory](https://www.4byte.directory/) API.
```go
package main
import (
"fmt"
"github.com/dbadoy/signature/fourbytes"
)
func main() {
client, err := fourbytes.New(fourbytes.DefaultConfig())
if err != nil {
panic(err)
}
// [join_tg_invmru_haha_fd06787(address,bool) func_2093253501(bytes) transfer(bytes4[9],bytes5[6],int48[11]) many_msg_babbage(bytes1) transfer(address,uint256)]
fmt.Println(client.Signature("0xa9059cbb"))
fmt.Println(client.Signature("a9059cbb"))
}
```
### openchain client
Get the signature from the [openchainxyz](https://openchain.xyz/signatures) API.
```go
package main
import (
"fmt"
"github.com/dbadoy/signature/openchain"
)
func main() {
client, err := openchain.New(openchain.DefaultConfig())
if err != nil {
panic(err)
}
// [transfer(address,uint256)]
fmt.Println(client.Signature("0xa9059cbb"))
fmt.Println(client.Signature("a9059cbb"))
}
```