These are chat archives for Nethereum/Nethereum

22nd
Jan 2019
Craig Waite
@craigvl
Jan 22 02:19
This message was deleted
@Shammah we are able to refund reward if required, we don't currently support multiple collaborators, would love your feedback if you want to jump onto the app. Thanks.
mosinms7711
@mosinms7711
Jan 22 07:48
@juanfranblanco How to create Vetted Wallet with Seed Phrase and how can we recover same account…????
Grey007
@Grey007
Jan 22 08:14

Hey @Dave-Whiffin & @juanfranblanco ,

It's been awhile but I'm back. I want to get your guys opinion on something.

Is it better to subscribe to pending transactions? Or to use your blockchain store that processes every block? Specifically, I just need to identify when any of my addresses have received transactions or sent transactions.

Grey007
@Grey007
Jan 22 08:31
Another question, if I use the blockchain storage tool. I give it a list of my addresses, how would I update the list of addresses?
Juan Blanco
@juanfranblanco
Jan 22 09:10
hi @mosinms7711 Vetted?
mosinms7711
@mosinms7711
Jan 22 09:11
Simple Wallet
Juan Blanco
@juanfranblanco
Jan 22 09:11
HdWallet?
mosinms7711
@mosinms7711
Jan 22 09:11
Yes...
how to create seed phrase while creating Wallet...
check that constructor
mosinms7711
@mosinms7711
Jan 22 09:13
@juanfranblanco Thank You..
Juan Blanco
@juanfranblanco
Jan 22 09:14
@Grey007 depends what you are doing, and reliability
if you have many accounts and you want to ensure a number of confirmations, the best is the blockchain processing checking for the accounts after a set of blocks
if you wan to react very fast to transactions but you are happy that they might be reorganised, you can subscribe to pending transactions and check for the addresses there
Grey007
@Grey007
Jan 22 09:25
Perfect, so I'm now playing around with the Blockchain Processing tool now. To filter on an address, I use var transactionFilter = TransactionFilter.ToOrEmpty(address) correct?
Dave Whiffin
@Dave-Whiffin
Jan 22 09:32

@Grey007 As Juan suggested - it depends!

If you need reliability and persistence (i.e. the ability to pick up where you left off) then it's best to use Blockchain storage or Blockchain processing - these both walk the blocks sequentially. They both support persistence of progress, so if your process crashes you can restart and pick up again.

If events on your contracts are enough to identify the transactions you need - then the most efficient way is use the BlockchainLogProcessor in the Blockchain processing repo. This walks events by block number range. It's quicker than walking the blocks, transactions and logs. Again, it supports filtering.

If events aren't sufficient to identify all related transactions then you can use the Blockchain processor.

Link to samples:

https://github.com/Nethereum/Nethereum.BlockchainProcessing/tree/master/Nethereum.BlockchainProcessing.Samples

Regarding tracking your addresses. If you have a static list then you can pass in a transaction filter which is pre loaded with them. The example you quoted above is fine for one address but it also supports multiple addresses.

If the addresses are dynamic (changing whilst processing) then you just need to create your own transaction filter (implementing the very simple ITransactionFilter) to dynamically retrieve the addresses and filter. The storage project has configuration to stay within x number of block confirmations (to avoid storing orphaned data).

Schalk Dormehl
@sjalq
Jan 22 09:56
@juanfranblanco , what is the simplest route to getting the block time in the latest block?
Roy
@Shammah
Jan 22 10:00
The blocks have a .Timestamp property, if that's what you need
Grey007
@Grey007
Jan 22 10:00

I'll use the Blockchain Processing, and then create a transaction filter to dynamically retrieve the addresses.

I don't need events just yet. Purely looking at a transaction level relating to an address.

Dave Whiffin
@Dave-Whiffin
Jan 22 10:06

@Grey007 Nice one .- The TransactionFilter object can accept a lambda in the constructor. That is evaluated every time a transaction is retrieved. So you can just load that with the function that retrieves your addresses and checks if the transaction belongs to them.

https://github.com/Nethereum/Nethereum.BlockchainProcessing/blob/master/Nethereum.BlockchainProcessing/Processors/Transactions/TransactionFilter.cs

Schalk Dormehl
@sjalq
Jan 22 10:08
@Shammah , how do I get the latest blocknumber? I seet Eth.GetBlockNumber, but that looks to be some sort of another object?
OK, nvm, I figured it out, doh
Roy
@Shammah
Jan 22 10:09
It's another RPC request. Try var latestBlock = await Web3.Eth.BlockService.GetBlockNumber.SendRequestAsync();
Ah ;)
Juan Blanco
@juanfranblanco
Jan 22 10:22
 public DateTime UnixTimeStampToDateTime(int unixTimeStamp)
        {
            var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
            dateTime = dateTime.AddSeconds(unixTimeStamp).ToLocalTime();
            return dateTime;
        }
if it helps
Roy
@Shammah
Jan 22 10:23
Boggles my mind there's no standard Unix conversion methods in .NET :/
Dave Whiffin
@Dave-Whiffin
Jan 22 10:26
In newer versions of .Net there are methods to convert from and to - check out DateTimeOffset (FromUnixTimeSeconds etc)
Roy
@Shammah
Jan 22 10:27
Ooooh you're right
.NET Framework: 4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6
so new DateTimeOffset(block.Timespan).Date should suffice
Juan Blanco
@juanfranblanco
Jan 22 11:56
cool, should refactor my code then :D
DateTimeOffset.FromUnixTimeSeconds(unixTimeStamp).DateTime;
Roy
@Shammah
Jan 22 12:14
errr, that's what I ment :P
Dwagga
@Dwagga
Jan 22 13:56
Hi guys, is there any way to convert a string, int, decimal or hex value to HexBigInteger?
I would like to run this: var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(HexBigInteger value, true);
Roy
@Shammah
Jan 22 14:02
Well, yes, except for the decimal, and it's different for each types.
if you have an int, you can simply do new HexBigInteger(new BigInteger(myInt))
Juan Blanco
@juanfranblanco
Jan 22 14:11
although that is mainly used to do unit conversions
Schalk Dormehl
@sjalq
Jan 22 15:19
Hey again guys,
I am writing some tests to check if an interface has been correctly implemented on a contract.
Before I dive to deep into thing, can I instantiate a contract from an Interface's JSON file and an address of an implementing contract?
Schalk Dormehl
@sjalq
Jan 22 15:37
OK, looks like it is possible
fernandoarauz
@fernandoarauz
Jan 22 23:24

Hi everyone!

I find this place looking for an answer about Nethereum:

I got a function that receive a byte32 parameter to use it as a key, and I tried to send this byte32 as parameter with a simple string, but I got no lucky, so

var key = "0x667f1fa200520202";
var redeemFunction = contract.GetFunction("redeem");
var response = redeemFunction.SendTransactionAsync(contract.Eth.TransactionManager.Account.Address, new HexBigInteger(30000), new HexBigInteger(0), key).Result;
If someone can help me to achive this, I going to be so thankful