These are chat archives for Nethereum/Nethereum

30th
Nov 2018
Kasper Hämäläinen
@miekassu
Nov 30 2018 06:21

@juanfranblanco on August 25 2017 you wrote

need to add an error / warning to validate if the file opened is the json file

could you specify what you mean and how "Error generating code:
Unexpected token p in JSON at position 0" is fixed in the VS Code. Thanks!

Enigmatic
@EnigmaticUnreal_twitter
Nov 30 2018 07:01
Hmmmm yikes I just realised I wanted to tag @p0onage on his flying comment yesterday actually, as he was proposing a cool idea to attempt it through Truffle. :D
Roman Rudenko
@roman-rudenko
Nov 30 2018 07:18
Hi All, I have pool eth addresses, I need to have cache (in my db) of their balances to avoid query network for balance of every address when I need display all them. Could I use Nethereum for monitoring all transactions in network? I'm going update balance cache (in my db) for address only if address present in transaction. Will it works?
Dave Whiffin
@Dave-Whiffin
Nov 30 2018 08:17
@roman-rudenko Hi, yes. See the block chain storage repo. It has an extensible solution for traversing and filtering the chain and persisting transactions/logs into a variety of DB’s. https://github.com/Nethereum/Nethereum.BlockchainStorage. There’s also Blockchain Processing repo which is a little more abstract and allows you to do pretty much anything you want with chain data. https://github.com/Nethereum/Nethereum.BlockchainProcessing
Roman Rudenko
@roman-rudenko
Nov 30 2018 10:50
@Dave-Whiffin Thank you!
proBeejay141
@proBeejay141
Nov 30 2018 11:55
Is there a way to get Ethereum transaction list of an address with nethereum?
Dave Whiffin
@Dave-Whiffin
Nov 30 2018 12:44

@proBeejay141 Hi - one way is to walk the blocks on the chain and grab transactions of interest along the way. (see below - you just need a reference to Nethereum.Web3)

        static async Task GetTransactionsForAccount()
        {
            const string MyContractAddress = "0x7316203132adace374f530bd0850e66c2bfe6daa";
            var myTransactions = new List<Transaction>();
            var web3 = new Web3.Web3("https://rinkeby.infura.io/v3/25e7b6dfc51040b3bfc0e47317d38f60");

            for (ulong blockNumber = 2830143; blockNumber < (ulong) 2830243; blockNumber++)
            {
                var blockTransactions = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(
                    new HexBigInteger(blockNumber));

                myTransactions.AddRange(blockTransactions
                    .Transactions
                    .Where(t => t.To != null && t.To.Equals(MyContractAddress, StringComparison.InvariantCultureIgnoreCase)));
            }
        }

Also - see the repo below, which has extensible solutions for reading from the chain (tx and logs).

https://github.com/Nethereum/Nethereum.BlockchainProcessing/

proBeejay141
@proBeejay141
Nov 30 2018 12:57
@Dave-Whiffin Thanks, but i mean for Ether not for contract token
Dave Whiffin
@Dave-Whiffin
Nov 30 2018 12:58
@proBeejay141 The example just gets any tx sent to an address? It doesn't matter if it's a contract or not?
hessam94
@hessam94
Nov 30 2018 16:39
hi, would you tell me how to return the address ? i used this code var result = await q.QueryAsync<Int64>(msg, contractAddress); also with int32 and string , but all of them send me back "the vlaue is too small or too large for int32". the solidity code is right and works on remix test IDE, thanks
Dave Whiffin
@Dave-Whiffin
Nov 30 2018 16:55
@hessam94 Have you tried System.Numerics.BigInteger? That is a commonly used type for mapping to and from Ethereum numbers.
hessam94
@hessam94
Nov 30 2018 17:02
yeah it worked thank you very much, after that we have to change it to hex,
Dave Whiffin
@Dave-Whiffin
Nov 30 2018 17:09
@hessam94 Excellent - also worth knowing are the hex based extensions in Nethereum.Hex.HexConvertors.Extensions and the Nethereum.Hex.HexTypes.HexBigInteger type.
hessam94
@hessam94
Nov 30 2018 19:28
One more Q, i saw in TestChain, you provided a pre configured account. with address and PvtKey! I know that we cannot get private by PublicKey. how did you get the privateKey? We can make up new Account("privatekey") but it needs a file in keystore folder. I need more than one account because I want to set up an application for more than one player. I can create an account with GETH but it asks me password and gives me an address, AND in NETHEREUM it asks me a private key to set a new account and send my requests. It seems I confused some parts, Thanks
Dave Whiffin
@Dave-Whiffin
Nov 30 2018 19:32
@hassam94 I am going out now, but this page in the docs might help. https://nethereum.readthedocs.io/en/latest/accounts/
Daniel Hursan
@hdany
Nov 30 2018 21:07
Hello everyone. Did any of you experience "false negatives" while deploying a new token contract? The contract was actually successfully deployed, but Nethereum throws an error
transactionReceipt =
                    await
                        web3.Eth.DeployContract.SendRequestAndWaitForReceiptAsync(
                            compileContractResult.abi,
                            compileContractResult.bytecode,
                            MyAddress,
                            estimatedGas);

Exception Message: Code not deployed succesfully
Stacktrace:
   at Nethereum.RPC.TransactionReceipts.TransactionReceiptPollingService.<DeployContractAndWaitForReceiptAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at ErcToken.Core.ContractHelper.<DeployContract>d__5.MoveNext() in  ...
By looking at the TransactionReceipt -> TransactionHash in the exception I was able to search the hash in EtherScan and token is actually ok. Not sure why an error is thrown. By doing more testing it seems it's thrown randomly.