compile.linker
Module¶
The compile.linker
module
Functions used for linking libraries for Solidity libraries
Example Solidity placeholder: __$13811623e8434e588b8942cf9304d14b96$__
-
solidbyte.compile.linker.
address_placeholder
(name)[source]¶ Provide a false, but repeatable address for a link ref with name. Used in bytecode hashing.
Parameters: name – ( str
) The name to use for the placeholderReturns: ( str
) A false address derrived from a placeholder
-
solidbyte.compile.linker.
bytecode_link_defs
(bytecode) → Set[Tuple[str, str]][source]¶ Return set of tuples with names and placeholders for link definitions from a bytecode file
Parameters: bytecode – ( str
) Contents of a Solidity bytecode output file
-
solidbyte.compile.linker.
clean_bytecode
(bytecode: str) → str[source]¶ Clean the bytecode string of any comments and whitespace
Parameters: bytecode – ( str
) Bytecode output from the Solidity compiler
-
solidbyte.compile.linker.
contract_from_def
(s: str) → str[source]¶ return a contract name form a solc file link definition
Parameters: s – ( str
) A “definition” from a solidity bytecode output file
-
solidbyte.compile.linker.
hash_linked_bytecode
(bytecode) → str[source]¶ Hash bytecode that has link references in a way that the addresses for delegate calls don’t matter. Useful for comparing bytecode hashes when you don’t know deployed addresses.
Parameters: bytecode – ( str
) Bytecode output from the Solidity compilerReturns: ( str
) A link-agnostic hash of the bytecode
-
solidbyte.compile.linker.
link_library
(bytecode: str, links: dict) → str[source]¶ Providing bytecode output from the Solidity copmiler and a dict of links, perform the placeholder replacement to create deployable bytecode.
Parameters: - bytecode – (
str
) Bytecode output from the Solidity compiler - links – (
dict
) A dict of links. ContractName:Address
- bytecode – (
-
solidbyte.compile.linker.
make_placeholder_regex
(placeholder: str) → Pattern[str][source]¶ Return a regex pattern for a placeholder
Parameters: placeholder – ( str
) Given a solidity placeholder, make a regex
-
solidbyte.compile.linker.
placeholder_from_def
(s: str) → str[source]¶ return a placeholder form a solc file link definition
Parameters: s – ( str
) A “definition” from a solidity bytecode output file
-
solidbyte.compile.linker.
replace_placeholders
(bytecode: str, placeholder: str, addr: str) → str[source]¶ Replace the placeholders with the contract address
Parameters: - bytecode – (
str
) Solidity bytecode output - placeholder – (
str
) The placeholder to replace - addr – (
str
) Address to replace the placeholder with
- bytecode – (