bech32

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HexToBech32Method defines the ABI method name to convert a EIP-55
	// hex formatted address to bech32 address string.
	HexToBech32Method = "hexToBech32"
	// Bech32ToHexMethod defines the ABI method name to convert a bech32
	// formatted address string to an EIP-55 address.
	Bech32ToHexMethod = "bech32ToHex"
)
View Source
const (
	// PrecompileAddress defines the address of the bech32 precompile contract.
	PrecompileAddress = "0x0000000000000000000000000000000000000400"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Precompile

type Precompile struct {
	abi.ABI
	// contains filtered or unexported fields
}

Precompile defines the precompiled contract for Bech32 encoding.

func NewPrecompile

func NewPrecompile(baseGas uint64) (*Precompile, error)

NewPrecompile creates a new bech32 Precompile instance as a PrecompiledContract interface.

func (Precompile) Address

func (Precompile) Address() common.Address

Address defines the address of the bech32 compile contract. address: 0x0000000000000000000000000000000000000400

func (Precompile) Bech32ToHex

func (p Precompile) Bech32ToHex(
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Bech32ToHex converts a bech32 address to its corresponding EIP-55 hex format. The Human Readable Prefix (HRP) must be provided in the arguments. This function fails if the address is invalid or if the bech32 conversion fails.

func (Precompile) HexToBech32

func (p Precompile) HexToBech32(
	method *abi.Method,
	args []interface{},
) ([]byte, error)

HexToBech32 converts a hex address to its corresponding Bech32 format. The Human Readable Prefix (HRP) must be provided in the arguments. This function fails if the address is invalid or if the bech32 conversion fails.

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(_ []byte) uint64

RequiredGas calculates the contract gas use.

func (Precompile) Run

func (p Precompile) Run(_ *vm.EVM, contract *vm.Contract, _ bool) (bz []byte, err error)

Run executes the precompiled contract bech32 methods defined in the ABI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL