These are chat archives for Nethereum/Nethereum

28th
Nov 2018
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 05:01

Some block heights would work, especially if they're closer to the current block, as geth/parity does keep some block state in memory

This might give a better insight: https://ethereum.stackexchange.com/questions/40648/full-node-sync-only-preserve-the-last-128-history-states.

I was playing around with the idea how we could more easily retrieve historical balances last night, probably with some "creative" use of block explorers; Happy to learn from anyone else if there's any other ideas. =D
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 05:23
Speaking of which @shareworlds - Are you using Infura or synced a local node? I think I was able to get historical balances from way back with Infura.
keepbreath
@keepbreath
Nov 28 2018 10:14
@EnigmaticUnreal_twitter Hello,Do you know the relevant solution to this exception("ERC-20 Token Transfer Error (Unable to locate Corresponding Transfer Event Logs), Check with Sender.")?And... How do I know the gas value of the current transaction?Thank you
Juan Blanco
@juanfranblanco
Nov 28 2018 10:18
@keepbreath what is your environment to get that exception?
keepbreath
@keepbreath
Nov 28 2018 10:18
@juanfranblanco with infura
Juan Blanco
@juanfranblanco
Nov 28 2018 10:19
"ERC-20 Token Transfer Error (Unable to locate Corresponding Transfer Event Logs), Check with Sender."
that is a very specific error
the rpc node wont' throw that exception
what library are you using?
I don't think I have put that exception even on the wallet samples :)
ahh.. you see that exception in Etherscan
that explains the situation
keepbreath
@keepbreath
Nov 28 2018 10:25
emmm.ok let me try,Thank you.QAQ..
Juan Blanco
@juanfranblanco
Nov 28 2018 10:25
So what etherscan does to validate the token transfer was successful (the call was identified as a token transfer based on the signature), is to check if an event has raised using the ERC20 Transfer event
in this scenario the transaction was successful but the transfer event did not occurred, so you may not have enough balance for the transfer (token balance), ie failed before raising the event, or the contract does not raise an event (so it is not really a standard erc20 contract)
keepbreath
@keepbreath
Nov 28 2018 10:31
ok,let me check the balance of token
MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 11:42
Hi I am trying to write the APIs using Nethereum and in my application I am making raw transactions. In this scenario, I am facing nonce issue as the current get transaction count will not have the count of pending transactions.
Could someone help me on how to get the tx count form the pending transactions. I found below links but not sure how to use it, if I need to change the geth files or I need to include in my code
https://ethereum.stackexchange.com/questions/42465/nethereum-how-to-get-the-list-of-pending-transactions-havent-mined-to-a-block
http://qnimate.com/calculating-nonce-for-raw-transactions-in-geth/
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 12:56

@MANOJKUMARCH - You could use txpool, something like this which would return the JSON result that you can parse.

Dim obj As New Nethereum.JsonRpc.Client.RpcClient(New Uri("http://localhost:8545"))
Dim res = Await obj.SendRequestAsync(Of Object)("txpool_inspect")

Though... Hmm... I think a better way might be to maintain your own nonce counter, if using a web3 object to maintain the nonce is not possible.

MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 13:04
@EnigmaticUnreal_twitter , Thanks for the response, I am writing the code in c# and I am new to c# and so did not get what your code says as obj.SendRequestAsync(Of Object)("txpool_inspect")
I am currently creating the web3 objext in below manner, can you help me on how to access txpool from Nethereum
var web3 = new Web3(account, "http://127.0.0.1:8001/", null, null);
Joshua Duxbury
@p0onage
Nov 28 2018 13:22
I could be wrong, but I'm sure I've heard @juanfranblanco talk about a built in memory cache for the nonce? "if you use the same instance of Web3 / Account the InMemoryNonceService keeps track of your nonces
if you are using the same account in different executables, the best thing is to create your own nonce tracker microservice"
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 13:42

You're absolutely right @p0onage :)

@MANOJKUMARCH - You could refer to the below link, since you're creating a web3 object you could transfer ethers using the transaction manager, which will handle the nonce for you... Or are we missing something with your use case?

https://nethereum.readthedocs.io/en/latest/nethereum-transferring-ether/

MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 13:46
@EnigmaticUnreal_twitter @EnigmaticUnreal_twitter , I have looked into the ether transfer function, but in my use case we also need to send the inputs to the transaction as a part of the logging. Ether transfer function do not support the data/input part. So could not use it.
Also in my use case we are running transactions in parallel from same account in 2 different nodes.
Joshua Duxbury
@p0onage
Nov 28 2018 14:05
I think what was previously suggested, is either use different accounts if possible and if not then you will need to create your own nonce tracker micro service
MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 14:08
@p0onage , Thank You, but I am looking to add the values of transactionCount and the number of pending transaactions for the given account. This will give correct nonce in case of raw, transactions. I found the below, but its not for Nethereum, so want to know if anything of such thing is available for Nethereum
http://qnimate.com/calculating-nonce-for-raw-transactions-in-geth/
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 14:14

we also need to send the inputs to the transaction as a part of the logging

Hmm. Could you elaborate a bit more on this please?

txpool is not implemented as a library call but could still be called through RpcClient.

Maybe if I understand better your use case there might be an overload somewhere which will help us.
Joshua Duxbury
@p0onage
Nov 28 2018 14:16
I could be wrong, but from my understanding If one of the pending transactions fails, won't you have a invalid nonce count if your using pending + current transactions for your nonce count? something maybe to be mindful of ?
MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 14:17
@EnigmaticUnreal_twitter , Let me give you an example
In case of John is sending the Ether to Ram as part of their deal to transfer of property, then in the part of Transaction Data "w.r.t transfer of property of xxx" will be sent. This will help in tracking the reason of the ether transfer.
@p0onage, yes and its correct. However, I am writing a exception catch and so it will be caught and handled manually. Really thanks for the thought through.
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 14:47

Oh - I think you can still use TransactionInput and define a transactioninput with data for that. To be clear, you're not sending to a smart contract, just a normal transaction + append with data, to a normal account?

Let me quickly test the code.

MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 14:50
@EnigmaticUnreal_twitter , here I am not using smart contract, it's just a normal transaction(transaction between two normal/non contract accounts) + apend the data.
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 14:56

https://ropsten.etherscan.io/tx/0xc850342fb4907464eb0b33225fa4f1e4189e8901d6a485bf97748356133c8594

Thanks for clarifying - Something like this transaction I reckon.

See if the below code helps? There might be cleaner ways to do it though, always happy to hear suggestions.

        Dim transactionInput = New Nethereum.RPC.Eth.DTOs.TransactionInput()
        transactionInput.Data = "0x123"
        transactionInput.From = account.Address
        transactionInput.To = "0x3d080421c9DD5fB387d6e3124f7E1C241ADE9568"
        transactionInput.Value = New HexBigInteger(1000000000000000)
        transactionInput.Gas = New HexBigInteger(50000)
        Dim txid = Await iweb3.Eth.TransactionManager.SendTransactionAsync(transactionInput)
        Dim receipt = Await iweb3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txid)

        'if receipt is received, transaction should be sent
        While receipt Is Nothing
            System.Threading.Thread.Sleep(5000)
            receipt = Await iweb3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txid)
        End While

And of course, web3 is initialised with the account above.

This is in VB.NET though..... Hmm..... An example in C# you could refer to:

https://github.com/Nethereum/MultipleAccountTransferSample/blob/master/Program.cs

Uses the same TransactionInput method.

If you see the code for TransactionInput, you get access to Data, and if you ever need the nonce you could use it as well.

https://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.RPC/Eth/DTOs/TransactionInput.cs

MANOJKUMARCH
@MANOJKUMARCH
Nov 28 2018 15:01
@EnigmaticUnreal_twitter , I tried SendTransaactionAsync method and it works flaw less with single node, but I am using a private key to create account/web3 instance and working on two different nodes in parallel with same account. This actually created the nonce issue.
Enigmatic
@EnigmaticUnreal_twitter
Nov 28 2018 15:02
Ah. Then @p0onage is spot on. You'll need to create a microservice for web3, which both nodes connect to.
Dave Whiffin
@Dave-Whiffin
Nov 28 2018 16:04
@MANOJKUMARCH or - if feasible - use a different account for each parallel process/node