These are chat archives for Nethereum/Nethereum

11th
Feb 2018
Brianenno2
@Brianenno2
Feb 11 2018 10:15 UTC

Hi to everyone, I have a problem when I'm getting the value from a getter (in the smart contract).
In my contract I have this simple one:
function getBudget constant returns (string){
return (budgetString);
}
I'm trying the return the value with the c# code above:
await functionToCall.CallDeserializingToObjectAsync<Budget>();
but, what i have the error: "No parameterless constructor defined for this object."
(I already tryed with an empty array or list).

The "Budget" class is an object created with the "[FunctionOutput]" attribute (as the tutorial says).
Please, I need help. Does anyone have an idea why is not working? Thanks

Juan Blanco
@juanfranblanco
Feb 11 2018 12:36 UTC
@kkagill yes I was able to return the result, your issue was that the amounts were not matching, hence it was throwing an error when submitting the transaction. Then when attempting to retrieve the results nothing was returned due to the previous error
You need to change your amounts to Wei or Eth
She Jong Shon
@kkagill
Feb 11 2018 12:48 UTC
@juanfranblanco submitting the transaction is not the problem
@juanfranblanco my problem is I can't retrieve public constant returns function after I've submitted transaction
@juanfranblanco as you can see from the code I can submit the transaction and var result returns true which means transaction has been successful
 var transactionHash = await functionPlaceBet.SendTransactionAsync(transactionInput, functionInput);            
 var result = await functionPlaceBet.CallAsync<bool>();

@juanfranblanco but

var result2 = await functionGetBetterBettingInfo.CallDeserializingToObjectAsync<GetBetterBettingInfo>(senderAddress);

this constant returns function is returning 0. This is the problem.

var functionGetBetterBettingInfo = contract.GetFunction("getBetterBettingInfo");
var result2 = await functionGetBetterBettingInfo.CallDeserializingToObjectAsync<GetBetterBettingInfo>(senderAddress);

Do I need to implement more codes other than those two lines?

Juan Blanco
@juanfranblanco
Feb 11 2018 12:54 UTC
If you look at your solidity code, the problem is that 200 ether is not the same as 200 wei
Fix that and you will get some results
She Jong Shon
@kkagill
Feb 11 2018 12:57 UTC
@juanfranblanco yeah. So this was the fix you gave me and I replaced, but this still gives me 0 so I'm kinda lost T_T image
Juan Blanco
@juanfranblanco
Feb 11 2018 13:00 UTC
SendTransactionAndWaitForReceipt
Well if it is not mined you will get 0
She Jong Shon
@kkagill
Feb 11 2018 13:01 UTC
oh
constant function still needs to be mined?
Juan Blanco
@juanfranblanco
Feb 11 2018 13:02 UTC
Well you are changing the state before, but until is mined it won't be included for your constant function to retrieve the values you are expecting
She Jong Shon
@kkagill
Feb 11 2018 13:04 UTC
thanks for explanation, where can I find the usage for SendTransactionAndWaitForReceipt in the document?

@juanfranblanco

 var test = functionGetBetterBettingInfo.SendTransactionAndWaitForReceiptAsync(senderAddress);

I will try with this first

She Jong Shon
@kkagill
Feb 11 2018 13:11 UTC
@juanfranblanco nice I see some progress here, it now returns null instead of 0.
image
functionGetBetterBettingInfo takes senderAddress, and I get returned value using remix ropsten.
image
what would be the problem here?
I suspect it's a dto mapping?
Juan Blanco
@juanfranblanco
Feb 11 2018 14:06 UTC
The mappings are fine, they were fine on my end
Try testing locally using clique or poa, you will get a faster test cycle
She Jong Shon
@kkagill
Feb 11 2018 14:08 UTC
yeah i will try with that, but getting null means it is still not mined?
Juan Blanco
@juanfranblanco
Feb 11 2018 14:09 UTC
@Brianenno2 a List<BigInteger> will do the trick
She Jong Shon
@kkagill
Feb 11 2018 14:15 UTC

@juanfranblanco ok, so I further tested adding another constant return function which returned 222

var transactionHash = await functionPlaceBet.SendTransactionAsync(transactionInput, functionInput);            
 var result = await functionPlaceBet.CallAsync<bool>();
var test = await functionGetBetterBettingInfo.SendTransactionAndWaitForReceiptAsync(transactionInput1);
var result2 = await functionGetBetterBettingInfo.CallDeserializingToObjectAsync<GetBetterBettingInfo>(senderAddress);
var result3 = await functionGetContractBalance.CallAsync<uint>();

result3 returned 222 (data I expect), but result2 returns arrays of null

oh man it finally works
thanks juan
She Jong Shon
@kkagill
Feb 11 2018 14:20 UTC
so SendTransactionAndWaitForReceiptAsync was the key here.
Juan Blanco
@juanfranblanco
Feb 11 2018 14:47 UTC
Cool :)
@doreegekku List<BigInteger> will do
Juan Blanco
@juanfranblanco
Feb 11 2018 14:53 UTC
@Brianenno2 if you deserialising to Budget it needs a parameterless constructer (that is the Budget DTO) and an attribute with Parameter ("string", 1)
Where string is the type of the output and 1 the order
Or just CallAsync<string>