Coder Social home page Coder Social logo

dbadoy / signature Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 44 KB

Go implementation of the Ethereum 4byte, openchain API client

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%
ethereum ethereum-lists openchain signature 4bytes 4byte

signature's Introduction

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"))
}

signature's People

Contributors

dbadoy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

anhthii

signature's Issues

v0.8.73: need some test code

/fourbytes, /openchain

  • [update]client_test: TestConfigNil (If enter nil, make sure DefaultConfig is set)
  • [add]config_test: TestConfigValidate

ref:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.