Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compilation ¶
type Compilation struct {
// Sources describes the CompiledSource objects provided in a compilation, housing information regarding source
// files, mappings, ASTs, and contracts.
Sources map[string]CompiledSource
}
Compilation represents the artifacts of a smart contract compilation.
func NewCompilation ¶
func NewCompilation() *Compilation
NewCompilation returns a new, empty Compilation object.
type CompiledContract ¶
type CompiledContract struct {
// Abi describes a contract's application binary interface, a structure used to describe information needed
// to interact with the contract such as constructor and function definitions with input/output variable
// information, event declarations, and fallback and receive methods.
Abi abi.ABI
// InitBytecode describes the bytecode used to deploy a contract.
InitBytecode []byte
// RuntimeBytecode represents the rudimentary bytecode to be expected once the contract has been successfully
// deployed. This may differ at runtime based on constructor arguments, immutables, linked libraries, etc.
RuntimeBytecode []byte
// SrcMapsInit describes the source mappings to associate source file and bytecode segments in InitBytecode.
SrcMapsInit string
// SrcMapsRuntime describes the source mappings to associate source file and bytecode segments in RuntimeBytecode.
SrcMapsRuntime string
}
CompiledContract represents a single contract unit from a smart contract compilation.
func (*CompiledContract) GetDeploymentMessageData ¶
func (c *CompiledContract) GetDeploymentMessageData(args []any) ([]byte, error)
GetDeploymentMessageData is a helper method used create contract deployment message data for the given contract. This data can be set in transaction/message structs "data" field to indicate the packed init bytecode and constructor argument data to use.
type CompiledSource ¶
type CompiledSource struct {
// Ast describes the abstract syntax tree artifact of a source file compilation, providing tokenization of the
// source file components.
Ast any
// Contracts describes a mapping of contract names to contract definition structures which are contained within
// the source.
Contracts map[string]CompiledContract
}
CompiledSource represents a source descriptor for a smart contract compilation, including AST and contained CompiledContract instances.
type ContractMetadata ¶
ContractMetadata is an CBOR-encoded structure describing contract information which is embedded within smart contract bytecode by the Solidity compiler (unless explicitly directed not to). Reference: https://docs.soliditylang.org/en/v0.8.16/metadata.html
func ExtractContractMetadata ¶
func ExtractContractMetadata(bytecode []byte) *ContractMetadata
ExtractContractMetadata extracts contract metadata from provided byte code and returns it. If contract metadata could not be extracted, nil is returned.
func (ContractMetadata) ExtractBytecodeHash ¶
func (m ContractMetadata) ExtractBytecodeHash() []byte
ExtractBytecodeHash extracts the bytecode hash from given contract metadata and returns the bytes representing the hash. If it could not be detected or extracted, nil is returned.