These are chat archives for Nethereum/Nethereum

23rd
Nov 2018
Daniel Hursan
@hdany
Nov 23 2018 17:18
Hello. Any ideas why the UnlockAccount call throws an exception?
return await web3.Personal.UnlockAccount.SendRequestAsync(MyAddress, MyPrivateKey, 900, Guid.NewGuid());
Response status code does not indicate success: 405 (Method Not Allowed).
Error occurred when trying to send rpc requests(s)
Enigmatic
@EnigmaticUnreal_twitter
Nov 23 2018 17:46
Any chance you're trying to unlock via Infura? Or is it local geth/parity?
Daniel Hursan
@hdany
Nov 23 2018 17:47
Yes, exactly, Infura (Kovan). Is there an issue, or something specific to Infura that I should take into account?
Enigmatic
@EnigmaticUnreal_twitter
Nov 23 2018 17:48

Ah. So Infura doesn't allow that rpc call (which makes sense, as unlocking it on that node means everyone else have access to your private keys too).

Try to create a web3 object using your private keys/JSON files instead.

Daniel Hursan
@hdany
Nov 23 2018 17:49
Gotcha, will do and let you know. Thanks for the tips
Enigmatic
@EnigmaticUnreal_twitter
Nov 23 2018 17:49
Cheers. Let us know how you get on with it. :)
Daniel Hursan
@hdany
Nov 23 2018 18:02
This is what I ended up with and still get the same error
var ecKey = new EthECKey(MyPrivateKey);
var account = new Account(ecKey);
web3 = new Web3(account, Configuration.Kovan.APIEndpoint);

return await web3.Personal.UnlockAccount.SendRequestAsync(MyAddress, MyPrivateKey, 900, Guid.NewGuid());
Enigmatic
@EnigmaticUnreal_twitter
Nov 23 2018 18:03

As far as I know ManagedAccount would only work on local nodes (or your own node), since it relies on the node to have the accounts stored by the client and being able to unlock it via a password.

If you could bear with me with my VB code, would be something like:

Dim privateKey As New Nethereum.Signer.EthECKey("<privatekey>")
Dim account = New Nethereum.Web3.Accounts.Account(privateKey)
Dim iweb3 = New Web3(account, "https://ropsten.infura.io")
Ah. Just saw your code.
So you pretty much already have your web3 started up.
Daniel Hursan
@hdany
Nov 23 2018 18:04
thanks a lot for the code sample, but still throws that error. I must be doing something wrong
Enigmatic
@EnigmaticUnreal_twitter
Nov 23 2018 18:04
You don't need to call Personal.UnlockAccount - Instead you can start calling for transactions etc. E.g.
        Dim gas As HexBigInteger = Await iweb3.Eth.DeployContract.EstimateGasAsync(abi, bytecode, account.Address, Nothing)
        Dim receiptHash = Await iweb3.Eth.DeployContract.SendRequestAndWaitForReceiptAsync(abi, bytecode, account.Address, gas, value)
(of course I had the ABI and bytecode earlier declared, but not shown here)
Daniel Hursan
@hdany
Nov 23 2018 18:05
aaaaa, awesome. I'll try again :)
Enigmatic
@EnigmaticUnreal_twitter
Nov 23 2018 18:05
Cool - Don't mind me if I pop to bed though - 2AM now. But happy to drop by back a couple hours from now. :)
Daniel Hursan
@hdany
Nov 23 2018 18:05
Good night and thanks for the help! ;)