Skip to content

Commit f8439f0

Browse files
docs: add tx.replace to documentation
1 parent 7f866db commit f8439f0

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

docs/api-network.rst

+29-1
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,12 @@ TransactionReceipt Attributes
22192219
22202220
.. py:attribute:: TransactionReceipt.status
22212221
2222-
The status of the transaction: -1 for pending, 0 for failed, 1 for success.
2222+
An :class:`IntEnum <enum.IntEnum>` object representing the status of the transaction:
2223+
2224+
* ``1``: Successful
2225+
* ``0``: Reverted
2226+
* ``-1``: Pending
2227+
* ``-2``: Dropped
22232228
22242229
.. code-block:: python
22252230
@@ -2315,6 +2320,29 @@ TransactionReceipt Attributes
23152320
TransactionReceipt Methods
23162321
**************************
23172322
2323+
.. py:method:: TransactionReceipt.replace(increment=None, gas_price=None)
2324+
2325+
Broadcast an identical transaction with the same nonce and a higher gas price.
2326+
2327+
Exactly one of the following arguments must be provided:
2328+
2329+
* ``increment``: Multiplier applied to the gas price of the current transaction in order to determine a new gas price
2330+
* ``gas_price``: Absolute gas price to use in the replacement transaction
2331+
2332+
Returns a :func:`TransactionReceipt <brownie.network.transaction.TransactionReceipt>` object.
2333+
2334+
.. code-block:: python
2335+
2336+
>>> tx = accounts[0].transfer(accounts[1], 100, required_confs=0, gas_price="1 gwei")
2337+
Transaction sent: 0xc1aab54599d7875fc1fe8d3e375abb0f490cbb80d5b7f48cedaa95fa726f29be
2338+
Gas price: 13.0 gwei Gas limit: 21000 Nonce: 3
2339+
<Transaction object '0xc1aab54599d7875fc1fe8d3e375abb0f490cbb80d5b7f48cedaa95fa726f29be'>
2340+
2341+
>>> tx.replace(1.1)
2342+
Transaction sent: 0x9a525e42b326c3cd57e889ad8c5b29c88108227a35f9763af33dccd522375212
2343+
Gas price: 14.3 gwei Gas limit: 21000 Nonce: 3
2344+
<Transaction '0x9a525e42b326c3cd57e889ad8c5b29c88108227a35f9763af33dccd522375212'>
2345+
23182346
.. py:classmethod:: TransactionReceipt.info()
23192347
23202348
Displays verbose information about the transaction, including event logs and the error string if a transaction reverts.

docs/core-accounts.rst

+19
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,22 @@ Additionally, setting ``silent = True`` suppresses the console output.
8989
[1, -1, -1]
9090
9191
These transactions are initially pending (``status == -1``) and appear yellow in the console.
92+
93+
Replacing Transactions
94+
======================
95+
96+
The :func:`TransactionReceipt.replace <TransactionReceipt.replace>` method can be used to replace underpriced transactions while they are still pending:
97+
98+
.. code-block:: python
99+
100+
>>> tx = accounts[0].transfer(accounts[1], 100, required_confs=0, gas_price="1 gwei")
101+
Transaction sent: 0xc1aab54599d7875fc1fe8d3e375abb0f490cbb80d5b7f48cedaa95fa726f29be
102+
Gas price: 13.0 gwei Gas limit: 21000 Nonce: 3
103+
<Transaction object '0xc1aab54599d7875fc1fe8d3e375abb0f490cbb80d5b7f48cedaa95fa726f29be'>
104+
105+
>>> tx.replace(1.1)
106+
Transaction sent: 0x9a525e42b326c3cd57e889ad8c5b29c88108227a35f9763af33dccd522375212
107+
Gas price: 14.3 gwei Gas limit: 21000 Nonce: 3
108+
<Transaction '0x9a525e42b326c3cd57e889ad8c5b29c88108227a35f9763af33dccd522375212'>
109+
110+
All pending transactions are available within the :func:`history <brownie.network.state.TxHistory>` object. As soon as one transaction confirms, the remaining dropped transactions are removed. See the documentation on :ref:`accessing transaction history <core-chain-history>` for more info.

docs/core-chain.rst

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ The :func:`Chain <brownie.network.state.Chain>` object, available as ``chain``,
5353
Accessing Transaction Data
5454
==========================
5555

56+
.. _core-chain-history:
57+
5658
Local Transaction History
5759
-------------------------
5860

0 commit comments

Comments
 (0)