Skip to content

Go implementation of the Ethereum 4byte, openchain API client

License

Notifications You must be signed in to change notification settings

dbadoy/signature

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

signature

signature is a client implemented in Go that can query signatures from 4byte.directory, ethereum-lists, openchainxyz.
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

$ 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 repository.

package main

import (
	"fmt"

	"github.com/dbadoy/signature/file"
)

func main() {
	client, err := file.New(0)
	if err != nil {
		panic(err)
	}

	// [transfer(address,uint256)] <nil>
	fmt.Println(client.Signature("0xa9059cbb"))
	fmt.Println(client.Signature("a9059cbb"))
}

fourbytes client

Get the signature from the 4byte.directory API.

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)] <nil>
	fmt.Println(client.Signature("0xa9059cbb"))
	fmt.Println(client.Signature("a9059cbb"))
}

openchain client

Get the signature from the openchainxyz API.

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)] <nil>
	fmt.Println(client.Signature("0xa9059cbb"))
	fmt.Println(client.Signature("a9059cbb"))
}

About

Go implementation of the Ethereum 4byte, openchain API client

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages