Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.99 KB

Examples.md

File metadata and controls

57 lines (48 loc) · 1.99 KB

Examples of getting transactions

Get the last transactions of a certain address:

    var node = new Node(Node.MainNetHost);
    var limit = 100;
    var address = "3PBmsJXAcgnH9cu81oyW8abNh9jsaNzFQKJ";

    var transactions = node.GetTransactions(address, limit);

Get a transaction by its Id:

    var transaction = node.GetTransactionById("37nfgadHFw92hNqzyHFZXmGFo5Wmct6Eik1Y2AdYW1Aq");

Get all recent TransferTransactions:

    var transferTransactions = node.GetTransactions(address)
                                   .OfType<TransferTransaction>();

List all distinct recipients of MassTransferTransactions with EUR asset:

    var massTransferEURRecipients = node.GetTransactions(address)
                                 .OfType<MassTransferTransaction>()
                                 .Where(tx => tx.Asset.Id == Assets.EUR.Id)
                                 .SelectMany(tx => tx.Transfers)
                                 .Select(t => t.Recipient)
                                 .Distinct();

List all recently issued custom assets' names:

    var customAssetsNames = node.GetTransactions(address)
                                .OfType<IssueTransaction>()
                                .Select(tx => tx.Name);

Calculate the total amount of recently leased assets that are still leased:

    var leasedAmount = node.GetTransactions(address)
                         .OfType<LeaseTransaction>()
                         .Where(tx => tx.IsActive)
                         .Sum(tx => tx.Amount);

Count transactions of each type in recent transactions:

    var transactionsByType = node.GetTransactions(address)
                                 .GroupBy(tx => tx.GetType())
                                 .Select(group => new { Type = group.Key.Name, Count = group.Count() })
                                 .OrderByDescending(x => x.Count);

    foreach (var tx in transactionsByType)
        Console.WriteLine($"{tx.Type}\t\t{tx.Count}");