Skip to content

Commit ef4727d

Browse files
committed
Add send_raw_transaction, deprecate sendRawTransaction
1 parent c5f8a15 commit ef4727d

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

docs/examples.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ There are a few options for making transactions:
183183
Use this method if:
184184
- you want to send ether from one account to another.
185185

186-
- :meth:`~web3.eth.Eth.sendRawTransaction`
186+
- :meth:`~web3.eth.Eth.send_raw_transaction`
187187

188188
Use this method if:
189189
- you want to sign the transaction elsewhere, e.g., a hardware wallet.
@@ -657,7 +657,7 @@ And finally, send the transaction
657657

658658
.. code-block:: python
659659
660-
txn_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
660+
txn_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
661661
txn_receipt = w3.eth.waitForTransactionReceipt(txn_hash)
662662
663663
Tip : afterwards you can use the value stored in ``txn_hash``, in an explorer like `etherscan`_ to view the transaction's details

docs/overview.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Making Transactions
159159
The most common use cases will be satisfied with
160160
:meth:`send_transaction <web3.eth.Eth.send_transaction>` or the combination of
161161
:meth:`sign_transaction <web3.eth.Eth.sign_transaction>` and
162-
:meth:`sendRawTransaction <web3.eth.Eth.sendRawTransaction>`.
162+
:meth:`send_raw_transaction <web3.eth.Eth.send_raw_transaction>`.
163163

164164
.. note::
165165

@@ -172,7 +172,7 @@ API
172172

173173
- :meth:`web3.eth.send_transaction() <web3.eth.Eth.send_transaction>`
174174
- :meth:`web3.eth.sign_transaction() <web3.eth.Eth.sign_transaction>`
175-
- :meth:`web3.eth.sendRawTransaction() <web3.eth.Eth.sendRawTransaction>`
175+
- :meth:`web3.eth.send_raw_transaction() <web3.eth.Eth.send_raw_transaction>`
176176
- :meth:`web3.eth.replaceTransaction() <web3.eth.Eth.replaceTransaction>`
177177
- :meth:`web3.eth.modifyTransaction() <web3.eth.Eth.modifyTransaction>`
178178
- :meth:`web3.eth.waitForTransactionReceipt() <web3.eth.Eth.waitForTransactionReceipt>`

docs/web3.eth.account.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Local vs Hosted Keys
2222
Local Private Key
2323
A key is 32 :class:`bytes` of data that you can use to sign transactions and messages,
2424
before sending them to your node.
25-
You must use :meth:`~web3.eth.Eth.sendRawTransaction`
25+
You must use :meth:`~web3.eth.Eth.send_raw_transaction`
2626
when working with local keys, instead of
2727
:meth:`~web3.eth.Eth.send_transaction` .
2828

@@ -224,7 +224,7 @@ Sign a Transaction
224224
------------------------
225225

226226
Create a transaction, sign it locally, and then send it to your node for broadcasting,
227-
with :meth:`~web3.eth.Eth.sendRawTransaction`.
227+
with :meth:`~web3.eth.Eth.send_raw_transaction`.
228228

229229
.. doctest::
230230

@@ -249,8 +249,8 @@ with :meth:`~web3.eth.Eth.sendRawTransaction`.
249249
>>> signed.v
250250
37
251251

252-
# When you run sendRawTransaction, you get back the hash of the transaction:
253-
>>> w3.eth.sendRawTransaction(signed.rawTransaction) # doctest: +SKIP
252+
# When you run send_raw_transaction, you get back the hash of the transaction:
253+
>>> w3.eth.send_raw_transaction(signed.rawTransaction) # doctest: +SKIP
254254
'0xd8f64a42b57be0d565f385378db2f6bf324ce14a594afc05de90436e9ce01f60'
255255

256256
Sign a Contract Transaction
@@ -262,7 +262,7 @@ To sign a transaction locally that will invoke a smart contract:
262262
#. Build the transaction
263263
#. Sign the transaction, with :meth:`w3.eth.account.sign_transaction()
264264
<eth_account.account.Account.sign_transaction>`
265-
#. Broadcast the transaction with :meth:`~web3.eth.Eth.sendRawTransaction`
265+
#. Broadcast the transaction with :meth:`~web3.eth.Eth.send_raw_transaction`
266266

267267
.. testsetup::
268268

@@ -317,8 +317,8 @@ To sign a transaction locally that will invoke a smart contract:
317317
>>> signed_txn.v
318318
37
319319

320-
>>> w3.eth.sendRawTransaction(signed_txn.rawTransaction) # doctest: +SKIP
320+
>>> w3.eth.send_raw_transaction(signed_txn.rawTransaction) # doctest: +SKIP
321321

322-
# When you run sendRawTransaction, you get the same result as the hash of the transaction:
322+
# When you run send_raw_transaction, you get the same result as the hash of the transaction:
323323
>>> w3.toHex(w3.keccak(signed_txn.rawTransaction))
324324
'0x4795adc6a719fa64fa21822630c0218c04996e2689ded114b6553cef1ae36618'

docs/web3.eth.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ The following methods are available on the ``web3.eth`` namespace.
744744
* Delegates to ``eth_signTransaction`` RPC Method.
745745

746746
Returns a transaction that's been signed by the node's private key, but not yet submitted.
747-
The signed tx can be submitted with ``Eth.sendRawTransaction``
747+
The signed tx can be submitted with ``Eth.send_raw_transaction``
748748

749749
.. code-block:: python
750750
@@ -765,16 +765,16 @@ The following methods are available on the ``web3.eth`` namespace.
765765
.. warning:: Deprecated: This property is deprecated in favor of
766766
:attr:`~web3.eth.Eth.sign_transaction()`
767767

768-
.. py:method:: Eth.sendRawTransaction(raw_transaction)
768+
.. py:method:: Eth.send_raw_transaction(raw_transaction)
769769
770770
* Delegates to ``eth_sendRawTransaction`` RPC Method
771771

772772
Sends a signed and serialized transaction. Returns the transaction hash as a HexBytes object.
773773

774774
.. code-block:: python
775775
776-
>>> signed_txn = w3.eth.account.signTransaction(dict(
777-
nonce=w3.eth.getTransactionCount(public_address_of_senders_account),
776+
>>> signed_txn = w3.eth.account.sign_transaction(dict(
777+
nonce=w3.eth.get_transaction_count(public_address_of_senders_account),
778778
gasPrice=w3.eth.gas_price,
779779
gas=100000,
780780
to='0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
@@ -783,9 +783,13 @@ The following methods are available on the ``web3.eth`` namespace.
783783
),
784784
private_key_for_senders_account,
785785
)
786-
>>> w3.eth.sendRawTransaction(signed_txn.rawTransaction)
786+
>>> w3.eth.send_raw_transaction(signed_txn.rawTransaction)
787787
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
788788
789+
.. py:method:: Eth.sendRawTransaction(raw_transaction)
790+
791+
.. warning:: Deprecated: This property is deprecated in favor of
792+
:meth:`~web3.eth.Eth.send_raw_transaction()`
789793

790794
.. py:method:: Eth.replaceTransaction(transaction_hash, new_transaction)
791795

newsfragments/1880.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``w3.eth.send_raw_transaction``, deprecate ``w3.eth.sendRawTransaction``

tests/core/eth-module/test_accounts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def test_eth_account_sign_and_send_EIP155_transaction_to_eth_tester(
405405
raw_tx,
406406
expected_tx_hash,
407407
r, s, v):
408-
actual_tx_hash = w3.eth.sendRawTransaction(raw_tx)
408+
actual_tx_hash = w3.eth.send_raw_transaction(raw_tx)
409409
assert actual_tx_hash == expected_tx_hash
410410
actual_txn = w3.eth.get_transaction(actual_tx_hash)
411411
for key in ('to', 'nonce', 'gas', 'gasPrice', 'value', ):

web3/_utils/module_testing/eth_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,14 +852,14 @@ def test_eth_modifyTransaction(
852852
),
853853
]
854854
)
855-
def test_eth_sendRawTransaction(
855+
def test_eth_send_raw_transaction(
856856
self,
857857
web3: "Web3",
858858
raw_transaction: Union[HexStr, bytes],
859859
funded_account_for_raw_txn: ChecksumAddress,
860860
expected_hash: HexStr,
861861
) -> None:
862-
txn_hash = web3.eth.sendRawTransaction(raw_transaction)
862+
txn_hash = web3.eth.send_raw_transaction(raw_transaction)
863863
assert txn_hash == web3.toBytes(hexstr=expected_hash)
864864

865865
def test_eth_call(

web3/eth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def send_transaction_munger(self, transaction: TxParams) -> Tuple[TxParams]:
473473
mungers=[send_transaction_munger]
474474
)
475475

476-
sendRawTransaction: Method[Callable[[Union[HexStr, bytes]], HexBytes]] = Method(
476+
send_raw_transaction: Method[Callable[[Union[HexStr, bytes]], HexBytes]] = Method(
477477
RPC.eth_sendRawTransaction,
478478
mungers=[default_root_munger],
479479
)
@@ -668,3 +668,6 @@ def setGasPriceStrategy(self, gas_price_strategy: GasPriceStrategy) -> None:
668668
getUncleCount = DeprecatedMethod(get_uncle_count, 'getUncleCount', 'get_uncle_count')
669669
sendTransaction = DeprecatedMethod(send_transaction, 'sendTransaction', 'send_transaction')
670670
signTransaction = DeprecatedMethod(sign_transaction, 'signTransaction', 'sign_transaction')
671+
sendRawTransaction = DeprecatedMethod(send_raw_transaction,
672+
'sendRawTransaction',
673+
'send_raw_transaction')

0 commit comments

Comments
 (0)