These are chat archives for Nethereum/Nethereum

10th
Jul 2018
Truong Dang Nghia
@DangNghia123_twitter
Jul 10 2018 04:46
hi, anyone know there is a ethereum wallet on android
Juan Blanco
@juanfranblanco
Jul 10 2018 05:47
there are some, if you want a sample you can see the https://github.com/Nethereum/Nethereum.UI.Wallet.Sample
Zeshan Virk
@zeshanvirk
Jul 10 2018 06:27
is there any method that give me transactions is last 10 block? or i have to do it with forloop?
Zeshan Virk
@zeshanvirk
Jul 10 2018 07:33
i'm using GetBlockWithTransactionsByNumber to get transactions in block and its giving me gas,gasprice,value in hex. How can i get their original value instead of hex.
currently its giving response like :
"gas": "0x249f0",
"gasPrice": "0x29e8d60800",
"value": "0x19af4521056f9800
Enigmatic
@EnigmaticUnreal_twitter
Jul 10 2018 08:24
@zeshanvirk - You'll need to do something like gas.Value
image.png
Enigmatic
@EnigmaticUnreal_twitter
Jul 10 2018 08:30
I guess alternative you could convert the hex to biginteger too, but it's already part of the value.
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:20
@EnigmaticUnreal_twitter if i get transactions of 10 blocks then the total number of transactions will be about ~500-700, it'll be not a good approach to convert the value for each transaction and then pass it to the client. There should be any way to recieve value only, instead of hex in transaction array
Enigmatic
@EnigmaticUnreal_twitter
Jul 10 2018 09:21
In my reply above I did mention you can also retrieve it as gas.Value which will return you a BigInteger.
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:22
GetBlockWithTransactionsByNumber returns array
not single object
if there are 150 transactions in one block
then you want me to convert for 150 and then add it to some new array? i don't think its a good approach
if i get transactions of 10 block then the transactions will be around 500-700, and converting each transaction will slow down the process
@juanfranblanco whats your suggestion or recommendation about this?
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:35
?
Juan Blanco
@juanfranblanco
Jul 10 2018 09:39
?
@EnigmaticUnreal_twitter has given a great answer
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:40
but that doesn't solve the problem
Juan Blanco
@juanfranblanco
Jul 10 2018 09:40
i don't understand your conversion
what problem
you get the transactions
you work with them
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:41
var blocknumber = await _web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();
List<Nethereum.RPC.Eth.DTOs.Block> txs = new List<Nethereum.RPC.Eth.DTOs.Block>();
for (int i = 0; i <= 10; i++)
{
var block = await _web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(new HexBigInteger(blocknumber.Value - i));
txs.Add(block);
}
that code will give me 10 blocks info, right?
now each block have 50-70 transactions
and every transaction have hex value
Juan Blanco
@juanfranblanco
Jul 10 2018 09:42
yes
that is the rpc
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:42
you want me to convert for each block and for each transaction in each block?
Juan Blanco
@juanfranblanco
Jul 10 2018 09:42
comes in hex
that is why you have a hex value
you don't convert anything
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:42
then?
Juan Blanco
@juanfranblanco
Jul 10 2018 09:42
that is done by the HexValue
YourValue.Value
what do you mean by "then?"
i don't understand your question / problem
what is different from the original answer
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:44
12.PNG
thats a postman call
and in that i'm getting hex value
here i can't do gas.value
Juan Blanco
@juanfranblanco
Jul 10 2018 09:45
are you using Nethereum?
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:45
yes
using the code that i sent you above
Juan Blanco
@juanfranblanco
Jul 10 2018 09:46
sure
so what is the problem :)
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:47
the problem is that in response i'm getting hex, i want value
Juan Blanco
@juanfranblanco
Jul 10 2018 09:47
and that is what Netherum does for you
that is why you have HexBigInteger
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:48
Netherum is giving me that response
Juan Blanco
@juanfranblanco
Jul 10 2018 09:48
are you debugging?
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:49
yes
Juan Blanco
@juanfranblanco
Jul 10 2018 09:49
and checking the Value
ie Nonce.Value
that is the BigInteger Value
that's it
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:50
yes in visual studio it shows that, but when i return that result
all i got is in hex
why not value?
Juan Blanco
@juanfranblanco
Jul 10 2018 09:51
see now we have step down to your real problem
a HexType in Nethererum
returns a HexValue
or a type converted Value
so Nonce as an example in a Transaction
can return
Nonce.HexValue (string hex)
or Nonce.Value (BigInteger value)
simple as that :)
also thanks @EnigmaticUnreal_twitter for stepping again and helping
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:55
yes exactly, and again my question is, its returns hex as you saw in response ss, how can i return value in it?
The block contains 150 transactions array, i can't do nonce.value in an array. for this i've to convert all 150 transactions to value, you want me to do it this way?
Juan Blanco
@juanfranblanco
Jul 10 2018 09:55
????????
you have a transaction array
you loop for each transaction if you want to get the value of each one
each one will have different values
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:57
and thats what i asked the very first time that if i get transactions of 10 blocks it will return around 500-700 transactions in an array, and for loop will slow down the process, isn't there any better way except this? :(
Juan Blanco
@juanfranblanco
Jul 10 2018 09:57
you can use linq if you fancy and project all the nonce values into an array
but you were asking about conversions
and values
if you want to iterate through all the transactions looping is a good way
mutlithreading is also a good way depending of what you want to achieve
Zeshan Virk
@zeshanvirk
Jul 10 2018 09:59
Did you set the default return type of HexType in Nethereum? as if we don't do nonce.value it will not return value. it will return hex, why?
Juan Blanco
@juanfranblanco
Jul 10 2018 09:59
but since each transaction is in order you may not want to multithread
Because it is a HexType
and since is HexType my reasoning will be to return a Hex
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:01
ok
Juan Blanco
@juanfranblanco
Jul 10 2018 10:01
that is what I thought when I created that type :)
similarly to a nullable type
a nullable type has a Value
that was the inspirational thought
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:02
but as per my view there should be a method that returns value, instead of hex so that looping part can be skipped.
Juan Blanco
@juanfranblanco
Jul 10 2018 10:02
what ?
i don't understand that reasoning, on eliminating loops
if you are going to retrieve all then nonce values of all the transactions in an array
you will have to loop somehow
or multithread and project them
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:04
Value is what required mostly, hex isn't required as value.
Juan Blanco
@juanfranblanco
Jul 10 2018 10:04
well
some people might just want the hex value
hex is the standard rpc method
and you need to use it to retrieve and submit values
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:06
okay
Juan Blanco
@juanfranblanco
Jul 10 2018 10:07
although this decition was made 2 years ago
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:07
but in other cryptos there isn't concept of hex.
Enigmatic
@EnigmaticUnreal_twitter
Jul 10 2018 10:10
Was wondering @zeshanvirk - Is it possible from Postman to specify which values of the object you want to pick up? So instead of picking up all the defaults, you can say "pick up gas.Value instead of gas.HexValue"?
I have not worked with Postman before, so you'll know better.
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:11
its not possible in postman. it will get what you sent.
btw @EnigmaticUnreal_twitter what tool you use to test restful api?
Juan Blanco
@juanfranblanco
Jul 10 2018 10:14
Sorry I meant the hextype for Nethereum was created nearly 3 years the Ethereum spec for RPC much longer than that. The differences between other cryptos, there is not much I can do about it. Most probably you will need to take your thoughts to Gavin Wood. (As he created the yellow paper) Also note that the BigIntegers are encoded differently as they are packed.
So if your intention was to used the whole JSON you still will need to parse it and convert it
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:17
as other cyptos gave us converted values, so i though there must be a way in Eth too, did the eth rpc sends the hex or value or both?
Juan Blanco
@juanfranblanco
Jul 10 2018 10:18
Hex is the only one and standard
You could have asked that first!
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:24
i did now :)
Juan Blanco
@juanfranblanco
Jul 10 2018 10:25
:D
Now reversing your thoughts, an optimisation that could be done is the total opposite
which is only convert when accessing the Value
Juan Blanco
@juanfranblanco
Jul 10 2018 10:31
but that will also be an issue as you wont get notified of invalid hex until accesing the value
so lazy loading in this scenario might be very confusing
but an option
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:33
as per me, the only better option is to convert the hex into value while accessing it.
looping will increase the request time
Juan Blanco
@juanfranblanco
Jul 10 2018 10:34
well you did not want that in the first place
as it you did not want to use Value ;)
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:34
yes
i want to use value.
on the client side obviously the user concern with value, not with hex
Juan Blanco
@juanfranblanco
Jul 10 2018 10:35
i mean the Value property
the user is concerned with hex
as he needs to do converions
for rpc messaging
on the rpc api
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:36
its all messed
:D
Juan Blanco
@juanfranblanco
Jul 10 2018 10:36
why? because that provides you the understanding
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:37
do you know about etherscan?
Juan Blanco
@juanfranblanco
Jul 10 2018 10:37
of course I do
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:37
etherscan don't shows the hex, it shows the value to user,
Juan Blanco
@juanfranblanco
Jul 10 2018 10:37
but i am not going to start a debate
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:37
:D
Juan Blanco
@juanfranblanco
Jul 10 2018 10:37
sure you are a developer
not a user
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:38
yes, and Netherum is built for developers by a developer for the ease of developers. am i right? :D
Juan Blanco
@juanfranblanco
Jul 10 2018 10:39
sure and you are the only one who has mentioned this
which is good feedback
but 2 years too late
and going back the point of optimisation
now i can do Lazy loading of types
other way I wouldnt be able
and yeah for the easy usage of developers
you have the whole abi stuff
and the only thing you need to do is HexType.Value
not a big problem
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:44

let suppose i'm developing a restful api,

i wrote a method that will give me information in a block

Another use called that api method, the api return him hex. Now either he'll convert it or i'll do it by looping.

if i do it by looping it will slow down the response time.
thats why i was asking about a better solution
did you got me?
Juan Blanco
@juanfranblanco
Jul 10 2018 10:45
but that is the standard rpc
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:45
okay, i'll say the same to the developer who will use that api :D
Juan Blanco
@juanfranblanco
Jul 10 2018 10:46
i don't understand really
Ethereum h as an rpc standard
that is the way it is
it may change in the future, but that will mean every api will change
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:48
yes yes i got your point. hex is what eth returns. we have to convert it on our own.
information about the hex value encoding
which is also not "just" hex
Zeshan Virk
@zeshanvirk
Jul 10 2018 10:51
(y)
Zeshan Virk
@zeshanvirk
Jul 10 2018 11:57
@juanfranblanco if i manually convert the hex to value using c#, the hex i'll use to convert is after x? 4e942f760 instead of 0x4e942f760 ?
if you manually convert the hex
you will need to conform to the hex standards
for the rpc
which is not the standard hex
Zeshan Virk
@zeshanvirk
Jul 10 2018 11:58
ok
Juan Blanco
@juanfranblanco
Jul 10 2018 11:59
so you will end up using the hex types
just pushed a modification to the hex types
to lazy load
so if you want further optimisations will be only due json.net
also another important point
can be blank
or null from json
as some values are optional
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:02
okay
Juan Blanco
@juanfranblanco
Jul 10 2018 12:03
mainly you will still need to parse the json and retrieve the values, hey you could use a regex
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:07
what kind of regex?
Juan Blanco
@juanfranblanco
Jul 10 2018 12:07
it is a passing thought :)
to match values in the json
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:08
whatever i do, i have to convert the hex to value at the end.
:D
Juan Blanco
@juanfranblanco
Jul 10 2018 12:08
of course
but you just read the text and get the values you want
just going down on to optimisations thoughts
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:10
but there is a problem in that, some hex returns big int some returns int, if i pass int hex to big int it gave false value.
Juan Blanco
@juanfranblanco
Jul 10 2018 12:13
btw if you are just looking to get the gas price (re read the conversation)
geth provides you that with EthGasPrice
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:14
no i dont want the gas price only, i want the blocknumber, nonce, gasprice,gas,value,transactionIndex
Juan Blanco
@juanfranblanco
Jul 10 2018 12:15
so you want all the data
or most of it
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:15
yes
Juan Blanco
@juanfranblanco
Jul 10 2018 12:15
then ignore json parsing
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:15
yes i ignored it, i tried it but it wasn't useful for me.
i think looping is the only way left
Juan Blanco
@juanfranblanco
Jul 10 2018 12:16
if you are going to parse all the records yep
the lazy load optimisation i just pushed can save a fraction there
but if you are interested in most of the data
you are not going gain much that way
multithreading is a good option
but like i said depending of the data you neeed
as the data is in a ledger so it is in order
so business logic associated with it
is dependent on order
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:18
i think i should go for looping. that will be better for my scenario.
etherscan too do it with looping?
Juan Blanco
@juanfranblanco
Jul 10 2018 12:19
i couldnt tell you
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:19
:D
Juan Blanco
@juanfranblanco
Jul 10 2018 12:20
the optimisation can go at client level
whilst syncing transactions / blocks
it all depends what you are doing
Zeshan Virk
@zeshanvirk
Jul 10 2018 12:21
hmm
Juan Blanco
@juanfranblanco
Jul 10 2018 14:55