These are chat archives for Nethereum/Nethereum

27th
Oct 2017
Chandra Sekhar
@tcsekhar
Oct 27 2017 16:48
I need to pass a parameter to a Solidity function on a specific transaction block. I tried to do it this way but its failing. Can you please help me with how to pass the parameter:
    myProjObj myContract = await InitializeContract(contracthash, senderaddress, password, ethpooladdress);
    BlockParameter bp = new BlockParameter(blockno);
    return myContract.contract.GetFunction(v_functionName).CallAsync<string>(bp, v_delimiteddatatopass).Result.ToString();
check bottom part
of the workbook
are you using a hexbiginteger?
Chandra Sekhar
@tcsekhar
Oct 27 2017 16:52
It works if I don't pass the v_delimiteddatatopass variable (modifying the solidity function not to accept a string parameter)
the v_delimiteddatatopass is a string
Juan Blanco
@juanfranblanco
Oct 27 2017 16:53
it shouldnt be an issue
have you checked if it might be confused with other overload?
Chandra Sekhar
@tcsekhar
Oct 27 2017 16:54

SOLIDITY:

function getStoredHash(string inParams) returns(string) {
    return computedhash;
}

C#:
return myContract.contract.GetFunction("getStoredHash").CallAsync<string>(bp, "myparameter string").Result.ToString();

This doesn't work

I will check
Juan Blanco
@juanfranblanco
Oct 27 2017 16:54
yuu can try named parameters
Chandra Sekhar
@tcsekhar
Oct 27 2017 16:55
when you say named parameters you mean to create variables and pass the values in the variables correct?
Juan Blanco
@juanfranblanco
Oct 27 2017 16:55
no i mean providing the name of the parameter
Chandra Sekhar
@tcsekhar
Oct 27 2017 16:56

I see.

Is it like a name value pair object I should pass?

Chandra Sekhar
@tcsekhar
Oct 27 2017 16:58

myContract.contract.GetFunction(v_functionName).CallAsync<string>(bp, inParams: v_delimiteddatatopass).Result.ToString();

It doesn't like it. Compilation fails

myContract.contract.GetFunction(v_functionName).CallAsync<string>(bp, "inParams": v_delimiteddatatopass).Result.ToString();
neither
Juan Blanco
@juanfranblanco
Oct 27 2017 16:58
oh no it will be something like "values"
Chandra Sekhar
@tcsekhar
Oct 27 2017 16:59

In Solidity the name of the parameter is "inParams"

function getStoredHash(string inParams) returns(string) {
return computedhash;
}

Juan Blanco
@juanfranblanco
Oct 27 2017 16:59
oh no
"functionInput"
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:00
got it
you are awesome
Juan Blanco
@juanfranblanco
Oct 27 2017 17:00
sorry had to find it, bad memory
still i don't know what overload might have been confused with
so the theory might not be right
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:05
I will test and let you know.. There are no compile issues now

the client-side configuration does not match the proxy; the existing proxy is invalid

Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SmartContracts.GetStoredStateValue(String FunctionName, String BlockNumber, String DelimitedStringData, String ContractHash, String SenderAddress, String Password, String EthPoolAddress)
at SmartContractsClient.GetStoredStateValue(String FunctionName, String BlockNumber, String DelimitedStringData, String ContractHash, String SenderAddress, String Password, String EthPoolAddress)

Solidity:

function getStoredHash(string inParams) returns(string) {
    return computedhash;
}

C# Code:

public async Task<string> GetStoredStateValue(string v_functionName, HexBigInteger blockno, string v_delimiteddatatopass = "", string contracthash = "", string senderaddress = "", string password = "", string ethpooladdress = "")
{   if (v_delimiteddatatopass == null) v_delimiteddatatopass = "";
    myProjObj myContract = await InitializeContract(contracthash, senderaddress, password, ethpooladdress);
    BlockParameter bp = new BlockParameter(blockno);
    return myContract.contract.GetFunction(v_functionName).CallAsync<string>(bp, functionInput: v_delimiteddatatopass).Result.ToString();
}
Juan Blanco
@juanfranblanco
Oct 27 2017 17:10
that is a web service error
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:10
yes
I'm creating a webservice layer to interact with the ethereum contracts
Juan Blanco
@juanfranblanco
Oct 27 2017 17:10
ok got you
so you are exposing the rpc
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:11
yes
Juan Blanco
@juanfranblanco
Oct 27 2017 17:11
methods through a service
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:12
I'm then going to expose this through Extended Stored proc to be called from SQL server. That way, I will be able to leverage existing legacy applications to start using the blockchain
It could be potentially called through triggers even
Juan Blanco
@juanfranblanco
Oct 27 2017 17:12
ah cool, are you going to use clr sprocs
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:12
yes
Juan Blanco
@juanfranblanco
Oct 27 2017 17:12
nice
a shame that you cannot use them in azure
sql
sorry back to your issue
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:13
Yeah..
Juan Blanco
@juanfranblanco
Oct 27 2017 17:14
i think is issue is just the web service configuration at the moment
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:15
myContract.contract ==> is a Nethereum.Contracts.Contract object its in memory
Juan Blanco
@juanfranblanco
Oct 27 2017 17:16
"the client-side configuration does not match the proxy; the existing proxy is invalid"
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:16
if I modify the code not to pass the string parameter (modifying the solidity code with no input parameter) it works

This one below works perfectly fine:

Solidity:
function getStoredHash() returns(string) {
return computedhash;
}
C#:
public async Task<string> GetStoredStateValue(string v_functionName, HexBigInteger blockno, string v_delimiteddatatopass = "", string contracthash = "", string senderaddress = "", string password = "", string ethpooladdress = "")
{ if (v_delimiteddatatopass == null) v_delimiteddatatopass = "";
myProjObj myContract = await InitializeContract(contracthash, senderaddress, password, ethpooladdress);
BlockParameter bp = new BlockParameter(blockno);
return myContract.contract.GetFunction(v_functionName).CallAsync<string>(bp).Result.ToString();
}

the failure is at the nethereum.contracts.contract.getfunction(x).callasync call when I pass in the string parameter
Juan Blanco
@juanfranblanco
Oct 27 2017 17:18
right, but when you call the wcf
service
before hand?
is that part of the web service?
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:19
no its failing on this call.. Meaning if I port this to a console app, it will fail there as well
let me quickly create a console app and share the code
Juan Blanco
@juanfranblanco
Oct 27 2017 17:20
sure
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:34
    StackTrace    "   at SmartContract.<GetStoredStateValue>d__3.MoveNext() in C:\\Users\\chandra.sekhar\\documents\\visual studio 2017\\Projects\\SimpleSmartContract\\SimpleSmartContract\\SmartContract.cs:line 98\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at SimpleSmartContract.Program.<>c__DisplayClass0_0.<<Main>b__2>d.MoveNext() in C:\\Users\\chandra.sekhar\\documents\\visual studio 2017\\Projects\\SimpleSmartContract\\SimpleSmartContract\\Program.cs:line 34"    string
this is from the console app
Juan Blanco
@juanfranblanco
Oct 27 2017 17:35
ok have you tried other overload?
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:37
there are only 4 overloads. The other overloads require from and gas
Juan Blanco
@juanfranblanco
Oct 27 2017 17:37
yes just put your from address
and add some gas
Chandra Sekhar
@tcsekhar
Oct 27 2017 17:37
ok
Juan Blanco
@juanfranblanco
Oct 27 2017 17:37
just testing
Juan Blanco
@juanfranblanco
Oct 27 2017 17:49
got to go
speak tomorrow :D
Chandra Sekhar
@tcsekhar
Oct 27 2017 18:18

Thanks will talk to you tomorrow..
string s = myContract.contract.GetFunction(v_functionName).CallAsync<string>(senderaddress, new HexBigInteger(System.Numerics.BigInteger.Parse("0")), new HexBigInteger(System.Numerics.BigInteger.Parse("0")), bp, functionInput: v_delimiteddatatopass).Result.ToString();

Still errors out.

    StackTrace    "   at SmartContract.<GetStoredStateValue>d__3.MoveNext() in C:\\Users\\chandra.sekhar\\documents\\visual studio 2017\\Projects\\SimpleSmartContract\\SimpleSmartContract\\SmartContract.cs:line 100\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at SimpleSmartContract.Program.<>c__DisplayClass0_0.<<Main>b__2>d.MoveNext() in C:\\Users\\chandra.sekhar\\documents\\visual studio 2017\\Projects\\SimpleSmartContract\\SimpleSmartContract\\Program.cs:line 34"    string