Skip to content

Commit

Permalink
Improve docs for abi required-ness (#3137)
Browse files Browse the repository at this point in the history
* Improve docs for abi required-ness

* Newsfragment

* Fix list syntax

* Update parameters and types for Contract API

* Fill in parameters where possible

* Fix space in solidity docs link

* Fix doc syntax
  • Loading branch information
reedsa committed Nov 7, 2023
1 parent f14936a commit 48a753c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
20 changes: 18 additions & 2 deletions docs/web3.contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ After ``py-solc-x`` is installed, you will need to install a version of ``solc``
>>> from solcx import install_solc
>>> install_solc(version='latest')
You should now be set up to run the contract deployment example below:
You should now be set up to compile and deploy a contract.

The following example runs through these steps:
#. Compile Solidity contract into bytecode and an ABI
#. Initialize a Contract Web3.py instance
#. Deploy the contract using the Contract instance to initiate a transaction
#. Interact with the contract functions using the Contract instance

.. code-block:: python
Expand Down Expand Up @@ -132,7 +138,11 @@ Each Contract Factory exposes the following properties.

.. py:attribute:: Contract.abi
The contract ABI array.
The contract ``abi``, or Application Binary Interface, specifies how a contract can
be interacted with. Without an ``abi``, the contract cannot be decoded. The ``abi``
enables the Contract instance to expose functions and events as object properties.

For further details, see the `Solidity ABI specification <https://docs.soliditylang.org/en/develop/abi-spec.html>`_.


.. py:attribute:: Contract.bytecode
Expand Down Expand Up @@ -1280,3 +1290,9 @@ You can interact with web3.py contract API as follows:
>>> deployed_contract.functions.retrieve().call()
'0x0000000000000000000000000000000000000002'
Where can I find more information about Ethereum Contracts?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Comprehensive documentation for Contracts is available from the `Solidity Docs <https://docs.soliditylang.org/>`_.
38 changes: 22 additions & 16 deletions docs/web3.eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1282,22 +1282,28 @@ Contracts

The following arguments are accepted for contract class creation.

- ``abi``
- ``asm``
- ``ast``
- ``bytecode``
- ``bytecode_runtime``
- ``clone_bin``
- ``dev_doc``
- ``decode_tuples``
- ``interface``
- ``metadata``
- ``opcodes``
- ``src_map``
- ``src_map_runtime``
- ``user_doc``

See :doc:`web3.contract` for more information about how to use contracts.
:param abi: Application Binary Interface. Usually provided since an ``abi`` is required to interact with any contract.
:type abi: ABI
:param asm: Asssembly code generated by the compiler
:param ast: Abstract Syntax Tree of the contract generated by the compiler
:param bytecode: Bytecode of the contract generated by the compiler
:param bytecode_runtime: Bytecode stored at the contract address, excludes the constructor and initialization code
:param clone_bin:
:param dev_doc:
:param decode_tuples: Optionally convert tuples/structs to named tuples
:param interface:
:param metadata: Contract Metadata generated by the compiler
:param opcodes: Opcodes for the contract generated by the compiler
:param src_map:
:param src_map_runtime:
:param user_doc:
:return: Instance of the contract
:rtype: Contract
:raises TypeError: If the address is not provided
:raises AttributeError: If the contract class is not initialized

See the :doc:`web3.contract` documentation for more information about Contracts.


.. py:method:: Eth.set_contract_factory(contractFactoryClass)
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2539.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Additional contract ``abi`` documentation to make it a clear requirement for contract instances.

0 comments on commit 48a753c

Please sign in to comment.