These are chat archives for Nethereum/Nethereum

11th
Oct 2017
Juan Blanco
@juanfranblanco
Oct 11 2017 04:45
that should do it return myContract.contract.GetFunction("GetStoredHash").CallAsync<string>(bp).Result;
but you should use await instead of Result
that might help you
Chandra Sekhar
@tcsekhar
Oct 11 2017 13:54
Thanks @juanfranblanco

When I write the contract and read it within the same context, it always returns:

SmartContract s = new SmartContract();
myProjObj o = await s.WriteSmartContract(ComputedHash,Description,DateTime);
var res1 = s.GetStoredStateHash(o.blocknumber).Result;

But when I write the contract with a different instance and read it with a different instance, it always gets back null. I will try with just await - but I believe it will still return with null. I will confirm shortly.

SmartContract s = new SmartContract();
myProjObj o = await s.WriteSmartContract(ComputedHash,Description,DateTime);
SmartContract p = new SmartContract();
var res2 = p.GetStoredStateHash(o.blocknumber).Result;

Juan Blanco
@juanfranblanco
Oct 11 2017 13:57
just think of the blockchain as a database so it should not be an issue
also note if you are launching the testchain using the batch file provided
that deletes the state of the previous launch
Chandra Sekhar
@tcsekhar
Oct 11 2017 13:59
The blockchain is always running on a separate node. So that shouldn't be the issue.
Juan Blanco
@juanfranblanco
Oct 11 2017 13:59
then yes it shouldnt
are you connecting to live and using fast sync ?
hak
@hakart_twitter
Oct 11 2017 14:06

Hi Guys one question
the following code is working fine locally and the smart contract function returns correct value

var contract = _web3.Eth.GetContract(abi, contractAddress);
                var function = contract.GetFunction(methodName);
                var result = await function.CallAsync<TReturn>(arguments);

but when i deployed following code under IIS as WebAPI method the result is always 0
have you ever faced such of issue ?
@juanfranblanco

Chandra Sekhar
@tcsekhar
Oct 11 2017 14:06

No I was not using --fast

geth.exe --datadir=devChain init genesis_dev.json
geth.exe --mine --rpc --networkid=39318 --cache=2048 --maxpeers=0 --datadir=devChain --ipcpath "geth.ipc" --rpccorsdomain "*" --rpcapi "eth,web3,personal,net,miner,admin,debug" --rpcaddr "0.0.0.0" --verbosity 0 console

hak
@hakart_twitter
Oct 11 2017 14:26

Hi Guys one question
the following code is working fine locally and the smart contract function returns correct value

var contract = _web3.Eth.GetContract(abi, contractAddress);
                var function = contract.GetFunction(methodName);
                var result = await function.CallAsync<TReturn>(arguments);

but when i deployed following code under IIS as WebAPI method the result is always 0
have you ever faced such of issue ?
to continue my question could it be unable to create socket under IIS ?
@juanfranblanco

Juan Blanco
@juanfranblanco
Oct 11 2017 14:32
@tcsekhar yes that should be fine
just checking :)
@hakart_twitter can you perform any other type of request? like GetBalance
hak
@hakart_twitter
Oct 11 2017 14:35
let me check
hak
@hakart_twitter
Oct 11 2017 14:42
@juanfranblanco GetBalance also returns 0
is there any access issue ?
Anyway i turn off my firewall
Juan Blanco
@juanfranblanco
Oct 11 2017 14:46
have you got the ' --rpcaddr "0.0.0.0"'
as per the geth.exe comment above ?
try infura
also to validate is your node access
hak
@hakart_twitter
Oct 11 2017 14:47
I'm connecting to Azure Consortium Blockchain it is not local geth.exe
Juan Blanco
@juanfranblanco
Oct 11 2017 14:47
ok
can you connect from the console?
hak
@hakart_twitter
Oct 11 2017 14:48
it is working fine with debug mode
Juan Blanco
@juanfranblanco
Oct 11 2017 14:48
ok it might be threading issue
in iis
hak
@hakart_twitter
Oct 11 2017 14:49
did you mean the issue in Nethereum ?
ah ok
Juan Blanco
@juanfranblanco
Oct 11 2017 14:49
well we have configureAwait(false)
everywhere
and that has solved issues before
"we" :)
hak
@hakart_twitter
Oct 11 2017 14:52
What can you suggest to solve the issue ? any thoughts ?
Did you ever test Nethereum under IIS ?
Juan Blanco
@juanfranblanco
Oct 11 2017 14:52
so the issue only happens when deployed
yeah
i have ran webjobs too
azure website
hey look
hak
@hakart_twitter
Oct 11 2017 14:53
great!
and the very very old
that was pointing at the DAO ;)
Karsten Gebbert
@krgn
Oct 11 2017 14:55
Hi!
Juan Blanco
@juanfranblanco
Oct 11 2017 14:55
HEY
Karsten Gebbert
@krgn
Oct 11 2017 14:56
how's it going?
I have come here with a question :)
@krgn awesome :D
hak
@hakart_twitter
Oct 11 2017 14:57
Thanks @juanfranblanco I got the point let me test them and make sure the issue was not coming from my site and get back to you
Thank you very much for quick response !
Juan Blanco
@juanfranblanco
Oct 11 2017 14:57
sure
Karsten Gebbert
@krgn
Oct 11 2017 14:57
@juanfranblanco yes, I'm in awe of the amount of work you put into Nethereum!
pretty cool stuff
Juan Blanco
@juanfranblanco
Oct 11 2017 14:58
thanks
so how is it going your F# implementation?
Karsten Gebbert
@krgn
Oct 11 2017 14:59
I'm running into this problem that I can't put my finger on. When I call the multiply function of the sample contract with a log filter set up, I don't catch any events
yet, when I make a transaction from geth, it works and the filter catches the log correctly
Juan Blanco
@juanfranblanco
Oct 11 2017 14:59
i guess you have setup the log before hand
to getChanges?
Karsten Gebbert
@krgn
Oct 11 2017 15:00
aha! how do I do that?
Juan Blanco
@juanfranblanco
Oct 11 2017 15:01
the filterlog I mean
Karsten Gebbert
@krgn
Oct 11 2017 15:01
I basically have this:
  let testFunc = contract.GetFunction("test")
  let multiplyFunc = contract.GetFunction("multiply")

  let multiplyEvent = contract.GetEvent("Multiplied")

  let filterAll = await (multiplyEvent.CreateFilterAsync())
Juan Blanco
@juanfranblanco
Oct 11 2017 15:01
if is not setup before hand it will get the newest
ah ok that should do it
Karsten Gebbert
@krgn
Oct 11 2017 15:01
(where await is just a function that says Async.AwaitTask t |> Async.RunSynchronously)
Juan Blanco
@juanfranblanco
Oct 11 2017 15:02
so for your filterAll you get the HexBigInteger with the id of the filter
Karsten Gebbert
@krgn
Oct 11 2017 15:02
right
Juan Blanco
@juanfranblanco
Oct 11 2017 15:03
ok so now you send the multiple transaction
Karsten Gebbert
@krgn
Oct 11 2017 15:03
and then I do this: multiplyEvent.GetFilterChanges<NewResult>(filterAll) |> await
Juan Blanco
@juanfranblanco
Oct 11 2017 15:03
yes that should do it
Karsten Gebbert
@krgn
Oct 11 2017 15:03
hm strange, it doesn't seem to work
is geth 1.7.1 supported in general?
Juan Blanco
@juanfranblanco
Oct 11 2017 15:04
yes
was your transaction successful?
can you see the log
in the transactionreceipt?
Karsten Gebbert
@krgn
Oct 11 2017 15:05
the receipts look OK, and there is no error
Juan Blanco
@juanfranblanco
Oct 11 2017 15:05
well there is no errors ever
just now in Byzantine you have the status
Karsten Gebbert
@krgn
Oct 11 2017 15:05
(been running into "intrinsic gas too low" before though, so I had to use a signature with explicit gas setting)
Juan Blanco
@juanfranblanco
Oct 11 2017 15:05
to see errors
ah that might be the issue
Karsten Gebbert
@krgn
Oct 11 2017 15:05
ah really!
Juan Blanco
@juanfranblanco
Oct 11 2017 15:06
you have not put enough gas
Karsten Gebbert
@krgn
Oct 11 2017 15:06
so I used this:
        let receipt =
          multiplyFunc.SendTransactionAndWaitForReceiptAsync(
            sender,
            HexBigInteger(Numerics.BigInteger(4700000)),
            HexBigInteger(Numerics.BigInteger(7)),
            null)
          |> await
Juan Blanco
@juanfranblanco
Oct 11 2017 15:06
try estimate gas before hand, geth seems to calculate ok the gas now for transaction alls
(not deployment)
try this
to see if the event is in the log
Karsten Gebbert
@krgn
Oct 11 2017 15:07
how can I check if there is an error in the transaction receipt?
Juan Blanco
@juanfranblanco
Oct 11 2017 15:08
well if your gas sent matches the consumption
that is normally a sign of a problem
Karsten Gebbert
@krgn
Oct 11 2017 15:09
ah ok, misunderstanding: when I use that signature up there, the "intrinsic gas too low" error doesn't happen
Juan Blanco
@juanfranblanco
Oct 11 2017 15:09
oh yes
Karsten Gebbert
@krgn
Oct 11 2017 15:09
but the logs don't appear either
Juan Blanco
@juanfranblanco
Oct 11 2017 15:10
there is a gas check
when you send
but there is a gas consumption in your contract
so if there is an error or your ran out of gas all the gas is consumed
and your transction will stay there on chain
Karsten Gebbert
@krgn
Oct 11 2017 15:11
its actually just the one from your that example at this point
ah interesting!
Juan Blanco
@juanfranblanco
Oct 11 2017 15:11
just add more gas
Karsten Gebbert
@krgn
Oct 11 2017 15:11
hehe
ok, I'll try that
Juan Blanco
@juanfranblanco
Oct 11 2017 15:12
did you check the receipt?
Karsten Gebbert
@krgn
Oct 11 2017 15:12
what do I need to look for in the receipt?
(sorry, I'm pretty new to this stuff)
Juan Blanco
@juanfranblanco
Oct 11 2017 15:13
it is ok, check if it matches the gas you sent
to the one used
but also check the logs
Karsten Gebbert
@krgn
Oct 11 2017 15:13
ah, CumulativeGasUsed
Juan Blanco
@juanfranblanco
Oct 11 2017 15:13
the should contain your event
well they will come up like a set of bytes
in the log[0]
and you should have values in topic[0], topic[1], etc
or just ry the code i sent before to decode the transaction receipt log
Karsten Gebbert
@krgn
Oct 11 2017 15:17
yeah, its probably not the gas. the call uses 21357 wei according to CumulativeGasUsed in the receipt
Juan Blanco
@juanfranblanco
Oct 11 2017 15:18
ok
Karsten Gebbert
@krgn
Oct 11 2017 15:18
I'll probe the logs though
Juan Blanco
@juanfranblanco
Oct 11 2017 15:18
sure
the logs will cotain the event
should contain the event :)
Karsten Gebbert
@krgn
Oct 11 2017 15:18
ah this is Json AST
Juan Blanco
@juanfranblanco
Oct 11 2017 15:19
yes use the
Karsten Gebbert
@krgn
Oct 11 2017 15:21
ah I see, its empty
Juan Blanco
@juanfranblanco
Oct 11 2017 15:22
ok so something has gone wrong
somewhere
Karsten Gebbert
@krgn
Oct 11 2017 15:22
I shall make a boiled down version to show you
Juan Blanco
@juanfranblanco
Oct 11 2017 15:22
ok cool
the FileSyncContract actually contains the example contract from your tutorial
Juan Blanco
@juanfranblanco
Oct 11 2017 15:31
ah you dont need to
Karsten Gebbert
@krgn
Oct 11 2017 15:31

and I'm starting geth like this:

${dapp.go-ethereum}/bin/geth \
    --identity "KrgnNode${count}" \
    --datadir "$@" \
    --port ${port} \
    --rpc \
    --rpcaddr 127.0.0.1 \
    --rpcport ${rpc} \
    --rpccorsdomain "*" \
    --rpcapi "eth,web3,personal,net,miner,admin,debug" \
    --ws \
    --wsport 3000 \
    --wsorigins "*" \
    --networkid 666 \
    --dev \
    --nat "any" \
    --shh \
    --gasprice 0 \
    --lightkdf \
    --nodiscover \
    --vmdebug \
    --verbosity 6 \
    console 2>> "$@"/node${count}.log

(which has some nix variables interpolated)

Juan Blanco
@juanfranblanco
Oct 11 2017 15:31
unlock your account
Karsten Gebbert
@krgn
Oct 11 2017 15:31
ok
Juan Blanco
@juanfranblanco
Oct 11 2017 15:31
as you are using a managed account
Karsten Gebbert
@krgn
Oct 11 2017 15:31
I was cargo cult'ing around because it didn't work :laughing:
Juan Blanco
@juanfranblanco
Oct 11 2017 15:31
:)
also if you use clique
it will be much faster and better for your PC
as it uses a PoA consensus so the mining process is different
"mining"
so you won't need to control the mining either
Karsten Gebbert
@krgn
Oct 11 2017 15:33
ah nice, that's cool
Juan Blanco
@juanfranblanco
Oct 11 2017 15:35
give two ticks ill create an f# project
Karsten Gebbert
@krgn
Oct 11 2017 15:35
thank you!
I was about to offer to make one
(ah, maybe this is important: I'm using netcoreapp2.0 profile in linux)
Juan Blanco
@juanfranblanco
Oct 11 2017 15:36
it should not be a problem
if everthing fails ill run the ubuntu bash
Karsten Gebbert
@krgn
Oct 11 2017 15:38
I'm just saying, because I get a warning for Nethereum.Portable that it uses 4.6.1 framework profile, but it should be compatible afaik
Juan Blanco
@juanfranblanco
Oct 11 2017 15:38
oh yes you need to use Nethereum.Web3
I had the same issue, actually @knocte raised it the other day
Karsten Gebbert
@krgn
Oct 11 2017 15:39
you mean instead of Web3Geth
Juan Blanco
@juanfranblanco
Oct 11 2017 15:39
oh
sorrry yeah
Geth is the same
Karsten Gebbert
@krgn
Oct 11 2017 15:39
right, ok!
its a framework related issue?
Juan Blanco
@juanfranblanco
Oct 11 2017 15:39
The portable library is just everything in one project
Karsten Gebbert
@krgn
Oct 11 2017 15:40
btw, does IPC also work on linux?
Juan Blanco
@juanfranblanco
Oct 11 2017 15:40
I think is an issue with portable itself
yes released the other day
Karsten Gebbert
@krgn
Oct 11 2017 15:40
Nice!
Juan Blanco
@juanfranblanco
Oct 11 2017 15:40
netstandard 1.3
Karsten Gebbert
@krgn
Oct 11 2017 15:41
so, I should use the single packages (-Pre?) and Nethereum.Web3?
that sounds like a plan
Juan Blanco
@juanfranblanco
Oct 11 2017 15:41
well if you use Nethereum.Geth
then that depends on Nethereum.Web3
but if you are not going to use any of the management apis for Geth
(mining, debug, admin..)
then just use web3
Karsten Gebbert
@krgn
Oct 11 2017 15:42
ah ok
thats fine, I don't necessarily need to use management APIs, although it makes things somewhat easier I guess
and for IPC, does "eth_subscribe"/"eth_unsubscribe" for push work?
Juan Blanco
@juanfranblanco
Oct 11 2017 15:58
no i have not implemented that yet
Karsten Gebbert
@krgn
Oct 11 2017 15:58
ah ok
I have a little web socket based thing that listens to geth and tells me about logs and stuff
Karsten Gebbert
@krgn
Oct 11 2017 16:38
with the single packages I get this:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942'. The system cannot find the file specified.

   at Nethereum.Util.Sha3Keccack.CalculateHash(Byte[] value)
   at Nethereum.Util.Sha3Keccack.CalculateHash(String value)
   at Nethereum.ABI.FunctionEncoding.SignatureEncoder.GenerateSha3Signature(String name, Parameter[] parameters)
   at Nethereum.ABI.Model.EventABI.get_Sha33Signature()
   at Nethereum.Contracts.EventTopicBuilder.GetSignaguteTopic()
   at Nethereum.Contracts.Event.CreateFilterInput(BlockParameter fromBlock, BlockParameter toBlock)
   at Nethereum.Contracts.Event.CreateFilterAsync(BlockParameter fromBlock)
it happens when I call let filterAll = await (multiplyEvent.CreateFilterAsync())
Juan Blanco
@juanfranblanco
Oct 11 2017 17:24
hmm
that one works
:)
you had confused some of the parameters
you may need to add BouncyCastle for your error
also i have just run all sync on the sample
Juan Blanco
@juanfranblanco
Oct 11 2017 17:31
let me know what you think @krgn ^^
Karsten Gebbert
@krgn
Oct 11 2017 17:52
thank you!
I tried adding BouncyCastle.NetCore but no luck
Juan Blanco
@juanfranblanco
Oct 11 2017 17:53
that won't work
you will need normal bouncycastle
or portable if using the portable library
Karsten Gebbert
@krgn
Oct 11 2017 17:54
I use paket, so the deps should all be there
Juan Blanco
@juanfranblanco
Oct 11 2017 17:54
yeah
i have not used paket yet
Karsten Gebbert
@krgn
Oct 11 2017 17:55
and indeed it is in the packages folder
hm
Karsten Gebbert
@krgn
Oct 11 2017 18:13
its working with Nethereum.Portable!
:tada:
Juan Blanco
@juanfranblanco
Oct 11 2017 18:13
ha ha in VisualStudio portable complaints
awesome
Karsten Gebbert
@krgn
Oct 11 2017 18:13
oh no XD
@juanfranblanco thank you for your help!
Juan Blanco
@juanfranblanco
Oct 11 2017 18:16
oh it is cool I wanted to have an F# sample :)