These are chat archives for Nethereum/Nethereum

31st
Jan 2018
raderack3948
@raderack3948
Jan 31 2018 08:58
Is there a possibility to list all transactions under an account and get the block number of when a specific transaction was first seen? This way I could self calculate the age of the transaction and confirmations.
Juan Blanco
@juanfranblanco
Jan 31 2018 09:05
@Art1987 are you pointing to a testnet or mainnet
that is how long it takes to mine
Art1987
@Art1987
Jan 31 2018 09:06
@juanfranblanco I am pointing to rinkby
Juan Blanco
@juanfranblanco
Jan 31 2018 09:07
oh rinkeby should not take so long
as it is PoA
Art1987
@Art1987
Jan 31 2018 09:07
but it takes at least 25 secs
Juan Blanco
@juanfranblanco
Jan 31 2018 09:08
which part
estimate gas or
the deployment
Art1987
@Art1987
Jan 31 2018 09:08
deploying smart contract or making transactions
there is a case when estimated gas throw following error
gas required exceeds allowance or always failing transaction
Juan Blanco
@juanfranblanco
Jan 31 2018 09:09
well you are using too much gas
in that scenario
are you connecting to infura?
rinkeby?
Art1987
@Art1987
Jan 31 2018 09:09
yes
here is the code
Juan Blanco
@juanfranblanco
Jan 31 2018 09:09
it might be due to their transaction queue
Art1987
@Art1987
Jan 31 2018 09:09
                var contract = _web3.Eth.GetContract(abi, contractAddress);
                var caller = contract.GetFunction(methodName);
                var gasPrice = await caller.EstimateGasAsync(arguments);
Juan Blanco
@juanfranblanco
Jan 31 2018 09:09
being to large
Art1987
@Art1987
Jan 31 2018 09:10
EstimateGasAsync method throws mentioned message
Juan Blanco
@juanfranblanco
Jan 31 2018 09:10
and re estimage gas it should not be an issue with a simple function
Art1987
@Art1987
Jan 31 2018 09:11
I am trying to send transaction, signing multisig contract and transferring ether
Art1987
@Art1987
Jan 31 2018 09:12
I have looked at it, but I don't know how apply it using Nethereum
Juan Blanco
@juanfranblanco
Jan 31 2018 09:13
it might be due to your solidity code
test it locally
Art1987
@Art1987
Jan 31 2018 09:14
it works when I have passed hard coded gas
Juan Blanco
@juanfranblanco
Jan 31 2018 09:14
ah interesting
then don't estimate it :)
Art1987
@Art1987
Jan 31 2018 09:14
var result = await caller.SendTransactionAndWaitForReceiptAsync(_account.Address, gasPrice, null, null, arguments);
Juan Blanco
@juanfranblanco
Jan 31 2018 09:14
it might be due to the transfer
Art1987
@Art1987
Jan 31 2018 09:14
in that case how I can calculate optimal gas?
Juan Blanco
@juanfranblanco
Jan 31 2018 09:15
well if you have an already valid transaction
Art1987
@Art1987
Jan 31 2018 09:15
transaction gas underpriced
Juan Blanco
@juanfranblanco
Jan 31 2018 09:15
use the gas used
for it
Art1987
@Art1987
Jan 31 2018 09:15
how can I avoid getting - transaction gas under priced exception?
Juan Blanco
@juanfranblanco
Jan 31 2018 09:17
are you replacing a transaction?
or using a low gas price?
(mainly increase the gas price)
Art1987
@Art1987
Jan 31 2018 09:18
the issue is that when I set for example 1 300 000 for gas, after while it stop working and I get transaction gas underpriced exception and I need to again increase gas price
I don't want to repeatedly increase it every day
Juan Blanco
@juanfranblanco
Jan 31 2018 09:19
@jonathansmirnoff no, but raise an issue to add it to the backlog
Art1987
@Art1987
Jan 31 2018 09:19
I want to calculate it, I thought EstimateGasAsync method could help me
Juan Blanco
@juanfranblanco
Jan 31 2018 09:20
so you want to calculate the gas price or the total gas
Art1987
@Art1987
Jan 31 2018 09:21
gas and gasPrice for SendTransactionAndWaitForReceiptAsync method
Juan Blanco
@juanfranblanco
Jan 31 2018 09:21
gas price might increase
depending on the current usage of the network
and the gas usage depends of what you are doing
if you are not storing any value and all the operations are the same it should not change
as i remember the nonce value of the multisignature increases over time
Art1987
@Art1987
Jan 31 2018 09:23
yes it increases incrementally
Juan Blanco
@juanfranblanco
Jan 31 2018 09:23
is there any other storage or different calculation you use?
those will drive the gas usage
Art1987
@Art1987
Jan 31 2018 09:23
I am calculating hash of transaction
Juan Blanco
@juanfranblanco
Jan 31 2018 09:25
Yes true, I don't know how much gas will change overtime due to different parameters
something to test in remix
Art1987
@Art1987
Jan 31 2018 09:26
so there is no any formula to calculate optimal gas, right?
Juan Blanco
@juanfranblanco
Jan 31 2018 09:26
well yes going through all opcodes
estimategas should do that for you but you are having issues
maybe something to raise with the geth guys
Art1987
@Art1987
Jan 31 2018 09:28
I see, I will try to understand what I pass wrong or ask question to different forums, Thanks
Juan Blanco
@juanfranblanco
Jan 31 2018 09:36
btw
your gas price
parameter
is not the gas price bu the gas usage
@Art1987
var gasPrice = await caller.EstimateGasAsync(arguments);
^^ that is the gas
not the price
also because you are transferring some amounts using a call
you should consider providing some gas to the gasEstimate call
Art1987
@Art1987
Jan 31 2018 09:52
@juanfranblanco now I am getting Array value expected for type message when calling EstimateGasAsync method
Juan Blanco
@juanfranblanco
Jan 31 2018 09:56
ok i guess you are using the wrong parameters
you could use CQS instead
if you have complex parameters
Art1987
@Art1987
Jan 31 2018 09:59
there is a parameter bytes in my smart contract type is bytes
how can I pass it?
it works fine when I call SendTransactionAndWaitForReceiptAsync, but it does not work when I call EstimateGasAsync
Juan Blanco
@juanfranblanco
Jan 31 2018 10:01
well it should work for both the same
Art1987
@Art1987
Jan 31 2018 10:01
but it doesn't
Juan Blanco
@juanfranblanco
Jan 31 2018 10:02
well are you able to execute the code succesfully when sending a transaction?
if so
you are using the wrong overload
Art1987
@Art1987
Jan 31 2018 10:02
yes, when I pass hard coded gas price to SendTransactionAndWaitForReceiptAsync it works fine
Juan Blanco
@juanfranblanco
Jan 31 2018 10:02
have you corrected the gas price
and the gas
Art1987
@Art1987
Jan 31 2018 10:03
yes
Juan Blanco
@juanfranblanco
Jan 31 2018 10:03
ok cool
Art1987
@Art1987
Jan 31 2018 10:03
I wrote wrong it should be gas not gas price
I meant gas
Juan Blanco
@juanfranblanco
Jan 31 2018 10:03
right but if you use the wrong figure
well everything will go foobar :)
Art1987
@Art1987
Jan 31 2018 10:04
I have called EstimateGasAsync passing method's parameter
Juan Blanco
@juanfranblanco
Jan 31 2018 10:04
i am guessing your issue is that a wrong overload is getting used
if your transaction is ok
also pass some gas
as a parameter as this might be also the issue
Art1987
@Art1987
Jan 31 2018 10:05
I am using following overload
public Task<HexBigInteger> EstimateGasAsync(params object[] functionInput);
Juan Blanco
@juanfranblanco
Jan 31 2018 10:05
right
ok ignore the gas for now
so how are you pasing the parameters
if you are able to send the transaction it should be the same
but i still think cqs will help you in a complex scenario
use the code generator if that helps
Art1987
@Art1987
Jan 31 2018 10:09
here is the hall code
        public virtual async Task<TransactionReceipt> SendTransactionAndWaitForReceiptAsync(string abi, string contractAddress, string methodName,  params object[] arguments)
        {
            try
            {
                var contract = _web3.Eth.GetContract(abi, contractAddress);
                var caller = contract.GetFunction(methodName);

                var gas = await caller.EstimateGasAsync(arguments);
                //Maybe we need to pass CancellationTokenSource
                var result = await caller.SendTransactionAndWaitForReceiptAsync(_account.Address, gas null, null, arguments);

                return result;
            }
            catch (Exception exp)
            {
                //TODO: log here                
                Debug.Write(exp);
                throw;
            }
Juan Blanco
@juanfranblanco
Jan 31 2018 10:29
@Art1987 i see both use the same function to encode the data
one builds a call input another a transactioninput
but overall is the same
Art1987
@Art1987
Jan 31 2018 10:30
so what did I miss?
Juan Blanco
@juanfranblanco
Jan 31 2018 10:30
nothing
so if you are having problems with array types
Art1987
@Art1987
Jan 31 2018 10:30
now I am constantly getting this message gas required exceeds allowance or always failing transaction
Juan Blanco
@juanfranblanco
Jan 31 2018 10:30
you should have the same issue with your send transaction
as I don't know what parameters you are using i don't understand
(real parameters)
  1. can we verify that a) your transaction sends correctly
when you supply the gas
2.) that there is no errors encoding etc
you had one before
3.) only issue is with EstimateGas
if so try using further parameters
like address from, gas etc when estimating the gas
Art1987
@Art1987
Jan 31 2018 10:45
ok, thanks
Juan Blanco
@juanfranblanco
Jan 31 2018 11:03
@Art1987 let me know how it goes
Art1987
@Art1987
Jan 31 2018 11:04
still getting gas required exceeds allowance or always failing transaction error message :(
how can I translate this to c#?
let call_data_phase = this.contract.addPhase.getData(
        companies[i].phases[j].start_time,
        companies[i].phases[j].prices_in_wei,
        companies[i].phases[j].prices_in_wei_ends,
        companies[i].phases[j].tokens_count,
        companies[i].phases[j].min_tokens_to_sell,
        {from: sender, gas: 10000000000}

    );
web3.eth.estimateGas({data: call_data_phase, from: sender})
finally I found the solution
Art1987
@Art1987
Jan 31 2018 11:09
                var contract = _web3.Eth.GetContract(abi, contractAddress);
                var caller = contract.GetFunction(methodName);
                var functionInput = caller.GetData(arguments);
                var bytearay = functionInput.HexToByteArray();
                var gashHex = new HexBigInteger(new BigInteger(gas));
                var callInput = new CallInput(functionInput, toAddree);
                //EstimateGasAsync(string from, HexBigInteger gas, HexBigInteger value, params object[] functionInput);
                var gasPrice = await _web3.Eth.TransactionManager.EstimateGasAsync(callInput);
                //var gasPrice = await caller.EstimateGasAsync(_account.Address, gashHex, new HexBigInteger(0), arguments);
                //Maybe we need to pass CancellationTokenSource
                var result = await caller.SendTransactionAndWaitForReceiptAsync(_account.Address, gasPrice, null, null, arguments);
Juan Blanco
@juanfranblanco
Jan 31 2018 11:21
but did you do what i told you
add gas and fromAddress to EstimateGas?
//EstimateGasAsync(string from, HexBigInteger gas, HexBigInteger value, params object[] functionInput);
EstimateGasAsync(_account.Address, new HexBigInteger(1000000000), null, arguments);
just to validate
@Art1987
i guess you did as you have gasHex?
Juan Blanco
@juanfranblanco
Jan 31 2018 11:30
@Art1987 also is your transaction succesful
when submitted
do you have the etherscan link of the transaction
Art1987
@Art1987
Jan 31 2018 11:41
sure
second does not work
Juan Blanco
@juanfranblanco
Jan 31 2018 11:44
mainly if you look at this
i am asking to pass some gas just in case the block limit is lower of what you need (highly unlikely)
so it all seem to indicate an error executing
Art1987
@Art1987
Jan 31 2018 11:45
I have tried to translate web3 javascript code to c#
Juan Blanco
@juanfranblanco
Jan 31 2018 11:46
that is not going to do anything
you are using the same rpc methods
and everything results in the same calls
BUT just check the estimate
code
Art1987
@Art1987
Jan 31 2018 11:48
is there something wrong with me code? or I missed something
Juan Blanco
@juanfranblanco
Jan 31 2018 11:48
well your solidity code might not execute
your paramters might not be correct?
hence if i can see the txn in etherscan
and validate if successful
then it can be taken from there
Art1987
@Art1987
Jan 31 2018 11:49
I am sure my parameters are correct because transaction is succeeded
Juan Blanco
@juanfranblanco
Jan 31 2018 11:50
pass me a link to it
Art1987
@Art1987
Jan 31 2018 11:58
give a sec
Juan Blanco
@juanfranblanco
Jan 31 2018 11:59
mainly after all these attempts (changing gas supplied when estimating) and if the transaction is a success
when submitting then there is an issue in geth estimating
l-vitall
@l-vitall
Jan 31 2018 12:19
Hi Juan,
I'm trying event filters from Nethereum.Web3.Tests and I see that it works only when events were generated during the test. If I'm trying to get pre-existed events then event filter returns no records. Is there a way to get existing events from existing contract? Thanks.
Juan Blanco
@juanfranblanco
Jan 31 2018 15:16
@Art1987 that data is not complex at all
0xa9059cbb000000000000000000000000317f0f72bed926ce138665f3952194e1167c24920000000000000000000000000000000000000000000000000000000000000000
what do you have an input of an address and a uint256
@l-vitall yes you can, but when you use get filter changes it starts tracking from when you created the filter
use GetAllChanges and pass a filterInput with a block range
Juan Blanco
@juanfranblanco
Jan 31 2018 15:36
@Art1987 if you look at the multisig transactions all of them throw an error REVERT opcode
hence you cannot estimate your gas (i pressume)
JEN
@chukwuemekanweke
Jan 31 2018 15:49
@juanfranblanco Thanks a lot. Saved me a whole lot of stress. I'm very grateful
@juanfranblanco I'm returning an address and a uint array from the solidity contract. I can't seem to deserialize the adddress array to List<string>. I just want to know if that's the right way to deserialize an address array
I know i can deserialize an address to string. Don't just know why this isn't working
Jonathan Sheely
@jsheely
Jan 31 2018 15:55
I am having the same issue as @Art1987 with the gas price estimating I believe
Juan Blanco
@juanfranblanco
Jan 31 2018 15:55
if you are returning multiple values you need a FunctionOutputDTO
Jonathan Sheely
@jsheely
Jan 31 2018 15:57
var contract = web3.Eth.GetContract(abi, contractAddress);
var registerUser = contract.GetFunction("registerUser");
var gas = await registerUser.EstimateGasAsync(address, "0");
Error returns as: gas required exceeds allowance or always failing transaction
@chukwuemekanweke
Jonathan Sheely
@jsheely
Jan 31 2018 15:58
Looking at the transaction history. It appears to be trying to deploy a contract instead of running a function of the contract
Juan Blanco
@juanfranblanco
Jan 31 2018 15:58
have you deployed the contract?
is it on the testnet?
Jonathan Sheely
@jsheely
Jan 31 2018 15:58
Yes
It's deployed
Juan Blanco
@juanfranblanco
Jan 31 2018 15:59
can you post the solidity
and the link to it
you maybe having an error in your solidity code so it breaks
Jonathan Sheely
@jsheely
Jan 31 2018 15:59
Though I am manually providing abi (which I assume I'm suppose to do)
Juan Blanco
@juanfranblanco
Jan 31 2018 15:59
so it cannot estimate
Jonathan Sheely
@jsheely
Jan 31 2018 15:59
Well here is the problem
It works using the Portable library. But no the Web3 library
Juan Blanco
@juanfranblanco
Jan 31 2018 16:00
insteresting
interesting**
Jonathan Sheely
@jsheely
Jan 31 2018 16:00
I can't use the Portable library mostly because I need the HDWallet and there are all sorts of reference issues between the two
Juan Blanco
@juanfranblanco
Jan 31 2018 16:01
portable is the same as web3
they are all linked files
yes you cannot use HDWallet with portable
as the HDWallet targets 1.3
due to dependencies
Jonathan Sheely
@jsheely
Jan 31 2018 16:02
Yep, Unfortunately I think I need that. To create the wallet addresses and Mnemonic
Juan Blanco
@juanfranblanco
Jan 31 2018 16:03
yeah
portable is mainly for backwards support
so you should not have any issue with either library
mainly portable is a copy of all the other libraries (that it can support)
so it looks like a redherring
Jonathan Sheely
@jsheely
Jan 31 2018 16:04
Here is what the current transactions look like, 1 sec
Juan Blanco
@juanfranblanco
Jan 31 2018 16:05
your contract deployments has failed
Jonathan Sheely
@jsheely
Jan 31 2018 16:05
Right, It shouldn't be a contract deployment
It should be running a function of the contract like the prior ones
The prior ones are running from the portable library in a test console app
The two failing transactions were using the Nethereum.Web3 library and calling the "same" methods
I say the same because. The portable library was able to estimate the gas. Gas estimation fails for me.. So I hard coded the gas. Which then tried to deploy a contract instead of running a contract function
Which as you say. Portable and Web3 share the same code. So it has my head spinning as to what is different....
Juan Blanco
@juanfranblanco
Jan 31 2018 16:10
well you won't be able to call the contract if it has deployed
so your estimate will fail
Jonathan Sheely
@jsheely
Jan 31 2018 16:11
I'm not sure I understand what that means?
Juan Blanco
@juanfranblanco
Jan 31 2018 16:11
can you use Eth.GetCode.SendRequestAsync
to validate the contract you are using has deployed succesfully
Jonathan Sheely
@jsheely
Jan 31 2018 16:11
Hmm
Juan Blanco
@juanfranblanco
Jan 31 2018 16:11
mainly if it returns 0x
it has not been deployed correctly
Jonathan Sheely
@jsheely
Jan 31 2018 16:12
Well if we were able to run the code in the portable and get a result. Wouldn't that mean it was deployed correctly?
I am testing your idea tough
Juan Blanco
@juanfranblanco
Jan 31 2018 16:14
sure what address are you using?
Jonathan Sheely
@jsheely
Jan 31 2018 16:14
Hmmm
So the contract address is
Juan Blanco
@juanfranblanco
Jan 31 2018 16:15
oh you are using mainnet
Jonathan Sheely
@jsheely
Jan 31 2018 16:15
OMFG
jsheely @jsheely bashes head against desk
Jonathan Sheely
@jsheely
Jan 31 2018 16:15
Stupid AppSetting freaking strings
I spelled ContractAddress, ContactAddress
Sooo sorry for wasting your time. THoguh it's interesting that a null contract address would deploy a new contract by default
Juan Blanco
@juanfranblanco
Jan 31 2018 16:18
:) AppSettings WebConfigs are the evil source of all errors
as they are always overlooked
Jonathan Sheely
@jsheely
Jan 31 2018 16:21
So with that GetCode. Are we able to use that instead of the ABI ?
Juan Blanco
@juanfranblanco
Jan 31 2018 16:23
no
you need the abi
Jonathan Sheely
@jsheely
Jan 31 2018 16:23
Okay. So in order to run a function you always need to have the ABI manually copied into the project as a schema
Juan Blanco
@juanfranblanco
Jan 31 2018 16:24
but you can create messages like this
Jonathan Sheely
@jsheely
Jan 31 2018 16:24
Well I say manually. But it's not something that's exposed from the blockchain itself
yes correct
the schema could be retrieved from swarm
Jonathan Sheely
@jsheely
Jan 31 2018 16:26
Not sure what this link is showing me and what swarm is
Juan Blanco
@juanfranblanco
Jan 31 2018 16:26
well that shows you another way to create a contract message with the abi included on it
and swarm is decentralised storage built on ethereum
p2p network
that stores sometimes the abi and contract information
Jonathan Sheely
@jsheely
Jan 31 2018 16:27
Ahh, I see. So an abstraction but basically as useful as storing it myself
Juan Blanco
@juanfranblanco
Jan 31 2018 16:27
well the idea is that you don't need to create services for contracts
and you can target specific signatures / methods
but yeah
overall .net is typed
and you need to do type conversions to ethereum
Ryan
@cybervoid
Jan 31 2018 16:54
Does Nethereum allow us the ability to Load LDB block files and read data directly?
JEN
@chukwuemekanweke
Jan 31 2018 17:45
@juanfranblanco Yeah. It works. thanks a lot
Juan Blanco
@juanfranblanco
Jan 31 2018 17:47
np :)
@cybervoid not at the moment
the plan is to sync and store to a db
leveldb will be on of the repositories and make it compatible with geth
it will be obviously a good idea
Jonathan Smirnoff
@jonathansmirnoff
Jan 31 2018 20:34
@juanfranblanco I did it! thanks!
Juan Blanco
@juanfranblanco
Jan 31 2018 21:24
seen it :)