Documentation
¶
Overview ¶
Package hex provides common utilities and constants for Ethereum contract interactions.
Package hex provides common utilities and constants for Ethereum contract interactions.
Index ¶
- Constants
- Variables
- func CheckDiamondFunction(ctx context.Context, client simulated.Client, diamondAddr common.Address, ...) (bool, error)
- func DecodeErrorData(data interface{}) []byte
- func DeployContract(auth *bind.TransactOpts, client simulated.Client, abiString string, ...) (common.Address, *ethTypes.Transaction, *bind.BoundContract, error)
- func GetEncodedFunction(abiString, signature string, params ...interface{}) ([]byte, error)
- func GetImplementationAddress(ctx context.Context, client simulated.Client, proxyAddr common.Address) (common.Address, error)
- func ParseEther(a *big.Int) float64
- type Signature
Constants ¶
View Source
const ( // ErrorMethodIDLength is the length of Ethereum error method ID in bytes ErrorMethodIDLength = 4 // DecimalBase is the base for decimal number parsing DecimalBase = 10 // TestChainID is the chain ID used for testing TestChainID = 1337 // TestGasLimit is the gas limit used for testing TestGasLimit = 9_000_000 // Uint256BitSize is the bit size for uint256 values Uint256BitSize = 256 // MaxUint256Offset is the offset used in MaxUint256 calculation MaxUint256Offset = 9 )
Variables ¶
View Source
var ( // IERC721InterfaceID is the interface ID for ERC721 tokens IERC721InterfaceID = [4]byte{0x80, 0xac, 0x58, 0xcd} // IERC20InterfaceID is the interface ID for ERC20 tokens IERC20InterfaceID = [4]byte{0x36, 0x37, 0x2b, 0x07} // IERC1155InterfaceID is the interface ID for ERC1155 tokens IERC1155InterfaceID = [4]byte{0xd9, 0xb6, 0x7a, 0x26} )
View Source
var ( // ErrZeroAddress is returned when the zero address is used ErrZeroAddress = errors.New("TransferToZeroAddress") )
View Source
var ( // MaxUint256 represents the maximum value for a uint256 MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), Uint256BitSize), big.NewInt(MaxUint256Offset)) )
Functions ¶
func CheckDiamondFunction ¶
func CheckDiamondFunction( ctx context.Context, client simulated.Client, diamondAddr common.Address, funcSelector []byte, ) (bool, error)
CheckDiamondFunction checks if a function selector is supported by a Diamond proxy contract
func DecodeErrorData ¶
func DecodeErrorData(data interface{}) []byte
DecodeErrorData decodes hex-encoded error data from various input formats.
func DeployContract ¶
func DeployContract(auth *bind.TransactOpts, client simulated.Client, abiString string, byteCodeString string, params ...interface{}, ) (common.Address, *ethTypes.Transaction, *bind.BoundContract, error)
DeployContract deploys a contract with the given parameters
func GetEncodedFunction ¶
GetEncodedFunction encodes a function call with the given parameters
func GetImplementationAddress ¶
func GetImplementationAddress( ctx context.Context, client simulated.Client, proxyAddr common.Address, ) (common.Address, error)
GetImplementationAddress retrieves the implementation address from an EIP-1967 proxy contract
func ParseEther ¶
ParseEther converts a big.Int wei value to a float64 ether value
Types ¶
Click to show internal directories.
Click to hide internal directories.