I write this simple contract:

contract greeter {
    event LogSender(address sender);
    function getSender() constant returns (address) {
       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

        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!!!

1 Answer 1


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.

  • Even if the gas won't be charged this call will fail, if the gas parameter is set to 0. We need to pass the EstimateGasAsync result called from function instance
    – gsscoder
    Jun 4, 2022 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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