@@ -145,8 +145,45 @@ Valid formats for the this environment variable are:
145
145
- ``file:///path/to/node/rpc-json/file.ipc ``
146
146
- ``http://192.168.1.2:8545 ``
147
147
- ``https://node.ontheweb.com ``
148
+ - ``ws://127.0.0.1:8546 ``
148
149
149
150
151
+ Auto-initialization Provider Shortcuts
152
+ --------------------------------------
153
+
154
+ There are a couple auto-initialization shortcuts for common providers.
155
+
156
+ Infura Mainnet
157
+ ~~~~~~~~~~~~~~
158
+
159
+ To easily connect to the Infura Mainnet remote node, first register for a free
160
+ API key if you don't have one at https://infura.io/signup .
161
+
162
+ Then set the environment variable ``INFURA_API_KEY `` with your API key::
163
+
164
+ $ export INFURA_API_KEY=YourApiKey
165
+
166
+ .. code-block :: python
167
+
168
+ >> > from web3.auto.infura import w3
169
+
170
+ # confirm that the connection succeeded
171
+ >> > w3.isConnected()
172
+ True
173
+
174
+ Geth dev Proof of Authority
175
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176
+
177
+ To connect to a ``geth --dev `` Proof of Authority instance with defaults:
178
+
179
+ .. code-block :: python
180
+
181
+ >> > from web3.auto.gethdev import w3
182
+
183
+ # confirm that the connection succeeded
184
+ >> > w3.isConnected()
185
+ True
186
+
150
187
Built In Providers
151
188
------------------
152
189
@@ -171,7 +208,7 @@ HTTPProvider
171
208
.. code-block :: python
172
209
173
210
>> > from web3 import Web3
174
- >> > web3 = Web3(Web3.HTTPProvider(" http://127.0.0.1:8545" )
211
+ >> > web3 = Web3(Web3.HTTPProvider(" http://127.0.0.1:8545" ))
175
212
176
213
Note that you should create only one HTTPProvider per python
177
214
process, as the HTTPProvider recycles underlying TCP/IP network connections,
@@ -236,7 +273,7 @@ WebsocketProvider
236
273
.. code-block :: python
237
274
238
275
>> > from web3 import Web3
239
- >> > web3 = Web3(Web3.WebsocketProvider(" ws://127.0.0.1:8546" )
276
+ >> > web3 = Web3(Web3.WebsocketProvider(" ws://127.0.0.1:8546" ))
240
277
241
278
Under the hood, the ``WebsocketProvider `` uses the python websockets library for
242
279
making requests. If you would like to modify how requests are made, you can
0 commit comments