These are chat archives for Nethereum/Nethereum

14th
Sep 2018
Juan Blanco
@juanfranblanco
Sep 14 2018 06:24
@spied001 well that's it, there is not a method as such
Manuel Rauber
@ManuelRauber
Sep 14 2018 11:46

Hi again,

I'm not sure, how I can estimate the gas for a transaction using the generated code from Nethereum.

For example I've something like:

var transaction = new RegisterFunction()
            {
                BlockNumber = blockInformation.BlockHeight,
                BlockHash = blockInformation.BlockHash
            };

            var gasPriceEstimation = await _chainService.Web3.Eth.Transactions.EstimateGas.SendRequestAsync(new TransactionInput(transaction, 
                _serviceSettings.ContractAddress));

For sure, I can not use new TransactionInput(transaction), since it wants to have a string, but I'm not sure, how to get the string from my transaction?

Manuel Rauber
@ManuelRauber
Sep 14 2018 11:52
Background is, I want to setup a threshold of gas for invoking the function, so if the estimated gas is higher than my threshold, I want to print a message to the user
@ManuelRauber ^^
Manuel Rauber
@ManuelRauber
Sep 14 2018 12:00
Oh dang. I was looking at this one yesterday and missed this. Thanks for opening my eyes :)
Juan Blanco
@juanfranblanco
Sep 14 2018 12:01
Nethereum automatically estimates the gas for you, but yeah i see your point
Manuel Rauber
@ManuelRauber
Sep 14 2018 12:02
Yes, it's for an automatic service writing in an interval to the blockchain, so at some point we want to cut it off if it exceeds some gas
Juan Blanco
@juanfranblanco
Sep 14 2018 12:03
you may want to check the price too
if writing to the public chain
Manuel Rauber
@ManuelRauber
Sep 14 2018 12:04
Yes, I will and yes, it will go to the mainnet
Just doing some baby steps :)
Juan Blanco
@juanfranblanco
Sep 14 2018 12:05
If the function does not depend heavily on the state or data passed (random calculations) the gas used will be the same
(or nearly the same)
Manuel Rauber
@ManuelRauber
Sep 14 2018 12:06
The data is almost fixed size
Juan Blanco
@juanfranblanco
Sep 14 2018 12:06
but the price will vary depending
on the usage of the network
if it is just an oracle writing the same data, it won't change much then
Manuel Rauber
@ManuelRauber
Sep 14 2018 12:11
Better to check all available stuff to be sure :)
Juan Blanco
@juanfranblanco
Sep 14 2018 12:11
Oh yes !!
There are comments, thoughts about to increase the gas cost for storage, so that will affect your use case
(As an example)
Manuel Rauber
@ManuelRauber
Sep 14 2018 12:39
yes, I've read some of that comments. Let's see what's happening :)