These are chat archives for Nethereum/Nethereum

11th
Sep 2018
Tomas Tichy
@ttichy
Sep 11 2018 02:21
@sjalq from within a contract, you can only query for generated events (Nethereum/Nethereum.Workbooks#7)
for a function with signature like this function addEvent(string identifier, uint32 eventCode, bytes parameters, uint64 clientTimeStamp). How do I get nethereum to pass the bytes parameters? For the params object[] I've tried new object[] {"1234","410", new byte[] {1,2,3,4}, 12345} but EstimateGasAsync returns with a NullReferenceException :(
Thanks @juanfranblanco
Juan Blanco
@juanfranblanco
Sep 11 2018 10:38
"410" should be an int?
@ttichy
Tomas Tichy
@ttichy
Sep 11 2018 15:19
thanks @juanfranblanco - I mistyped quotes around 410, so that wasn't it. But ultimately, that is the correct syntax for passing bytes as parameters and it's working now. I think I was pointing to an old version of the contract yesterday. Duh
Juan Blanco
@juanfranblanco
Sep 11 2018 15:38
awesome @ttichy :)
Captain Paul
@voteopolis_twitter
Sep 11 2018 17:41

Hello - was using truffle petshoptutorial(with additional test contracts/functions) - all tested(with ganache).
Converting to use Nethereum from ASP.Net MVC controller.
Have ganache running - and copied word-list and accounts. transferring between 2 accounts works. retrieving contract and functions appears to work.
However, I cannot manage to get any function calls to work...have tried multiple calls/function combinations...
Attached code - thanks:

Web3 w3 = new Web3("http://localhost:7545");
var words = getWords();
var address = getFromAddress();
var toAddress = getToAddress();
var abi = getABI();
var bytecode = getByteCode();

        var account = new Wallet(words, null).GetAccount(address);
        var wei = Web3.Convert.ToWei(1, Nethereum.Util.UnitConversion.EthUnit.Ether);
        HexBigInteger gas = new HexBigInteger(wei);

        //this works transfer 1 between the two accounts
        //var transaction = await w3.TransactionManager.SendTransactionAsync(account.Address, toAddress, gas);

        //all following contract and function calls appear to work
        Contract c = w3.Eth.GetContract(abi, bytecode);
        Function getVoteCount = c.GetFunction("getVoteCount");//function getVoteCount(uint petId) public view returns (uint, uint, uint) 
        Function getVotes = c.GetFunction("getVotes");//function getVotes() public view returns (uint[16], uint[16], uint[16])
        Function voteOn = c.GetFunction("voteOn");//function voteOn(uint petId, uint voteNumber) public payable returns (uint) 

        //System.Exception: Too many arguments: 4 > 2
        //var a = await voteOn.EstimateGasAsync(account, gas, gas, new object[] { 2, 2 });

        //Nethereum.JsonRpc.Client.RpcResponseException: The field to must have byte length of 20
        // var a = await voteOn.EstimateGasAsync(new object[] { 2, 2 });

        //copied from docs
        //var addBidReceipt = await addBidFunction.SendTransactionAndWaitForReceiptAsync(account.Address, gas, null);

        //Nethereum.JsonRpc.Client.RpcResponseException: Number can only safely store up to 53 bits
        //var s = await getVotes.SendTransactionAndWaitForReceiptAsync(address, gas, null);

        //Nethereum.JsonRpc.Client.RpcResponseException: The field to must have byte length of 20
        //var s = await voteOn.SendTransactionAndWaitForReceiptAsync(address, null, new object[] { 2, 2 });

        //doesn't seem to comply with method signatures - and compiles when it shouldn't and vice versa etc

        // System.Exception: Too many arguments: 3 > 2
        // var s = await voteOn.SendTransactionAndWaitForReceiptAsync(address, null, gas, 1, new object[] { 2, 2 });

        // System.Exception: Too many arguments: 4 > 0
        //var s = await getVotes.CallAsync<uint[]>(address, gas, 1, null);

        //Nethereum.JsonRpc.Client.RpcResponseException: The field to must have byte length of 20
        //var s = await getVotes.CallAsync<uint[]>();