Documentation ¶
Overview ¶
Package bytecode provides requisite structs and utility functions to build and validate unlinked and unlinked bytecode objects for the ethpm v2 manifest. Information about these objects can be found here http://ethpm.github.io/ethpm-spec/package-spec.html#the-bytecode-object
Index ¶
- func GetVersion(t string) (version string, err error)
- type CompilerInformation
- func (c *CompilerInformation) Build(compiler string, settingsjsonstring string) (err error)
- func (c *CompilerInformation) SetName(t string)
- func (c *CompilerInformation) SetSettingsFromJSON(jsonstring string) (err error)
- func (c *CompilerInformation) SetVersion(t string) (err error)
- func (c *CompilerInformation) Validate() (err error)
- type LinkedBytecode
- type StandardJSONBC
- type UnlinkedBytecode
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetVersion ¶
GetVersion takes the name of the compiler and returns the version being used. Currently only tested against "solc --version" output
Types ¶
type CompilerInformation ¶
type CompilerInformation struct { Name string `json:"name"` Settings interface{} `json:"settings,omitempty"` Version string `json:"version"` }
CompilerInformation Information about the software that was used to compile a contract type or instance
Example ¶
c := &CompilerInformation{} if err := c.SetVersion("solc"); err != nil { log.Fatal(err) } s := `{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": ["abi", "evm.bytecode", "evm.deployedBytecode"] } } }` if err := c.SetSettingsFromJSON(s); err != nil { log.Fatal(err) }
Output:
func (*CompilerInformation) Build ¶
func (c *CompilerInformation) Build(compiler string, settingsjsonstring string) (err error)
Build takes the compiler name, such as "solc", and the 'settings' object from the standard input json and builds the CompilerInformation object
func (*CompilerInformation) SetName ¶
func (c *CompilerInformation) SetName(t string)
SetName sets the name of the compiler, such as "solc"
func (*CompilerInformation) SetSettingsFromJSON ¶
func (c *CompilerInformation) SetSettingsFromJSON(jsonstring string) (err error)
SetSettingsFromJSON accepts the 'settings' key from solc standard input json as a string and assigns it to the PackageManifest compiler information
func (*CompilerInformation) SetVersion ¶
func (c *CompilerInformation) SetVersion(t string) (err error)
SetVersion takes the name of the compiler and sets the version. The compiler must be installed on your system. Currently only tested against "solc --version" output
func (*CompilerInformation) Validate ¶
func (c *CompilerInformation) Validate() (err error)
Validate ensures ContractType conforms to the standard defined here https://ethpm.github.io/ethpm-spec/package-spec.html#the-compiler-information-object
type LinkedBytecode ¶
type LinkedBytecode struct { Bytecode string `json:"bytecode,omitempty"` LinkDependencies []*liblink.LinkValue `json:"link_dependencies,omitempty"` LinkReferences []*liblink.LinkReference `json:"link_references,omitempty"` }
LinkedBytecode A bytecode object for linked bytecode
func (*LinkedBytecode) AddLinkDependencies ¶
func (lb *LinkedBytecode) AddLinkDependencies(lv []*liblink.LinkValue)
AddLinkDependencies will take an array of LinkValue objects and add them to the LinkedBytecode object. This function is not currently built into any compiler or deployment workflow.
func (*LinkedBytecode) AddLinkReference ¶
func (lb *LinkedBytecode) AddLinkReference(lr []*liblink.LinkReference)
AddLinkReference will take an array of LinkReference objects and add them to the LinkedBytecode object. This function is not currently built into any compiler or deployment workflow.
func (*LinkedBytecode) Build ¶
func (lb *LinkedBytecode) Build(bc string) (err error)
Build the linked bytecode string and create a LinkedBytecode struct. Each dependency and reference for LinkedBytecode should be added through the AddLinkDependencies and AddLinkReference utility functions.
func (*LinkedBytecode) Validate ¶
func (lb *LinkedBytecode) Validate(dependencyLengths map[string]int) (err error)
Validate with LinkedBytecode ensures the LinkedBytecode object conforms to the standard described here https://ethpm.github.io/ethpm-spec/package-spec.html#bytecode
type StandardJSONBC ¶
type StandardJSONBC struct { LinkReferences map[string]map[string][]map[string]int `json:"linkReferences,omitempty"` Object string `json:"object,omitempty"` }
StandardJSONBC is the bytecode or deployedBytecode object from a compiler's standard JSON output object
type UnlinkedBytecode ¶
type UnlinkedBytecode struct { Bytecode string `json:"bytecode,omitempty"` LinkReferences []*liblink.LinkReference `json:"link_references,omitempty"` }
UnlinkedBytecode A bytecode object for unlinked bytecode.
Example ¶
ub := UnlinkedBytecode{} ub.Build(`{ "linkReferences": { "./node_modules/ethereum-libraries-token/contracts/TokenLib.sol": { "TokenLib": [{ "length": 20, "start": 184 }, { "length": 20, "start": 1802 }, { "length": 20, "start": 1998 }, { "length": 20, "start": 2213 }, { "length": 20, "start": 2379 }, { "length": 20, "start": 2518 }, { "length": 20, "start": 2739 }, { "length": 20, "start": 2870 }, { "length": 20, "start": 3002 }] } }, "object": "608060405234801561001057600080fd5b50604051610da0380380610da08339810160408181528251602080850151928501516060860151608087015160a08801517f93292972000000000000000000000000000000000000000000000000000000008852600060048901818152600160a060020a03881660248b015260ff851660848b015260a48a0184905282151560c48b015260e060448b01908152988b01805160e48c01528051989b909a96019894979396929573__./node_modules/ethereum-libraries-to__9563932929729593948d948d948d948d948d948d9491926064810192610104909101918a01908083838f5b8381101561010e5781810151838201526020016100f6565b50505050905090810190601f16801561013b5780820380516001836020036101000a031916815260200191505b50838103825287518152875160209182019189019080838360005b8381101561016e578181015183820152602001610156565b50505050905090810190601f16801561019b5780820380516001836020036101000a031916815260200191505b50995050505050505050505060006040518083038186803b1580156101bf57600080fd5b505af41580156101d3573d6000803e3d6000fd5b50505050505050505050610bb4806101ec6000396000f3006080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d4578063095ea7b31461015e57806318160ddd1461019657806323b872dd146101bd578063313ce567146101e7578063378dc3dc1461021257806370a08231146102275780637b47ec1a146102485780638bbdfaa61461026057806395d89b4114610289578063a6f9dae11461029e578063a9059cbb146102bf578063dd62ed3e146102e3578063fc0c546a1461030a575b600080fd5b3480156100e057600080fd5b506100e961043e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012357818101518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016a57600080fd5b50610182600160a060020a03600435166024356104d4565b604080519115158252519081900360200190f35b3480156101a257600080fd5b506101ab61058a565b60408051918252519081900360200190f35b3480156101c957600080fd5b50610182600160a060020a0360043581169060243516604435610590565b3480156101f357600080fd5b506101fc61064f565b6040805160ff9092168252519081900360200190f35b34801561021e57600080fd5b506101ab610670565b34801561023357600080fd5b506101ab600160a060020a0360043516610676565b34801561025457600080fd5b50610182600435610724565b34801561026c57600080fd5b50610182600160a060020a03600435166024356044351515610798565b34801561029557600080fd5b506100e9610823565b3480156102aa57600080fd5b50610182600160a060020a0360043516610884565b3480156102cb57600080fd5b50610182600160a060020a0360043516602435610900565b3480156102ef57600080fd5b506101ab600160a060020a0360043581169060243516610983565b34801561031657600080fd5b5061031f610a07565b6040805189151581526060810187905260808101869052600160a060020a03851660a082015260ff841660c082015282151560e082015261010060208083018281528b51928401929092528a5192939192918401916101208501918c019080838360005b8381101561039b578181015183820152602001610383565b50505050905090810190601f1680156103c85780820380516001836020036101000a031916815260200191505b5083810382528951815289516020918201918b019080838360005b838110156103fb5781810151838201526020016103e3565b50505050905090810190601f1680156104285780820380516001836020036101000a031916815260200191505b509a505050505050505050505060405180910390f35b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104ca5780601f1061049f576101008083540402835291602001916104ca565b820191906000526020600020905b8154815290600101906020018083116104ad57829003601f168201915b5050505050905090565b604080517f8ca979ca000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a038516602483015260448201849052915173__./node_modules/ethereum-libraries-to__91638ca979ca916064808301926020929190829003018186803b15801561055757600080fd5b505af415801561056b573d6000803e3d6000fd5b505050506040513d602081101561058157600080fd5b50519392505050565b60055490565b604080517f21a6a23d000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a0380871660248401528516604483015260648201849052915173__./node_modules/ethereum-libraries-to__916321a6a23d916084808301926020929190829003018186803b15801561061b57600080fd5b505af415801561062f573d6000803e3d6000fd5b505050506040513d602081101561064557600080fd5b5051949350505050565b60075474010000000000000000000000000000000000000000900460ff1690565b60065490565b604080517f3af00d0f000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a0384166024830152915173__./node_modules/ethereum-libraries-to__91633af00d0f916044808301926020929190829003018186803b1580156106f257600080fd5b505af4158015610706573d6000803e3d6000fd5b505050506040513d602081101561071c57600080fd5b505192915050565b604080517f6269321c00000000000000000000000000000000000000000000000000000000815260006004820181905260248201849052915173__./node_modules/ethereum-libraries-to__91636269321c916044808301926020929190829003018186803b1580156106f257600080fd5b604080517fbd03185c000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a0386166024830152604482018590528315156064830152915173__./node_modules/ethereum-libraries-to__9163bd03185c916084808301926020929190829003018186803b15801561061b57600080fd5b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104ca5780601f1061049f576101008083540402835291602001916104ca565b604080517f6f71ca3c000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a0384166024830152915173__./node_modules/ethereum-libraries-to__91636f71ca3c916044808301926020929190829003018186803b1580156106f257600080fd5b604080517fd4b1770a000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a038516602483015260448201849052915173__./node_modules/ethereum-libraries-to__9163d4b1770a916064808301926020929190829003018186803b15801561055757600080fd5b604080517fac9b44f7000000000000000000000000000000000000000000000000000000008152600060048201819052600160a060020a03808616602484015284166044830152915173__./node_modules/ethereum-libraries-to__9163ac9b44f7916064808301926020929190829003018186803b15801561055757600080fd5b600080546003805460408051602060026101006001861615026000190190941693909304601f810184900484028201840190925281815260ff90941694939291830182828015610a985780601f10610a6d57610100808354040283529160200191610a98565b820191906000526020600020905b815481529060010190602001808311610a7b57829003601f168201915b5050505060048301805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152949594935090830182828015610b285780601f10610afd57610100808354040283529160200191610b28565b820191906000526020600020905b815481529060010190602001808311610b0b57829003601f168201915b5050506005840154600685015460079095015493949093909250600160a060020a038116915060ff7401000000000000000000000000000000000000000082048116917501000000000000000000000000000000000000000000900416885600a165627a7a72305820edd13c28a29631d5c9b026539007fd60053a87f5f99846480d9ef03dc3c1917c0029"}`)
Output:
func (*UnlinkedBytecode) Build ¶
func (ub *UnlinkedBytecode) Build(jsonstring string) (err error)
Build takes a compiler standard output bytecode object as a json string and builds the UnlinkedBytecode struct
func (*UnlinkedBytecode) Validate ¶
func (ub *UnlinkedBytecode) Validate() (err error)
Validate with UnlinkedBytecode ensures the UnlinkedBytecode object conforms to the standard described here https://ethpm.github.io/ethpm-spec/package-spec.html#bytecode