These are chat archives for Nethereum/Nethereum

31st
Jan 2019
Online Certification Token
@provetoken
Jan 31 13:19
hi
I have the following
code:
        var service = new StandardTokenService(web3, contractAddress);
        var balance = service.BalanceOfQueryAsync(address, new BlockParameter((ulong)blockNumber)).Result;
apparently BalanceOfQueryAsync doesn't take into account the second parameter (blockParameter)
is it a bug?
Dave Whiffin
@Dave-Whiffin
Jan 31 13:21
@provetoken What client are you using? (Parity / Geth / Infura and which network?)
Online Certification Token
@provetoken
Jan 31 13:22
thank you for your answer
I'm using Nethereum framework on rinkeby
with geth
Dave Whiffin
@Dave-Whiffin
Jan 31 13:24
Just to be sure - you want to retrieve the balance of that contract/token as it was at a specific block?
Online Certification Token
@provetoken
Jan 31 13:24
now I see how does it work
is there any way to get the balance for a specific block?
Dave Whiffin
@Dave-Whiffin
Jan 31 13:25
for an address/contract?
Online Certification Token
@provetoken
Jan 31 13:25
yes
or ..a transaction
I could make the difference between the current block and the previous
but this means 2 queries
Dave Whiffin
@Dave-Whiffin
Jan 31 13:32

If you want to know the amount of ether involved in a block you could just retrieve the transactions in the block? Each transaction has the value - those can be added up.

new Web3.Web3().Eth.Blocks.GetBlockWithTransactionsByNumber etc

Online Certification Token
@provetoken
Jan 31 13:33
ok..but it seems slow
what about getting the balance of tokens
is there any code I can look for?
I'm parsing the logs string
manually
Dave Whiffin
@Dave-Whiffin
Jan 31 13:37

In the code above - there is no parsing involved. You get a list of typed transaction objects. It's not slow.

But really - you need to describe exactly what you want to achieve?

Balance of an address as it was at a specific block?
The total amount of balance movement for all tx (regardless of address) in a block?

Online Certification Token
@provetoken
Jan 31 13:40
I'm trying to get of ETH and Tokens received based on transaction hash
Dave Whiffin
@Dave-Whiffin
Jan 31 13:55
There's different ways of achieving this - but this is one way:
            var web3 = new Nethereum.Web3.Web3();
            var transferEvent = web3.Eth.GetEvent<TransferEventDTO>();
            var receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync("<your tx hash>");
            var transfers = transferEvent.DecodeAllEventsForEvent(receipt.Logs);


            foreach(var transfer in transfers)
            {
                //grab the value of the transfer
                //transfer.Event.Value
            }
Online Certification Token
@provetoken
Jan 31 13:59
great,many thanks
cloverme
@clovermebitcoin
Jan 31 17:49
Got a question... So I'm using receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(txhash) in a wait loop to check for a receipt... however, in one case I had a {Dropped & Replaced} and receipt was null. How can I check for a {Dropped & Replaced} event while waiting for a receipt?