These are chat archives for Nethereum/Nethereum

19th
Feb 2018
Rubén Murillo
@rumurillo
Feb 19 2018 00:35

I have been trying to interact with my ERC20 Token using Nethereum but I haven't been able to. I'm calling, for example, my token's balanceOf function and, after a couple minutes, it throws the following exception:

EdjCase.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s) ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.

Any ideas?

Thanks

TarrahArshad
@TarrahArshad
Feb 19 2018 05:20
hi all
Juan Blanco
@juanfranblanco
Feb 19 2018 11:13
@rumurillo how are you connecting?
Rubén Murillo
@rumurillo
Feb 19 2018 11:51
Hey @juanfranblanco, I'm using ethereumjs-testrpc.
Rubén Murillo
@rumurillo
Feb 19 2018 11:59
Here's how I try to get the balance, @juanfranblanco:
public async static Task<int> GetBalance(string address)
{
try
{
var balance = await token.GetBalanceOfAsync<int>(address);
return balance;
}
catch (Exception ex)
{
            throw;
        }
    }
And in token:
public async Task<T> GetBalanceOfAsync<T>(string address)
{
var function = GetBalanceOfFunction();
return await function.CallAsync<T>(address);
}
Juan Blanco
@juanfranblanco
Feb 19 2018 12:01
ok so you have deployed the contract? and use the private key / account to connect
Rubén Murillo
@rumurillo
Feb 19 2018 12:05
That's correct
Juan Blanco
@juanfranblanco
Feb 19 2018 12:06
strange
does it work with clique?
Rubén Murillo
@rumurillo
Feb 19 2018 12:06
I'm using testrpc --hostname="IP_ADDRESS" --account<privateKey,amount>
ok cool
Rubén Murillo
@rumurillo
Feb 19 2018 12:07
If I use "truffle console" I get to connect to ethereumjs-testrpc
Let me check
Juan Blanco
@juanfranblanco
Feb 19 2018 12:08
are you trialling in the console?
Rubén Murillo
@rumurillo
Feb 19 2018 12:08
In the console, I manage to get the accounts, ask for the balance. So that works fine
Juan Blanco
@juanfranblanco
Feb 19 2018 12:08
ah ok
just validating the usual Wait, Result issues
Rubén Murillo
@rumurillo
Feb 19 2018 12:08
I have a Xsmarin.Android app as the client
Was working fine couple of months ago 😅
Juan Blanco
@juanfranblanco
Feb 19 2018 12:09
ok sure
ha ha
yeah the joys
so your issue is the xamarin app
Rubén Murillo
@rumurillo
Feb 19 2018 12:10
I'm able to deploy the contract using truffle, then everything I try to get the balance using nethereum I get that exception
Might be haha
Let me share with you the way in which I create the web3 obj
Juan Blanco
@juanfranblanco
Feb 19 2018 12:11
are you deploying to hardware
i normally work better on the phone than on the pc
Rubén Murillo
@rumurillo
Feb 19 2018 12:11
I'm deploying to a physical device
Juan Blanco
@juanfranblanco
Feb 19 2018 12:12
ok
Rubén Murillo
@rumurillo
Feb 19 2018 12:12
Both have the issue (Samsung j5 and my brand new OnePlus5T)
Var web3 = new Nethereum.Web3.Web3(ip);
        CONTRACT_ADDRESS = "0X...";

        token = new StandardToken(web3, CONTRACT_ADDRESS);
Juan Blanco
@juanfranblanco
Feb 19 2018 12:16
have you included the port?
8545?
Rubén Murillo
@rumurillo
Feb 19 2018 12:16
Yes!
Juan Blanco
@juanfranblanco
Feb 19 2018 12:18
Does this work?
this does the same
but connects to infura
(mainly testing your xamarin app)
Rubén Murillo
@rumurillo
Feb 19 2018 12:19
What's infura? 😅
Juan Blanco
@juanfranblanco
Feb 19 2018 12:19
ah infura is a public node
Rubén Murillo
@rumurillo
Feb 19 2018 12:19
Cool
Juan Blanco
@juanfranblanco
Feb 19 2018 12:19
for mainnet
so that is querying the balance of an erc20 contract
Rubén Murillo
@rumurillo
Feb 19 2018 12:19
Ok. Let me try that and I'll get back to you. Thanks Juan!
Juan Blanco
@juanfranblanco
Feb 19 2018 12:20
cannot remember which one, i pick a random one from etherscan
Rubén Murillo
@rumurillo
Feb 19 2018 12:20
Few months ago you also helped me out and prevented me from banging my head towards a wall
Juan Blanco
@juanfranblanco
Feb 19 2018 12:20
ha ha we don't want that to happen
Rubén Murillo
@rumurillo
Feb 19 2018 12:20
Alright. I'll try and let you know
Juan Blanco
@juanfranblanco
Feb 19 2018 12:21
walls are expensive!
Rubén Murillo
@rumurillo
Feb 19 2018 12:28
Loool
Didn't see that coming 😂
Juan Blanco
@juanfranblanco
Feb 19 2018 12:34
:)
Rubén Murillo
@rumurillo
Feb 19 2018 14:15
Hey, @juanfranblanco . There's no "GetContractQueryHandler" in web3.Eth...
Juan Blanco
@juanfranblanco
Feb 19 2018 14:17
what version are you using_
you need 2.2.3
Rubén Murillo
@rumurillo
Feb 19 2018 14:18
Upgrading.. be right back
Rubén Murillo
@rumurillo
Feb 19 2018 14:26
It works with that code
Managed to get the balance back
Juan Blanco
@juanfranblanco
Feb 19 2018 14:26
ah cool
Rubén Murillo
@rumurillo
Feb 19 2018 14:27
I mean, it worked with infura
Juan Blanco
@juanfranblanco
Feb 19 2018 14:27
ahhh
Rubén Murillo
@rumurillo
Feb 19 2018 14:27
I'll check with my local one
haha
I cant' get too excited yet
Juan Blanco
@juanfranblanco
Feb 19 2018 14:27
yeah at least you have troubleshooted most of it
Rubén Murillo
@rumurillo
Feb 19 2018 14:34
So, this is how I'm trying:
public static async Task BalanceAsync()
{
var senderAddress = "0x1b5d7b5c248b662a076025f5d14e7fa6090f7f96";
var contractAddress = "0xdb32c926942c38f42fdf0d8138de2969eb244f56";
        //no private key we are not signing anything
        var web3 = new Nethereum.Web3.Web3("http://172.16.28.125:8545");

        var balanceOfFunctionMessage = new BalanceOfFunction()
        {
            Owner = senderAddress,
        };

        var balanceHandler = web3.Eth.GetContractQueryHandler<BalanceOfFunction>();
        var balance = await balanceHandler.QueryAsync<BigInteger>(balanceOfFunctionMessage, contractAddress);
        Console.WriteLine("Balance of token: " + Nethereum.Web3.Web3.Convert.FromWei(balance));

    }
I have a breakpoint right after balance and it never gets hit
It worked with infura
Juan Blanco
@juanfranblanco
Feb 19 2018 14:37
did you check you have the port open
(silly question i know)
Rubén Murillo
@rumurillo
Feb 19 2018 14:38
Checking that
Juan Blanco
@juanfranblanco
Feb 19 2018 14:38
you have already verified Internet access
Rubén Murillo
@rumurillo
Feb 19 2018 14:38

Althoug, I'm running

testrpc --hostname="172.16.28.125" --account="0xd60b8c906314aeac7ce02ffc9f89f3502fb69ca7bc908ca273c98cc13b44dcf7,972197500000000000" --account="0x07afc5901730cd37d7503fd87239313bd28e3535df1bc872a50165c08a31c3ce,972197500000000000"

That's running on the 8545 port
Yeah, I'm through Ethernet and it's stable
Juan Blanco
@juanfranblanco
Feb 19 2018 14:39
and you tested on console too
so i guess is the access to your pc / mac
Rubén Murillo
@rumurillo
Feb 19 2018 14:40
image.png
I'm on a DELL Computer
Juan Blanco
@juanfranblanco
Feb 19 2018 14:40
yes you have access
i mean that is running :)
so it has to be access from your device to your pc
Rubén Murillo
@rumurillo
Feb 19 2018 14:42
That's what I thought. Ethereumjs is working fine; I'm able to connect using "truffle console"
There's internet connection on my phone
Juan Blanco
@juanfranblanco
Feb 19 2018 14:42
check your firewall
Rubén Murillo
@rumurillo
Feb 19 2018 14:43
Anything special I should check?
Juan Blanco
@juanfranblanco
Feb 19 2018 14:43
port open for testrpc?
when using geth it asks to open the port
Rubén Murillo
@rumurillo
Feb 19 2018 14:44
checking that
image.png
Looks like we've found the problem
Juan Blanco
@juanfranblanco
Feb 19 2018 14:47
i don't know if telnet will be
a real scenario
try using curl from another pc?
Rubén Murillo
@rumurillo
Feb 19 2018 14:47
will do
Rubén Murillo
@rumurillo
Feb 19 2018 14:58
image.png
timed out
Juan Blanco
@juanfranblanco
Feb 19 2018 14:59
would not that be http://
instead of telnet://
Rubén Murillo
@rumurillo
Feb 19 2018 14:59
true :smile:
Juan Blanco
@juanfranblanco
Feb 19 2018 14:59
you can also test getbalance
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"],"id":1}'
plus your address
Rubén Murillo
@rumurillo
Feb 19 2018 15:01
chekcing it
image.png
Will try getbalance using curl
Rubén Murillo
@rumurillo
Feb 19 2018 15:15
image.png
Am I doing it wrong?
Rubén Murillo
@rumurillo
Feb 19 2018 15:46
I believe it might be because of the port
Rubén Murillo
@rumurillo
Feb 19 2018 16:22
Using cURL is not working either :worried:
When I run testrpc ... the port is successfully opened... I think
image.png
Juan Blanco
@juanfranblanco
Feb 19 2018 16:34
yeah but your firewall might not have it opened
Rubén Murillo
@rumurillo
Feb 19 2018 16:34
Just checked. I have McAfee handling my firewall
Juan Blanco
@juanfranblanco
Feb 19 2018 16:35
well i guess that is your problem
Rubén Murillo
@rumurillo
Feb 19 2018 16:38
Will uninstall and check again.
Will let you know
Rubén Murillo
@rumurillo
Feb 19 2018 16:58
@juanfranblanco ... I will forever hate McAfee. Period.
Juan Blanco
@juanfranblanco
Feb 19 2018 16:59
ha ha yeah i remember when it used to slow down the development completelly
Rubén Murillo
@rumurillo
Feb 19 2018 17:00
I spent, literally, all day long yesterday trying to figure out why it wasn't working
I wouldn't have done it without your help, @juanfranblanco. I would have probably set on fire my laptop and get a new one
Juan Blanco
@juanfranblanco
Feb 19 2018 17:02
ha ha breaking walls, burning laptops, you are rich :)
Rubén Murillo
@rumurillo
Feb 19 2018 17:02
lol. Thanks, @juanfranblanco!
Juan Blanco
@juanfranblanco
Feb 19 2018 17:02
nb
Jonathan Sheely
@jsheely
Feb 19 2018 17:48
Is there a built in way to get the latest bocks gas limit? Can't find the method
getblockbynumber or getblockbyhash
using GetBlockNumber to get last block number
Jonathan Sheely
@jsheely
Feb 19 2018 17:50
I tried that but I just get a HexBigInteger back
bluuman
@bluuman
Feb 19 2018 17:50
what is the value?
you can convert that to a biginteger if im not mistaken
.Value property
Jonathan Sheely
@jsheely
Feb 19 2018 17:51
Sure, But that isn't a block
bluuman
@bluuman
Feb 19 2018 17:52
sorry, i assumed you were talking about the field gaslimit
let me try
Jonathan Sheely
@jsheely
Feb 19 2018 17:52
I think I am
I'm trying to do the equivalent of web3.eth.getBlock(“latest”).gasLimit
bluuman
@bluuman
Feb 19 2018 17:54
yes, understood
i have my project open, ill see what im getting
Jonathan Sheely
@jsheely
Feb 19 2018 17:54
I had been using EstimateGasAsync() but running into some trouble. So trying to max it out and see what happens
bluuman
@bluuman
Feb 19 2018 17:59
GetBlockWithTransactionsByNumber
this one returns an object with gaslimit
which method are you using again?
GetBlockWithTransactionHashesByNumber suits your purpose better
bluuman
@bluuman
Feb 19 2018 18:04
doesn't have all the tx objects
Jonathan Sheely
@jsheely
Feb 19 2018 19:50
Awesome. Thank you
So what did you pass into that function?
"latest" is not acceptable
Nevermind. Forgot about BlockParameter.CreateLatest()
bluuman
@bluuman
Feb 19 2018 23:30
glad its working :+1:
Jonathan Sheely
@jsheely
Feb 19 2018 23:31
Is it normal to exceed the gas limit for a block by performing only a couple mutations in a transaction?
Have a function that has like 8 requires in it and 3 mutations and it blows up