These are chat archives for Nethereum/Nethereum

25th
Jun 2018
tmyngu11
@tmyngu11
Jun 25 2018 02:05 UTC
hey @juanfranblanco
I'm trying to call a solidity function getStuff(owner) which returns an array.
is there a way to decode an array of ints?
In the flappy example they only decode int results and loop through the top scores array.
tmyngu11
@tmyngu11
Jun 25 2018 02:22 UTC
for example if i had 0x00...0002000...00001 as a result. I want to decode that into an array instead
tmyngu11
@tmyngu11
Jun 25 2018 03:00 UTC
I tried return function.DecodeSimpleTypeOutput<List<int>>(result); but it says array index out of bounds
Kirankumar
@kiranbasvaraj
Jun 25 2018 06:01 UTC

Hi all,
i have updated my ABI and Contract address, suddenly i started getting exception
"The field to must have byte length of 20 at Nethereum.JsonRpc.Client.RpcClient.HandleRpcError",

There is one update in smart contract ie.. addition of one function and this is working fine in remix local environment but not in client side.

Thanks in advance!

Juan Blanco
@juanfranblanco
Jun 25 2018 06:44 UTC
@ela4men_twitter what was / is your problem?
i see "base fee exceeds gas limit"
can you post a sample?
Juan Blanco
@juanfranblanco
Jun 25 2018 06:49 UTC
@kiranbasvaraj your contract address is not correct
check it
Zeshan Virk
@zeshanvirk
Jun 25 2018 06:53 UTC
i
i'm sending tokens using nEthereum uisng
var gas = await transferFunction.EstimateGasAsync(tr.senderAddress, null, null, tr.toAddress, new HexBigInteger(amount).Value);
receipt = await transferFunction.SendTransactionAndWaitForReceiptAsync(tr.senderAddress, gas, null, null, tr.toAddress, new HexBigInteger(amount).Value);
but when i send 5, it sends 5
i send 60, it sends 96
why?
Michael van der Veeken
@mvdv
Jun 25 2018 06:55 UTC
96 is 60 in hex
Zeshan Virk
@zeshanvirk
Jun 25 2018 06:56 UTC
and 5 is 5 in hex?
Michael van der Veeken
@mvdv
Jun 25 2018 06:56 UTC
yes
Zeshan Virk
@zeshanvirk
Jun 25 2018 06:56 UTC
the value should be hex or value?
in sendToken method?
Zeshan Virk
@zeshanvirk
Jun 25 2018 07:16 UTC
the balance should be 60+5 = 65, but its showing 96+5 = 101, Why?
Zeshan Virk
@zeshanvirk
Jun 25 2018 07:28 UTC
i think the problem is in this method :
receipt = await transferFunction.SendTransactionAndWaitForReceiptAsync(tr.senderAddress, gas, null, null, tr.toAddress, new HexBigInteger(amount).Value);
can anyone correct me if i'm doing anything wrong?
Zeshan Virk
@zeshanvirk
Jun 25 2018 07:33 UTC
or may be here : var amount = new HexBigInteger(tr.amountToSend).Value * 1000000000000000000;
my value goes in hex value, how can i send the actual value?
if i send 100 it sends 256, if 60 it sends 96, if 5 it sends 5
Zeshan Virk
@zeshanvirk
Jun 25 2018 07:54 UTC

i changed my method to this :

receipt = await transferFunction.SendTransactionAndWaitForReceiptAsync(tr.senderAddress, gas, null, null, tr.toAddress, 11);

it gave me tx but the value is 0,

here is tx: https://ropsten.etherscan.io/tx/0xe626fcf2a327ecf58393cd6f902846f2104eeb27ac0f73616a750721c4de8674

if i send 5 instead of 11, then it the value becomes 5, what i'm doing wrong?

can anybody provide me sample working code or correct me on my code?
Psilon
@Pzixel
Jun 25 2018 08:51 UTC
I find value to work weird in nethereum. I tried once to make it work but I wasn't really successful with this task
need @juanfranblanco consultation
Juan Blanco
@juanfranblanco
Jun 25 2018 09:24 UTC
The value is the inner type of the hexBigInteger
if you are going to do operations you will need to use the values
and create a new hexBiginteger
hexBigIntegers and HexStrings are the types needed for encoding and decoding the data as the ethereum standard
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:26 UTC
i tried using this:
var amount = new HexBigInteger(11).Value * 1000000000000000000;
but it again converted it into hex
Juan Blanco
@juanfranblanco
Jun 25 2018 09:26 UTC
well would not be better to do something like
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:27 UTC
then whats the better way?
Juan Blanco
@juanfranblanco
Jun 25 2018 09:27 UTC
11 * new BigInteger(100000000000000000000000000);
and then new HexBigInteger(result);
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:29 UTC

var result = 11 * new BigInteger(1000000000000000000);
var amount = new HexBigInteger(result);
then what will i pass to SendTransactionAndWaitForReceiptAsync method?

amount.value? or just amout?

Juan Blanco
@juanfranblanco
Jun 25 2018 09:29 UTC
i have not created any specific operators (add, substract etc) for HexBigInteger
the amount
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:30 UTC
let me test
Juan Blanco
@juanfranblanco
Jun 25 2018 09:30 UTC
i have type operator
so it will be cast
mainly bigIntegers can be casted to HexBigInteger
hence converted automatically
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:36 UTC
by doing this i got this exception :
value for type 'Nethereum.ABI.Encoders.IntTypeEncoder': Nethereum.Hex.HexTypes.HexBigInteger (Nethereum.Hex.HexTypes.HexBigInteger)
i think it is due to amount.
i think it should be amount.value
Juan Blanco
@juanfranblanco
Jun 25 2018 09:37 UTC
??
i see what is wrong
mainly you are using the Ethereum balance
that comes as a HexBigInteger
and you are using it to send a value to a contract
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:38 UTC
yes
Juan Blanco
@juanfranblanco
Jun 25 2018 09:38 UTC
yes values to contracts are BigIntegers
the rpc top layer is in Hex
so mainly works like this
account GetBalance() == HexBigInteger();
value = HexBigInteger.Value;
calculation = value * xx;
SendAmountToContract(calculation (in BigInteger))
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:41 UTC
bigInteger or hexBigInteger?
as you said above it should be hexBigInteger
and the method is also recieve hexBigInteger!!
Juan Blanco
@juanfranblanco
Jun 25 2018 09:53 UTC
paste a snippet of your code
it will be simpler
Zeshan Virk
@zeshanvirk
Jun 25 2018 09:55 UTC
var result = 10 * new BigInteger(1000000000000000000);
var amount = new HexBigInteger(result);
            var gas = await transferFunction.EstimateGasAsync(tr.senderAddress, null, null, tr.toAddress, amount);
         var   receipt = await transferFunction.SendTransactionAndWaitForReceiptAsync(tr.senderAddress, gas, null, null, tr.toAddress, amount);
Juan Blanco
@juanfranblanco
Jun 25 2018 10:14 UTC
right
is your amount
Ether?
or Token Amount
because this seems to me you using the Token Amount
the token amount is a BigInteger
well depending on your contract
this is a good example using CQS
mainly Messages per Contract Transaction, Query
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:17 UTC
i'm sending Token Amount
Juan Blanco
@juanfranblanco
Jun 25 2018 10:17 UTC
which it is a bit simpler
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:17 UTC
18 decimal
Juan Blanco
@juanfranblanco
Jun 25 2018 10:17 UTC
sure that is not in hex
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:19 UTC

var result = 10 * new BigInteger(1000000000000000000);
var amount = new HexBigInteger(result);
var gas = await transferFunction.EstimateGasAsync(tr.senderAddress, null, null, tr.toAddress, amount.value);
var receipt = await transferFunction.SendTransactionAndWaitForReceiptAsync(tr.senderAddress, gas, null, null, tr.toAddress, amount.value);

this works for me

by passing amount.value not amount
Juan Blanco
@juanfranblanco
Jun 25 2018 10:19 UTC
sure
you don't need a hexBigInteger for the amount
those are smart contract values
types
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:21 UTC
but i'm sending a smart contract.
Juan Blanco
@juanfranblanco
Jun 25 2018 10:21 UTC
check the sample I send you before
i think those will be helpful
probably starting with the last one
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:23 UTC
GasPrice = Web3.Web3.Convert.ToWei(25, UnitConversion.EthUnit.Gwei)
in the first example, gasprice is hardcoded!! why?
Juan Blanco
@juanfranblanco
Jun 25 2018 10:29 UTC
becuase it is an example
you can put whatever you want
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:33 UTC
what should be the mininmum amount of gas and max of amount of gas?
Juan Blanco
@juanfranblanco
Jun 25 2018 10:33 UTC
that is why you do the estimation
and the gas price depends on the chain
in quorum is zero for example
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:34 UTC
estimation is done while sending tokens, we need to pass gas while sending ether too, but i didn't found any method for estimation of sending ether. whats in that case?
Juan Blanco
@juanfranblanco
Jun 25 2018 10:34 UTC
ether is the default
transaction cost
and estimation is done for any transaction with smart contracts
Zeshan Virk
@zeshanvirk
Jun 25 2018 10:37 UTC
isn't it necessary to pass gas to SendTransaction method while sending ether? what will be the default value?
El Amen
@ela4men_twitter
Jun 25 2018 10:42 UTC

@juanfranblanco Ok thanks.
Here is my code.

var result = await method.SendTransactionAsync(service.AccountAddress, value.ToString());

In Nethereum 2.0.0-rc1 this code runs problemlessly.
But when tried with 2.5.* I get
base fee exceeds gas limit

When I try to specify gas with the code below

var result = await method.SendTransactionAsync(service.AccountAddress, new Nethereum.Hex.HexTypes.HexBigInteger(Convert.ToInt64(80000)), value);

I get
Too many arguments: 2 > 1
I thought it is because maybe the variable value is a string while the SendTransactionAsync overload is expecting HexBigInt but my contract is expecting a string so I couldn't provide int value so I tried with a contract expecting integer and I get a totally different error.
I then tried all these methods below with no success until I revert Nethereum 2.5.* to 2.0.0-rc1 and portable.BouncyCastle 1.8.2 to 1.8.1
Here are the alternative methods I tried
var gas = Web3.Convert.FromWei(await method.EstimateGasAsync(service.AccountAddress, null, null));
var result = await method.SendTransactionAndWaitForReceiptAsync(service.AccountAddress, gas, new Nethereum.Hex.HexTypes.HexBigInteger(value));
var result = await method.SendTransactionAsync(service.AccountAddress, new Nethereum.Hex.HexTypes.HexBigInteger(Convert.ToInt64(80000)), new Nethereum.Hex.HexTypes.HexUTF8String("ok"),"ok");
var result = await method.SendTransactionAsync(service.AccountAddress,gas, new Nethereum.Hex.HexTypes.HexUTF8String("ok"),"ok");
var result = await method.SendTransactionAsync(service.AccountAddress, new Nethereum.Hex.HexTypes.HexUTF8String("ok"));

Also Nethereum 2.0.0 does not work with portable.BouncyCastle 1.8.2 and you only find out after excecution with the error message below

"Could not load file or assembly 'crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942'."

It will be nice if it can be pointed out early in design mode.

That is why I would like to know if there is any complete tutorial or documentation for the latest Nethereum
Thank you
Michael van der Veeken
@mvdv
Jun 25 2018 11:10 UTC
@zeshanvirk : 21000 gas
Juan Blanco
@juanfranblanco
Jun 25 2018 11:13 UTC
if you don't pass the anything the default value will be used
@ela4men_twitter yes portable does not work with bouncycastle 1.8.2 it was introduced in 2.5.*
regarding your contract, use named parameters
this is why of the new contractmessages it simplifies all the parameters
El Amen
@ela4men_twitter
Jun 25 2018 14:15 UTC
@juanfranblanco Can you please send me a line of how to declare named parameters on a contract and how to call it in Nethereum so I give it a trial and get back. Thank you