Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDeployCodeHash

func GetDeployCodeHash(code []byte, address crypto.Address) []byte

    GetDeployCodeHash deals with the issue described in https://github.com/ethereum/solidity/issues/7101 When a library contract (one declared with "libary { }" rather than "contract { }"), the deployed code will not match what the solidity compiler said it would be. This is done to implement "call protection"; library contracts are only supposed to be called from our solidity contracts, not directly. To prevent this, the library deployed code compares the callee address with the contract address itself. If it equal, it calls revert. The library contract address is only known post-deploy so this issue can only be handled post-deploy. This is why this is not dealt with during deploy time.

    func PrintResponse

    func PrintResponse(resp Response, cli bool, logger *logging.Logger)

    Types

    type ContractCode

    type ContractCode struct {
    	Object         string
    	LinkReferences json.RawMessage
    }

    type Metadata

    type Metadata struct {
    	ContractName    string
    	SourceFile      string
    	CompilerVersion string
    	Abi             json.RawMessage
    }

    type MetadataMap

    type MetadataMap struct {
    	DeployedBytecode ContractCode
    	Metadata         Metadata
    }

    type Response

    type Response struct {
    	Objects []ResponseItem `json:"objects"`
    	Warning string         `json:"warning"`
    	Version string         `json:"version"`
    	Error   string         `json:"error"`
    }

    func EVM

    func EVM(file string, optimize bool, workDir string, libraries map[string]string, logger *logging.Logger) (*Response, error)

    func WASM

    func WASM(file string, workDir string, logger *logging.Logger) (*Response, error)

    type ResponseItem

    type ResponseItem struct {
    	Filename   string           `json:"filename"`
    	Objectname string           `json:"objectname"`
    	Contract   SolidityContract `json:"binary"`
    }

      Compile response object

      type SolidityContract

      type SolidityContract struct {
      	Abi json.RawMessage
      	Evm struct {
      		Bytecode         ContractCode
      		DeployedBytecode ContractCode
      	}
      	EWasm struct {
      		Wasm string
      	}
      	Devdoc   json.RawMessage
      	Userdoc  json.RawMessage
      	Metadata string
      	// This is not present in the solidity output, but we add it ourselves
      	// This is map from DeployedBytecode to Metadata. A Solidity contract can create any number
      	// of contracts, which have distinct metadata. This is a map for the deployed code to metdata,
      	// including the first contract itself.
      	MetadataMap []MetadataMap `json:",omitempty"`
      }

        SolidityContract is defined for each contract defined in the solidity source code

        func LoadSolidityContract

        func LoadSolidityContract(file string) (*SolidityContract, error)

          LoadSolidityContract is the opposite of the .Save() method. This expects the input file to be in the Solidity json output format

          func (*SolidityContract) Code

          func (contract *SolidityContract) Code() (code string)

          func (*SolidityContract) GetMetadata

          func (contract *SolidityContract) GetMetadata(logger *logging.Logger) (map[acmstate.CodeHash]string, error)

            GetMetadata get the CodeHashes + Abis for the generated Code. So, we have a map for all the possible contracts codes hashes to abis

            func (contract *SolidityContract) Link(libraries map[string]string) error

              Link will replace the unresolved references with the libraries provided

              func (*SolidityContract) Save

              func (contract *SolidityContract) Save(dir, file string) error

                Save persists the contract in its json form to disk

                type SolidityInput

                type SolidityInput struct {
                	Language string                         `json:"language"`
                	Sources  map[string]SolidityInputSource `json:"sources"`
                	Settings struct {
                		Libraries map[string]map[string]string `json:"libraries"`
                		Optimizer struct {
                			Enabled bool `json:"enabled"`
                		} `json:"optimizer"`
                		OutputSelection struct {
                			File struct {
                				OutputType []string `json:"*"`
                			} `json:"*"`
                		} `json:"outputSelection"`
                	} `json:"settings"`
                }

                  SolidityInput is a structure for the solidity compiler input json form, see: https://solidity.readthedocs.io/en/v0.5.9/using-the-compiler.html#compiler-input-and-output-json-description

                  type SolidityInputSource

                  type SolidityInputSource struct {
                  	Content string   `json:"content,omitempty"`
                  	Urls    []string `json:"urls,omitempty"`
                  }

                    SolidityInputSource should be set for each solidity input source file in SolidityInput

                    type SolidityMetadata

                    type SolidityMetadata struct {
                    	Version string
                    	// The solidity compiler needs to tell us it compiles solidity
                    	Language string
                    	Compiler struct {
                    		Version   string
                    		Keccak256 string
                    	}
                    	Sources map[string]struct {
                    		Keccak256 string
                    		Content   string
                    		Urls      []string
                    	}
                    }

                      SolidityMetadata is the json field metadata

                      type SolidityOutput

                      type SolidityOutput struct {
                      	Contracts map[string]map[string]SolidityContract
                      	Errors    []struct {
                      		Component        string
                      		FormattedMessage string
                      		Message          string
                      		Severity         string
                      		Type             string
                      	}
                      }

                        SolidityOutput is a structure for the output of the solidity json output form

                        Source Files