Nethereum / Nethereum.Playground

Compile and run Nethereum snippets on the browser
MIT License
27 stars 17 forks source link

Example of pending transactions using the block #33

Closed juanfranblanco closed 3 years ago

juanfranblanco commented 4 years ago

using System; using System.Text; using Nethereum.Hex.HexConvertors.Extensions; using System.Threading.Tasks; using Nethereum.Web3; using Nethereum.RPC.Eth.DTOs;

public class Program {

static async Task Main(string[] args)
{

            var web3 = new Web3("https://mainnet.infura.io/v3/7238211010344719ad14a89db874158c");

          var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(BlockParameter.CreatePending());
                foreach(var txn in block.Transactions) {
                        Console.WriteLine(
                            $@"Hash:{txn.TransactionHash}, From: {txn.From}, To: {txn.To}, Value: {txn.Value}, Nonce: {txn.Nonce}, Data: {txn.Input}");

                }

}

}