4byte.directory API Client for Go.
Check out the endpoints or usage section for more information.
https://pkg.go.dev/github.com/0xhyim/fourbyte
go get -u github.com/0xhyim/fourbyte
Endpoint | Function |
---|---|
/api/v1/signatures | GetFunctionSignatures, GetFunctionSignatureById, CreateFunctionSignature |
/api/v1/event-signatures | GetEventSignatures, GetEventSignatureById, CreateEventSignature |
/api/v1/import-solidity | ImportFromSourceCode, ImportFromABI |
Refer to 4byte.directory Official API Documentation for more information.
The fourbyte
package provides access to all the endpoints listed above.
package main
import (
"context"
"fmt"
"log"
"github.com/0xhyim/fourbyte"
)
func main() {
response, err := fourbyte.GetFunctionSignatures(context.Background(), fourbyte.WithHexSignature("0x1249c58b"))
if err != nil {
log.Fatal(err)
}
// "mint()"
fmt.Println(response.Signatures[0].TextSignature)
}
package main
import (
"context"
"fmt"
"log"
"github.com/0xhyim/fourbyte"
)
func main() {
signatures := []fourbyte.Signature{}
response, err := fourbyte.GetFunctionSignatures(context.Background(), fourbyte.WithTextSignature("WETH"))
if err != nil {
log.Fatal(err)
}
signatures = append(signatures, response.Signatures...)
for response.Next != nil {
response, err = response.Next.Follow(context.Background())
if err != nil {
log.Fatal(err)
}
signatures = append(signatures, response.Signatures...)
}
fmt.Println(signatures)
}
- Add tests to project
- Add documentation/comments to code