0

I write this simple contract:

contract greeter {
    event LogSender(address sender);
    function getSender() constant returns (address) {
       LogSender(msg.sender);
       return msg.sender;
   }
}

Web Env [OK]

  1. Google Chrome with MetaMask Plugin
  2. Remix for Compile, Deploy and Run My contract
  3. Geth client in private test network

I choose account in MetaMask, call the function getSender() and it return the right value (the selected address in MetaMask)

C# Env (Nethereum) [WRONG]

  1. Windows Form app with included Nethereum Portable Lib
  2. Geth client in private test network

    try
    {
        Web3 web3 = new Web3(new ManagedAccount(txtAddress.Text, txtPassword.Text), "http://localhost:8545");
    
        GreeterService gs = new GreeterService(web3, txtContractAddress.Text);
    
        var res = await gs.GetSenderAsyncCall();
    
        txtLog.AppendText("getSender: " + res + "\n");
    }
    catch(Exception ex)
    {
        txtLog.AppendText(ex.Message + "\n");
    }
    

When I call the function with C#, res => first address of geth accounts! The address used for create an instance of ManagedAccount is not recognized!

Please give me support guys!!!

0

You need to pass the wallet address in if you want specific info on a specirfic address

    Contracts.Function myFunctionName = contract.GetFunction("YourFunctionName");
    bool value = await myFunctionName.CallAsync<bool>(from: address, gas: new HexBigInteger(0), value: new HexBigInteger(0), functionInput: i);

This assumes you have a function that checks the wallet address for something based on i as an index (returning true or false);

There is no gas cost for checking information from the Blockchain.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.