mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
@@ -184,24 +184,15 @@ custom types without the overhead of external function calls:
|
||||
It is possible to obtain the address of a library by converting
|
||||
the library type to the ``address`` type, i.e. using ``address(LibraryName)``.
|
||||
|
||||
As the compiler cannot know where the library will be
|
||||
deployed at, these addresses have to be filled into the
|
||||
final bytecode by a linker
|
||||
(see :ref:`commandline-compiler` for how to use the
|
||||
commandline compiler for linking). If the addresses are not
|
||||
given as arguments to the compiler, the compiled hex code
|
||||
will contain placeholders of the form ``__Set______`` (where
|
||||
``Set`` is the name of the library). The address can be filled
|
||||
manually by replacing all those 40 symbols by the hex
|
||||
encoding of the address of the library contract.
|
||||
|
||||
.. note::
|
||||
Manually linking libraries on the generated bytecode is discouraged, because
|
||||
in this way, the library name is restricted to 36 characters.
|
||||
You should ask the compiler to link the libraries at the time
|
||||
a contract is compiled by either using
|
||||
the ``--libraries`` option of ``solc`` or the ``libraries`` key if you use
|
||||
the standard-JSON interface to the compiler.
|
||||
As the compiler does not know the address where the library will be deployed, the compiled hex code
|
||||
will contain placeholders of the form ``__$30bbc0abd4d6364515865950d3e0d10953$__``. The placeholder
|
||||
is a 34 character prefix of the hex encoding of the keccak256 hash of the fully qualified library
|
||||
name, which would be for example ``libraries/bigint.sol:BigInt`` if the library was stored in a file
|
||||
called ``bigint.sol`` in a ``libraries/`` directory. Such bytecode is incomplete and should not be
|
||||
deployed. Placeholders need to be replaced with actual addresses. You can do that by either passing
|
||||
them to the compiler when the library is being compiled or by using the linker to update an already
|
||||
compiled binary. See :ref:`library-linking` for information on how to use the commandline compiler
|
||||
for linking.
|
||||
|
||||
In comparison to contracts, libraries are restricted in the following ways:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user