@@ -471,3 +471,50 @@ like so:
471471.. include :: ../tests/core/contracts/test_contract_example.py
472472 :code: python
473473 :start-line: 1
474+
475+ Using Infura Rinkeby Node
476+ -------------------------
477+ Import your required libraries
478+
479+ .. code-block :: python
480+
481+ from web3 import Web3, HTTPProvider
482+
483+ Initialize a web3 instance with an Infura node
484+
485+ .. code-block :: python
486+
487+ w3 = Web3(Web3.HTTPProvider(" https://rinkeby.infura.io/v3/YOUR_INFURA_KEY" ))
488+
489+
490+ Inject the middleware into the middleware onion
491+
492+ .. code-block :: python
493+
494+ from web3.middleware import geth_poa_middleware
495+ w3.middleware_onion.inject(geth_poa_middleware, layer = 0 )
496+
497+ Just remember that you have to sign all transactions locally, as infura does not handle any keys from your wallet ( refer to `this `_ )
498+
499+
500+ .. _this : https://web3py.readthedocs.io/en/stable/web3.eth.account.html#local-vs-hosted-nodes
501+
502+ .. code-block :: python
503+
504+ transaction = contract.functions.function_Name(params).buildTransaction()
505+ transaction.update({ ' gas' : appropriate_gas_amount })
506+ transaction.update({ ' nonce' : web3.eth.getTransactionCount(' Your_Wallet_Address' ) })
507+ signed_tx = w3.eth.account.signTransaction(transaction, private_key)
508+
509+ P.S : the two updates are done to the transaction dictionary, since a raw transaction might not contain gas & nonce amounts, so you have to add them manually.
510+
511+ And finally, send the transaction
512+
513+ .. code-block :: python
514+
515+ txn_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
516+ txn_receipt = w3.eth.waitForTransactionReceipt(txn_hash)
517+
518+ Tip : afterwards you can use the value stored in ``txn_hash ``, in an explorer like `etherscan `_ to view the transaction's details
519+
520+ .. _etherscan : https://rinkeby.etherscan.io
0 commit comments