These are chat archives for Nethereum/Nethereum

10th
Jan 2019
farzad-salimijazi
@farzad-salimijazi
Jan 10 00:44
@juanfranblanco Thank you it helped
Anyone have had conflict like this : 'The type 'BigInteger' exists in both 'Nethereum.Hex, Version=2.5.1.0, Culture=neutral, PublicKeyToken=null and 'System.Numerics, Version=4.0.0.0'
farzad-salimijazi
@farzad-salimijazi
Jan 10 01:04
I change the .NET version to 3.5 in build setting and it is resolved but according to the readME it said .net 4
Trycoder
@Trycoder
Jan 10 05:26
@farzad-salimijazi I think you can reference System.Numerics to use BigInteger .
That works fine for me
Juan Blanco
@juanfranblanco
Jan 10 09:34
@farzad-salimijazi just make sure it is not included in the zip
@GeorgSchneider 4.5.1 does not support TLS 2 so you need to add it
@Shammah
Juan Blanco
@juanfranblanco
Jan 10 09:40
@Trycoder regarding your issue is it only when deploying a contract?
also yes it will be ideal to use async but you should not have that problem, what do you mean that later on returns fine
are you using Kovan / Parity?
fruor
@fruor
Jan 10 10:54
now that's weird. I just figured I cannot do anything on normal parity nodes, web3secured.Eth.Blocks.GetBlockNumber.SendRequestAsync().Result and alikes get a CanceledException
Only when I do --unsafe-expse on the parity node
infura is working, but there I always get HTTP 400 for contract calls
Juan Blanco
@juanfranblanco
Jan 10 11:08
@fruor what network are you using on infura?
what version of parity are you running?
chain?
fruor
@fruor
Jan 10 11:08
infura ropsten
everything ropsten atm, wanted to get rid of --unsafe-exposed before going on mainnet
Just tried it on parity 2.2.5 beta on ubuntu, there i always get canceled even with --unsafe-expose
Juan Blanco
@juanfranblanco
Jan 10 11:10
what are you using to -unsafe-expose
fruor
@fruor
Jan 10 11:10
where everything works is parity 2.2.2 beta on windows with --unsafe-expose, but not without the flag
Juan Blanco
@juanfranblanco
Jan 10 11:11
are you using personal api?
fruor
@fruor
Jan 10 11:11
nothing really, I just did it this way in my testing environment so I dont run into errors while debugging
Juan Blanco
@juanfranblanco
Jan 10 11:11
how do you create an instance of web3? using a ManagedAccount?
fruor
@fruor
Jan 10 11:11
I think not, I initialize with web3unlocked = new Web3(account, jsonRpcUrl);
but I have a second one running web3secured = new Web3(jsonRpcUrl);
Juan Blanco
@juanfranblanco
Jan 10 11:12
how do you instantiate your account?
fruor
@fruor
Jan 10 11:12
and this is for asking the blockchain about stuff, starting with .net.Listening
so the web3secured doesn't work without the --unsafe-expose flag, that's quite irritating
Juan Blanco
@juanfranblanco
Jan 10 11:13
have you tried to connect to any other infura endpoint?
just trying to figure out what is the issue
fruor
@fruor
Jan 10 11:14
chain = Nethereum.Signer.Chain.Ropsten;
account = new Account(privateKey, chain);
Juan Blanco
@juanfranblanco
Jan 10 11:14
ok cool
fruor
@fruor
Jan 10 11:14
ok so I have 2 problems I think
Juan Blanco
@juanfranblanco
Jan 10 11:15
so if we fix infura first
fruor
@fruor
Jan 10 11:15
First one, I have this secured web3 instance without an account, just
web3secured = new Web3(jsonRpcUrl);
Ok let's do it
this one works with infura
Juan Blanco
@juanfranblanco
Jan 10 11:16
well web3secured is mainly a reading instance
fruor
@fruor
Jan 10 11:16
exactly
Juan Blanco
@juanfranblanco
Jan 10 11:16
do you have any issues reading smart contract?
fruor
@fruor
Jan 10 11:16
let's do infura, what doesn't work there is my web3unlocked (account) instance
for example
Juan Blanco
@juanfranblanco
Jan 10 11:17
when you send a transaction I guess (deploy contract, transaction)
if you remove the chain and create the instance just the the Account do you get any problems? (it should not be an issue, but just in case)
also can i see your account in etherscan?
(if possible)
fruor
@fruor
Jan 10 11:18
sure, it's just ropsten atm
you have some successful tx there, but they were all deployed via this local parity node with --unsafe-expose
https://ropsten.etherscan.io/address/0x37dd659b6515ed44cabb940294e8401c6f37ad4b
I just changed the url to https://ropsten.infura.io and try again
ok, here he throws
var estimate = await transferHandler.EstimateGasAsync(configparams.auctionContractAddress, unsealBidMessage);
which means broadcasting the unsealBidMessage will also throw
probably
Juan Blanco
@juanfranblanco
Jan 10 11:23
ok so if the estimate throws an error, normally indicates an issue with your solidity
for example a require exception thrown
fruor
@fruor
Jan 10 11:24
but why does it work on an unsafe-exposed local parity node?
Juan Blanco
@juanfranblanco
Jan 10 11:24
what is the error you get?
fruor
@fruor
Jan 10 11:25
{System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route)}
Juan Blanco
@juanfranblanco
Jan 10 11:25
and this happens for all transactions or just this one
fruor
@fruor
Jan 10 11:29
I get it at least for one other:
Nethereum.RPC.Eth.DTOs.TransactionReceipt auctionReceipt = await registrarService.StartAuctionsAndBidRequestAndWaitForReceiptAsync(startAuctionsMessage);
oh wow but this went through
var estimate = await transferHandler.EstimateGasAsync(configparams.auctionContractAddress, startAuctionsMessage);
what do you want me to test?
fruor
@fruor
Jan 10 11:35
gotta break it for now, unfortunately not back until evening... sorry for that. Maybe I can understand it with some distance
if you put some logging we might see full request
or just using Fiddler
or Wireshark
but it is very strange
fruor
@fruor
Jan 10 11:39
will do - did you use some nuget package in there? Because I have Common.Logging but not Common.Logging.Simple and he can't find
CapturingLoggerFactoryAdapter()
nevermind I'll just go through the sln in the evening
thanks so far
this will be included by default
fruor
@fruor
Jan 10 14:03
turned on logging, I have all the logs in the LoggerEvents now
here is _lastEvent.RenderedMessage
"RPC Exception, RPC Request: {\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"eth_sendRawTransaction\",\"params\":[\"0xf8f382011a8502540be4008309e21294c19fd9004b5c9789391679de6d766b981db94610872386f26fc10000b884febefd610000000000000000000000000000000000000000000000000000000000000040774698fa2376011861164cab67edbbb548c07f8469290660daab54346748eabd0000000000000000000000000000000000000000000000000000000000000001573c10ac5e6e24ecdd14853a4896e39e2b4f88d943851ad2c102aec9a3f6f77b2aa01b7930c68ebe69a589cf3ce3313561f3c375d6f7c1c5171131dd742ba189b55aa02de9249967fd893ad629e13923594de112b6afe320b8cf0294d225ee24f92dd6\"]}"
jsonRPC-url is still https://ropsten.infura.io
fruor
@fruor
Jan 10 14:10
interesting, UnsealBid seems to work now. got a mined tx there
the exception above was thrown when doing StartAuctionsAndBidRequestAndWaitForReceiptAsync(startAuctionsMessage)
fruor
@fruor
Jan 10 14:28
my new Web3 constructor is web3unlocked = new Web3(account, new RpcClient(new Uri(jsonRpcUrl), null, null, null, LogManager.GetLogger<ILog>()));
unfortunately I don't get such a beautiful RPC Error, just this RPC Exception. There are lik 10 logging events before that which seem to work fine. But I can consistently provoke the exception when broadcasting this startAuctionsMessage
Juan Blanco
@juanfranblanco
Jan 10 14:32
just tested the message just curling so the request is fine
i get a nonce too low exception
fruor
@fruor
Jan 10 14:33
how can I do what you did? :)
I wanna see the exception
Juan Blanco
@juanfranblanco
Jan 10 14:33
so mainly it works but obviously the nonce has been used already
curl -X POST -H "Content-Type: application/json" --data '{"id":1,"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf8f382011a8502540be4008309e21294c19fd9004b5c9789391679de6d766b981db94610872386f26fc10000b884febefd610000000000000000000000000000000000000000000000000000000000000040774698fa2376011861164cab67edbbb548c07f8469290660daab54346748eabd0000000000000000000000000000000000000000000000000000000000000001573c10ac5e6e24ecdd14853a4896e39e2b4f88d943851ad2c102aec9a3f6f77b2aa01b7930c68ebe69a589cf3ce3313561f3c375d6f7c1c5171131dd742ba189b55aa02de9249967fd893ad629e13923594de112b6afe320b8cf0294d225ee24f92dd6"]}' https://ropsten.infura.io
fruor
@fruor
Jan 10 14:34
thanks
Juan Blanco
@juanfranblanco
Jan 10 14:34
so no errors as such
so if you replace the params payload
with the new one
which it will be the raw transaction signed
fruor
@fruor
Jan 10 14:35
I rely mostly on lazy nonce calculation, so I don't include them in the message. But I know I did sth different in startAuction bc this was still my first one
Juan Blanco
@juanfranblanco
Jan 10 14:35
then you should see the responce
oh yes that issue is mainly due to yourself sending a new transaction whilst i was testing
but overall the request / response is correct
in this scenario it was a nonce issue
fruor
@fruor
Jan 10 14:40
right
just tried it with a new and now gas too low
can I somehow get the rpc response in nethereum, too?
Oh, wait...
hahahahaha
I really forgot to fill up my test wallet with this minor parameter called Ether
Juan Blanco
@juanfranblanco
Jan 10 14:42
ha ha those little things
fruor
@fruor
Jan 10 14:46
yeah, at least some silly stuff with infura going on
Is there a way to get the RPC Error messages here?
Juan Blanco
@juanfranblanco
Jan 10 14:48
you will get it with the curl response
fruor
@fruor
Jan 10 14:48
yeah but not in nethereum
Juan Blanco
@juanfranblanco
Jan 10 14:48
yes it is the same
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"nonce too low"}}
in that scenario the exception message will be "nonce too low" in Nethereum
that is the RpcException
fruor
@fruor
Jan 10 14:50
Sorry but where - the request above throws the exception, the exception only mentions error 400, the logger only that there IS an rpc exception as far as I can see
Roy
@Shammah
Jan 10 14:51
The RPC exception should have an innerexception that may tell you more
fruor
@fruor
Jan 10 14:53
the catch(Exception e) innerException doesn't mention RPC
System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route)
Roy
@Shammah
Jan 10 14:55
Oh right, uuuh, yeah I don't think it's possible at the moment? That http exception gets thrown before the content is read?
fruor
@fruor
Jan 10 14:58
The Common.Logging.Simple.CapturingLoggerFactoryAdapter produces Events, of which the MessageObject or RenderedMessage is only the string "RPC Exception, RPC Request: ..."
the Events also have an Exception but this is the HttpRequestException with InnerException = null
Juan Blanco
@juanfranblanco
Jan 10 14:59
yeah that is a server exception
so the rpc error message has not been returned
can you pass me a valid nonce payload
Roy
@Shammah
Jan 10 15:00
Error 400 is usually when you've sent incorrect input, in the case of incorrect nonce I'd expect return code 200 with an error message
Juan Blanco
@juanfranblanco
Jan 10 15:00
so i can curl (it)
yes exactly
fruor
@fruor
Jan 10 15:02
{"id":1,"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf8f482011b850306dc42008309e21294c19fd9004b5c9789391679de6d766b981db94610880713e24c43730000b884febefd610000000000000000000000000000000000000000000000000000000000000040d6433fb160a017f1c2414849d6256d3e5becdebc06a658165898438ee65ee7ec0000000000000000000000000000000000000000000000000000000000000001eb8b04d974d9679812d77892c0d971a7c2f281b7aa582d23e045b2bec089231b29a0db9b13bae4edb3c337192825b8caa53507c634c5b253632fafd8ed9984527cbba064ce6e54ff1da3e3ea1c7d8a850c6f650bb84ce6af1ace7fb35fe00b7ceb0efe"]}
this is valid nonce but Gas is too low
bc I selected to send so many Ether that I would run out of gas
or do you want me to create something that would go through without broadcasting it?
Juan Blanco
@juanfranblanco
Jan 10 15:04
yes please
mainly to try to force the 400
and see if there is something else returned
fruor
@fruor
Jan 10 15:04
this made a 400
Juan Blanco
@juanfranblanco
Jan 10 15:05
oh ok
image.png
so we get the rpc error message
you mainly got first the server error message (which you should not get)
fruor
@fruor
Jan 10 15:13
exactly
but we probably cannot change what infura is sending in this case
Error occurred when trying to send rpc requests(s) lastRPCMessage: RPC Exception, RPC Request: {[the one from above]} InnerEx: System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route)
Juan Blanco
@juanfranblanco
Jan 10 15:21
ok the issue is this
image.png
so the problem is that Infura in ropsten is sending a 400 error plus the rpc error message
Nethereum treats the 400 as a server error and stops reporting trying to decode it
so expects a 200 and later on check for an rpc error message
I am checking with infura about this specific ropsten thing (as ropsten is pretty old)
fruor
@fruor
Jan 10 15:24
thank you Sir, you are amazing
and a man of culture as well (linux subsystem ftw)
Juan Blanco
@juanfranblanco
Jan 10 15:27
ha ha thanks :)
That is the FluentTerminal
fruor
@fruor
Jan 10 15:29
oh, didn't know that one
fruor
@fruor
Jan 10 15:40
as for my second question, whenever I initiate web3 like this
web3secured = new Web3(jsonRpcUrl);
and the endpoint is a parity node without the flag --expose-unsafe
I get this as soon as I do something, e.g web3securedconnected = web3secured.Net.Listening.SendRequestAsync().Result;
Error occurred when trying to send rpc requests(s) ---> System.OperationCanceledException: The operation was canceled.
--expose-unsafe actually just sets a series of flags at once, I will now investigate which ones it needs
fruor
@fruor
Jan 10 15:57
aaaaand there's my second silly mistake of the day. of course on another pc in lan i need --jsonrpc-interface=all
Roy
@Shammah
Jan 10 15:59
(:
fruor
@fruor
Jan 10 16:00
right, thank you guys. all well now
Daniel Moos
@d-moos
Jan 10 16:39
Hey guys! Is there any chance to determine if a Token is ERC20 or ERC721 with Nethereum?
Roy
@Shammah
Jan 10 16:52
I can't find any current 'test' method yet. I think the only option is to see if the token contract implements all required ERC20/721 methods
Juan Blanco
@juanfranblanco
Jan 10 17:32
@fruor glad you are sorted
@d-moos yes that is more or less the best that it can be done
Juan Blanco
@juanfranblanco
Jan 10 18:11
@fruor talked to the infura team they will change the 400 response code to 200 in around a week
Janez Kranjc
@janezkranjc
Jan 10 22:04
Hello! I'm having problems signing messages with nethereum then using ecrecover in solidity
can someone help me?
I can sign a message in python or in javascript and get the same signature, but I just cant get it to sign correctly with nethereum
I always get a different signature, and when I try to do ECRecover in nethereum with the signatures I got in python (web3py) and javascript (web3), I get a different address
(I'm doing offline signing)
Janez Kranjc
@janezkranjc
Jan 10 22:09
basically what I'm saying is - if I sign something in geth I get a different signature than if I sign it with nethereum, so it's somehow incompatible
I can mimic geth's signatures in javascript and python, but not in C#
and I would very much like to do that
I'm looking at this test
Janez Kranjc
@janezkranjc
Jan 10 22:15
when I try to sign this same message in geth
using the same privatekey provided in this test
i get a different signature
Janez Kranjc
@janezkranjc
Jan 10 22:49
I get this signature 0x636415c264d2dce40c739fda66f1f7c75db64ccded2ca69faecb170c099ae96d17020acddc395147c1d62b93ae7493b499251cd88a48dcaf1089fc9616ebbbfb1b
which is totally different from the one in the test
I can verify this signature in solidity using ecrecover
but not the one generated by nethereum
the hashprefix2 are the same in all three implementations (web3py, web3, and nethereum)
but finally the signature is different in nethereum
(while it is the same in web3py and web3)
fruor
@fruor
Jan 10 22:57
@juanfranblanco awesome news about infura, thank you
Janez Kranjc
@janezkranjc
Jan 10 22:57
but apparently they are both valid
they are 2 signatures of the same message, how do I verify the second one using solidity?
Janez Kranjc
@janezkranjc
Jan 10 23:05
uh
nevermind my ramblings, both are working fine
:D
fruor
@fruor
Jan 10 23:06
still why is the signature hash different?
Janez Kranjc
@janezkranjc
Jan 10 23:17
I have no idea, and it works for the message 'test'
whenever I try something more complex
it recovers a completely different addres
the signatures are different
and V value is 27 in python and javascript and 28 in nethereum
so maybe different version of signing?
Janez Kranjc
@janezkranjc
Jan 10 23:31
uh, I finally got it working
I was mistakenly using EthereumMessageSigner
instead of MessageSigner
in my code
gotta check the source code to see what the difference is