question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I connect to Rinkeby?

See original GitHub issue

Currently trying to create and listen to contracts, testing on Rinkeby

  • Version: 3.16.4
  • Python: 3.5
  • OS: osx

What was wrong?

Please include any of the following that are applicable:

  • The code which produced the error

`from web3 import Web3, HTTPProvider, IPCProvider web3 = Web3(HTTPProvider(‘https://rinkeby.infura.io’))

web3.personal.unlockAccount(“[address]”,“[psw]”)`

  • The full output of the error
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../py3/lib/python3.5/site-packages/web3/personal.py", line 93, in unlockAccount
    [account, passphrase, duration],
  File ".../py3/lib/python3.5/site-packages/web3/manager.py", line 93, in request_blocking
    response = self._make_request(method, params)
  File ".../py3/lib/python3.5/site-packages/web3/manager.py", line 76, in _make_request
    return request_func(method, params)

  File ".../py3/lib/python3.5/site-packages/web3/middleware/attrdict.py", line 20, in middleware
    response = make_request(method, params)
  File ".../py3/lib/python3.5/site-packages/web3/middleware/formatting.py", line 25, in middleware
    response = make_request(method, params)
  File ".../py3/lib/python3.5/site-packages/web3/providers/rpc.py", line 52, in make_request
    **self.get_request_kwargs()
  File ".../py3/lib/python3.5/site-packages/web3/utils/compat/compat_requests.py", line 22, in make_post_request 
response.raise_for_status()
  File ".../py3/lib/python3.5/site-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: https://rinkeby.infura.io/
  • What type of node you were connecting to. Rinkeby

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13

github_iconTop GitHub Comments

3reactions
carvercommented, Dec 18, 2017

This is the important part of that error:

Method Not Allowed for url: https://rinkeby.infura.io/

Infura does not support private keys stored on their server (which is a good thing, that would be a gaping security hole). On mainnet, do not send your private keys or passwords to any remote service! If you do accidentally, you should empty the account and never use it again, and change the password.

In Web3 v3, sending transactions to Infura is a bit cumbersome. One needs to sign the transaction locally, and send with w3.eth.sendRawTransaction. Either use a local geth/parity/etc node, or upgrade to the beta v4, which has some convenience tools for signing transactions locally.

There is an ongoing project to sign transactions locally using middleware that will handle this logic of signing locally before sending as a raw transaction, but it will probably be at least a couple weeks until it is released. #493

1reaction
carvercommented, Dec 28, 2017

Really appreciate your help here and on Stack Overflow!

Sure thing, I’m happy to help. There’s still so many docs to write and infrastructure to build! Which brings me to…

I still haven’t been able to fully piece together how to do it…

I am now realizing that there is no good documentation or public API for deploying a contract with a private key. buildTransaction() won’t work for you for deploying the contract. That means web3 should probably add a new method. In the meantime, you can do this using a non-public method (_encode_constructor_data()), like so:

  1. Build contract_interface with the quickstart instructions you found.
  2. Generate the data field for the transaction to deploy the contract:
# build contract_interface
from web3.auto import w3
contract = w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin'])
data = contract._encode_constructor_data(any_args, you_have, in_the_constructor)
transaction = {'data': data, 'gas':...)
  1. Sign the transaction locally
from web3 import Account
acct = Account.privateKeyToAccount(your_private_key)
signed = acct.signTransaction(transaction)
  1. Issue deployment transaction
w3.eth.sendRawTransaction(signed.rawTransaction)

Note that the private key signing in w3.eth.account has not yet been audited, it’s in beta, use at your own risk.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect Metamask to Ethereum Testnet Rinkeby (RIN)
Connect Metamask wallet to Ethereum Testnet Rinkeby RIN. Configure metamask wallet to connect to another RPC.
Read more >
The Beginners Guide to Using an Ethereum Test Network
Rinkeby : A proof-of-authority blockchain, started by the Geth team. Ether can't be mined; it has to be requested. Connecting to a testnet....
Read more >
A Complete Guide to Ethereum's Rinkeby Testnet - Alchemy
How to get Rinkeby testnet ETH · Step 1: Sign up · Step 2: Change your Network in Metamask · Step 3: Add...
Read more >
How To Add Rinkeby To MetaMask: Guide With Images ...
How to Add Rinkeby Network to MetaMask – Mobile · Open MetaMask Mobile Application · Navigate to Menu & Go To Settings ·...
Read more >
How To Add Rinkeby Network To Metamask Easily - IsItCrypto
How To Add Rinkeby Testnet To Metamask Quickly · Launch the Metamask extension/mobile app and unlock your account. · Click on the network...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found