Nethereum / Nethereum.Templates.Metamask.Blazor

Metamask + Nethereum + Blazor interop
Apache License 2.0
87 stars 31 forks source link

Return values from contract function #4

Closed devjutsu closed 2 years ago

devjutsu commented 2 years ago

Hey! Is there a way I can possibly retrieve a value returned by contract function?

juanfranblanco commented 2 years ago

Same way as in Normal Nethereum, check the example of the Erc20

juanfranblanco commented 2 years ago

Actually i have just checked an in this example does not retrieve any values.. You have the documentation here: http://playground.nethereum.com/csharp/id/1005

devjutsu commented 2 years ago

Thank you! It really does return the value. But my concern is about MetaMask popup to confirm transaction and gas. When I try to call a function like this one:

function test(bytes4 _invite) external payable returns (uint256) {
        require(msg.value >= 1 ether, "Deposit funds to play");
        gameCount++;
        return gameCount;
    }

It doesn't ask for a MetaMask confirmation, doesn't charge the gas for this call. And doesn't change the contract state (gameCount). But it still returns the value. I might be misunderstanding something, but I wanted the same function to accept payment, modify state and return the value.

juanfranblanco commented 2 years ago

Sending transactions is different to getting data, you do not get any response back, just the transaction hash. Please come to discord to ask questions.

juanfranblanco commented 2 years ago

See the example here https://github.com/Nethereum/Nethereum.Metamask.Blazor/blob/master/Nethereum.Erc20.Blazor/Erc20Transfer.razor#L79-L84