mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Document library placeholder change.
This commit is contained in:
parent
56bbfce6d3
commit
e8ba2d6e46
@ -158,6 +158,12 @@ Command Line and JSON Interfaces
|
||||
node was replaced by a field called ``kind`` which can have the
|
||||
value ``"constructor"``, ``"fallback"`` or ``"function"``.
|
||||
|
||||
* In unlinked binary hex files, library address placeholders are now
|
||||
the first 36 hex characters of the keccak256 hash of the fully qualified
|
||||
library name, instead of just the fully qualified library name.
|
||||
Binary files now also contain a list of mappings from these hex placeholders
|
||||
to the fully qualified names.
|
||||
|
||||
Constructors
|
||||
------------
|
||||
|
||||
|
@ -41,14 +41,25 @@ If there are multiple matches due to remappings, the one with the longest common
|
||||
|
||||
For security reasons the compiler has restrictions what directories it can access. Paths (and their subdirectories) of source files specified on the commandline and paths defined by remappings are allowed for import statements, but everything else is rejected. Additional paths (and their subdirectories) can be allowed via the ``--allow-paths /sample/path,/another/sample/path`` switch.
|
||||
|
||||
If your contracts use :ref:`libraries <libraries>`, you will notice that the bytecode contains substrings of the form ``__LibraryName______``. You can use ``solc`` as a linker meaning that it will insert the library addresses for you at those points:
|
||||
If your contracts use :ref:`libraries <libraries>`, you will notice that the bytecode contains substrings of the form ``__53aea86b7d70b31448b230b20ae141a537e5__``. These are placeholders for the actual library addresses.
|
||||
The placeholder is a 36 character prefix of the hex encoding of the keccak256 hash of the fully qualified library name.
|
||||
The bytecode file will also contain lines of the form ``// <placeholder> -> <library name>`` at the end to help
|
||||
identify which libraries the placeholders represent.
|
||||
You can use ``solc`` as a linker meaning that it will insert the library addresses for you at those points:
|
||||
|
||||
Either add ``--libraries "Math:0x12345678901234567890 Heap:0xabcdef0123456"`` to your command to provide an address for each library or store the string in a file (one library per line) and run ``solc`` using ``--libraries fileName``.
|
||||
Either add ``--libraries "file.sol:Math:0x1234567890123456789012345678901234567890 file.sol:Heap:0xabCD567890123456789012345678901234567890"`` to your command to provide an address for each library or store the string in a file (one library per line) and run ``solc`` using ``--libraries fileName``.
|
||||
|
||||
If ``solc`` is called with the option ``--link``, all input files are interpreted to be unlinked binaries (hex-encoded) in the ``__LibraryName____``-format given above and are linked in-place (if the input is read from stdin, it is written to stdout). All options except ``--libraries`` are ignored (including ``-o``) in this case.
|
||||
If ``solc`` is called with the option ``--link``, all input files are interpreted to be unlinked binaries (hex-encoded) in the ``__53aea86b7d70b31448b230b20ae141a537e5__``-format given above and are linked in-place (if the input is read from stdin, it is written to stdout). All options except ``--libraries`` are ignored (including ``-o``) in this case.
|
||||
|
||||
If ``solc`` is called with the option ``--standard-json``, it will expect a JSON input (as explained below) on the standard input, and return a JSON output on the standard output. This is the recommended interface for more complex and especially automated uses.
|
||||
|
||||
.. note::
|
||||
The library placeholder used to be the fully qualified name of the library itself
|
||||
instead of the hash of it. This format is still supported by ``solc --link`` but
|
||||
the compiler will no longer output it. This change was made to reduce
|
||||
the likelihood of a collision between libraries, since only the first 36 characters
|
||||
of the fully qualified library name could be used.
|
||||
|
||||
.. _evm-version:
|
||||
.. index:: ! EVM version, compile target
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user