{"modulePath":"github.com/Evolution404/simcore","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package hexutil\n\nPackage hexutil implements hex encoding with 0x prefix. This encoding is used by the Ethereum RPC API to transport binary data in JSON payloads.\n\n### Encoding Rules {#hdr-Encoding_Rules}\n\nAll hex data must have prefix \"0x\".\n\nFor byte slices, the hex data must be of even length. An empty byte slice encodes as \"0x\".\n\nIntegers are encoded using the least amount of digits (no leading zero digits). Their encoding may be of uneven length. The number zero encodes as \"0x0\".\n\n## Variables\n\n```go\nvar (\n\tErrEmptyString   = \u0026decError{\"empty hex string\"}\n\tErrSyntax        = \u0026decError{\"invalid hex string\"}\n\tErrMissingPrefix = \u0026decError{\"hex string without 0x prefix\"}\n\tErrOddLength     = \u0026decError{\"hex string of odd length\"}\n\tErrEmptyNumber   = \u0026decError{\"hex string \\\"0x\\\"\"}\n\tErrLeadingZero   = \u0026decError{\"hex number with leading zero digits\"}\n\tErrUint64Range   = \u0026decError{\"hex number \u003e 64 bits\"}\n\tErrUintRange     = \u0026decError{fmt.Sprintf(\"hex number \u003e %d bits\", uintBits)}\n\tErrBig256Range   = \u0026decError{\"hex number \u003e 256 bits\"}\n)\n```\nErrors\n\n## Functions\n\n```go\nfunc Decode(input string) ([]byte, error)\n```\nDecode decodes a hex string with 0x prefix.\n\n```go\nfunc DecodeBig(input string) (*big.Int, error)\n```\nDecodeBig decodes a hex string with 0x prefix as a quantity. Numbers larger than 256 bits are not accepted.\n\n```go\nfunc DecodeUint64(input string) (uint64, error)\n```\nDecodeUint64 decodes a hex string with 0x prefix as a quantity.\n\n```go\nfunc Encode(b []byte) string\n```\nEncode encodes b as a hex string with 0x prefix.\n\n```go\nfunc EncodeBig(bigint *big.Int) string\n```\nEncodeBig encodes bigint as a hex string with 0x prefix.\n\n```go\nfunc EncodeUint64(i uint64) string\n```\nEncodeUint64 encodes i as a hex string with 0x prefix.\n\n```go\nfunc MustDecode(input string) []byte\n```\nMustDecode decodes a hex string with 0x prefix. It panics for invalid input.\n\n```go\nfunc MustDecodeBig(input string) *big.Int\n```\nMustDecodeBig decodes a hex string with 0x prefix as a quantity. It panics for invalid input.\n\n```go\nfunc MustDecodeUint64(input string) uint64\n```\nMustDecodeUint64 decodes a hex string with 0x prefix as a quantity. It panics for invalid input.\n\n```go\nfunc UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error\n```\nUnmarshalFixedJSON decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalJSON method for fixed-size types.\n\n```go\nfunc UnmarshalFixedText(typname string, input, out []byte) error\n```\nUnmarshalFixedText decodes the input as a string with 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.\n\n```go\nfunc UnmarshalFixedUnprefixedText(typname string, input, out []byte) error\n```\nUnmarshalFixedUnprefixedText decodes the input as a string with optional 0x prefix. The length of out determines the required input length. This function is commonly used to implement the UnmarshalText method for fixed-size types.\n\n## Types\n\n```go\ntype Big big.Int\n```\nBig marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as \"0x0\".\n\nNegative integers are not supported at this time. Attempting to marshal them will return an error. Values larger than 256bits are rejected by Unmarshal but will be marshaled without error.\n\n```go\nfunc (b Big) ImplementsGraphQLType(name string) bool\n```\nImplementsGraphQLType returns true if Big implements the provided GraphQL type.\n\n```go\nfunc (b Big) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler\n\n```go\nfunc (b *Big) String() string\n```\nString returns the hex encoding of b.\n\n```go\nfunc (b *Big) ToInt() *big.Int\n```\nToInt converts b to a big.Int.\n\n```go\nfunc (b *Big) UnmarshalGraphQL(input interface{}) error\n```\nUnmarshalGraphQL unmarshals the provided GraphQL query data.\n\n```go\nfunc (b *Big) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler.\n\n```go\nfunc (b *Big) UnmarshalText(input []byte) error\n```\nUnmarshalText implements encoding.TextUnmarshaler\n\n```go\ntype Bytes []byte\n```\nBytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as \"0x\".\n\n```go\nfunc (b Bytes) ImplementsGraphQLType(name string) bool\n```\nImplementsGraphQLType returns true if Bytes implements the specified GraphQL type.\n\n```go\nfunc (b Bytes) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler\n\n```go\nfunc (b Bytes) String() string\n```\nString returns the hex encoding of b.\n\n```go\nfunc (b *Bytes) UnmarshalGraphQL(input interface{}) error\n```\nUnmarshalGraphQL unmarshals the provided GraphQL query data.\n\n```go\nfunc (b *Bytes) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler.\n\n```go\nfunc (b *Bytes) UnmarshalText(input []byte) error\n```\nUnmarshalText implements encoding.TextUnmarshaler.\n\n```go\ntype Uint uint\n```\nUint marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as \"0x0\".\n\n```go\nfunc (b Uint) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler.\n\n```go\nfunc (b Uint) String() string\n```\nString returns the hex encoding of b.\n\n```go\nfunc (b *Uint) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler.\n\n```go\nfunc (b *Uint) UnmarshalText(input []byte) error\n```\nUnmarshalText implements encoding.TextUnmarshaler.\n\n```go\ntype Uint64 uint64\n```\nUint64 marshals/unmarshals as a JSON string with 0x prefix. The zero value marshals as \"0x0\".\n\n```go\nfunc (b Uint64) ImplementsGraphQLType(name string) bool\n```\nImplementsGraphQLType returns true if Uint64 implements the provided GraphQL type.\n\n```go\nfunc (b Uint64) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler.\n\n```go\nfunc (b Uint64) String() string\n```\nString returns the hex encoding of b.\n\n```go\nfunc (b *Uint64) UnmarshalGraphQL(input interface{}) error\n```\nUnmarshalGraphQL unmarshals the provided GraphQL query data.\n\n```go\nfunc (b *Uint64) UnmarshalJSON(input []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler.\n\n```go\nfunc (b *Uint64) UnmarshalText(input []byte) error\n```\nUnmarshalText implements encoding.TextUnmarshaler\n\n","path":"github.com/Evolution404/simcore/common/hexutil","name":"hexutil","synopsis":"Package hexutil implements hex encoding with 0x prefix.","isRedistributable":true}
