michielpost / MetaMask.Blazor

Use MetaMask with Blazor WebAssembly
MIT License
44 stars 21 forks source link

Added extension methods to send a transaction and get receipt via Nethereum #10

Closed CodyJG10 closed 2 years ago

michielpost commented 2 years ago

Thanks for your PR!

Can you tell me some more about this PR? What does it do? Why is it needed?

It looks like it's calling a smart contract and show the result. It's already possible to call smart contracts using this library. If you switch to the Kovan Network, it's also in the sample app.

See this: https://github.com/michielpost/MetaMask.Blazor/blob/master/MetaMask.Blazor.SampleApp/Pages/Index.razor.cs#L153 and here for the parameters: https://github.com/michielpost/MetaMask.Blazor/blob/master/MetaMask.Blazor.SampleApp/Pages/Index.razor.cs#L197-L221

CodyJG10 commented 2 years ago

Thanks for the reply! I did this to simplify the process if the user is seeking to retrieve an actual receipt and data within the completed transaction.

For example, the function you linked does indeed call the function, but it returns the transaction hash. What if you needed to access an event that would be emitted by the transaction? Or if you needed the address of a deployed smart contract resulting from that transaction? In Nethereum, you would need the TransactionReceipt.

With the function I added, you get the transaction receipt which is the result of the transaction. This is how you can access the data, to say, a smart contract function with a return value. Another example is if you're looking to retrieve event logs.

Basically, it's for when you need to send a transaction but also need to wait for the transaction to be completed the next block mined/staked/whatever.

Hope this explanation helps! Thanks!

michielpost commented 2 years ago

Released in NuGet version 1.6.0 https://www.nuget.org/packages/MetaMask.Blazor/