WavesCS - C# client library for Waves API

It’s hidden. You generate public and private keys, then derive address from public key. Then you can give your address to someone, and when he sends funds to this address it will appear in blockchain and you will be able to spend funds using your private key.

1 Like

Thank you, i understand

Hi @Putu,

We’ve just added new functionality.

Now you can 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);

You can also get a transaction by its Id:

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

Here are some examples of how it can be used.

  1. Get all recent TransferTransactions:
    var transferTransactions = node.GetTransactions(address)
                                   .OfType<TransferTransaction>();
  1. List all distinct recipients of MassTransferTransactions with BTC asset:
    var massTransferBTCRecipients = node.GetTransactions(address)
                                 .OfType<MassTransferTransaction>()
                                 .Where(tx => tx.Asset.Id == Assets.BTC.Id)
                                 .SelectMany(tx => tx.Transfers)
                                 .Select(t => t.Recipient)
                                 .Distinct();
  1. List all recently issued custom assets’ names:
    var customAssetsNames = node.GetTransactions(address)
                                .OfType<IssueTransaction>()
                                .Select(tx => tx.Name);
  1. 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);
  1. 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}");
2 Likes

Cool. Any plan to update the nuget package soon?
When I check this page it was last updated 8 days ago.

Sorry for the delay with an answer, the nuget package is updated (v. 1.1.0.2).

Hi,
is there anyway to query the network with this library so as to get a list of every address with a minimum amount of waves, or even to get every address on waves?
I guess most airdrops already use this, how do i do this with this library?

Thanks

Hi,

I was trying to send TransferTransaction with recipient alias and it fails during signing:

var tx = new TransferTransaction(Accounts.Alice.PublicKey, "alias:T:somealias", Assets.WAVES, 0.001m).Sign(Accounts.Alice);

with exception:

System.ArgumentException: Illegal character l at position 1
    at WavesCS.Base58.Decode(String input) in C:\Projects\WavesCS\WavesCS\Base58.cs:line 98
   at WavesCS.Base58.FromBase58(String data) in C:\Projects\WavesCS\WavesCS\Base58.cs:line 162
   at WavesCS.TransferTransaction.GetBody() in C:\Projects\WavesCS\WavesCS\Transactions\TransferTransaction.cs:line 77
   at WavesCS.TransactionExtensons.Sign[T](T transaction, PrivateKeyAccount account, Int32 proofIndex) in C:\Projects\WavesCS\WavesCS\Transactions\Transaction.cs:line 96

In seems that the problem in the prefix “alias:” itself!

The NuGet package is updated (v. 1.1.0.4):

  • FastHash(byte[] message) was added;
  • Node.GetTransactions was added;
  • We add the possibility to generate Id for Transaction and Order instances;
  • Deserialization of ExchangeTx was fixed (FromJson method).

The NuGet package is updated (v. 1.1.0.5):

  • Add the ability to transfer to aliased addresses.
  • Add Node.GetAssetBalances(address) method.
  • Change tests’ structure.

Hi,

It seems that updated nuget packages v. 1.1.0.4 and v. 1.1.0.5 contain updated source files but the binaries (WavesCS.dll) are old. For example if you try to use nuget v. 1.1.0.5 - there is still no method TransactionExtensons.GenerateId!

Thank you, I loaded an update 1.1.0.6, check it please

Hi,

Thanks for the updated binaries in Nuget 1.1.0.6.

Now I’ve found a deserialization exception when trying to create Transfer or MassPayment transaction from using GetJson method output. These tests will fail:

[TestMethod]
        public void TestTransferTransactionFromJson()
        {
            var tx = new TransferTransaction(Accounts.Alice.PublicKey, Accounts.Bob.Address, Assets.WAVES, 0.1m);
            var jsonDict = tx.GetJson();

            var deserializedTx = Transaction.FromJson(jsonDict);
        }
[TestMethod]
        public void TestTransferTransactionJsonConstructor()
        {
            var tx = new TransferTransaction(Accounts.Alice.PublicKey, Accounts.Bob.Address, Assets.WAVES, 0.1m);
            var jsonDict = tx.GetJson();

            var deserializedTx = new TransferTransaction(jsonDict);
        }

Since GetJson method does not add “sender” value which is now required by deserializing constructor.

Hi,
Thanks for your report. We’ve fixed this problem and updated the NuGet package (v. 1.1.0.7).

We published new NuGet package version 1.1.1.1:

  • Add smart assets
  • Add cancelAll transaction
1 Like

We published new NuGet package version 1.1.1.2:

  • Fix some bugs with JSON without “sender” field

Hello !

Can i see anywere short list of all WavesCs functons ?
like this:

var asset = node.GetAsset(string );
int balance = node.GetBalance(string address,asset);
var account = PrivateKeyAccount.CreateFromPrivateKey(privateKey, AddressEncoding.MainNet);
node.Transfer(account, string recipient, asset, int x);

etc
???

Hi,

It would be nice to have official .Net Standard targetting solution to be able to use this lib with Xamarin.Forms
I had to recompile this solution myself with some quick modifications to make it work for my mobile project.

Thanx

We published new NuGet package version 1.1.5:

  • Fix fee calculation and TransferTransaction.GenerateId()
  • Add MassTransfer with recipients list from file
  • Add SetAssetScript and SetScript implementations to Node class
  • Add FastHash and SecureHash implementations to Node class
  • Add GetUnconfirmedTransactions function
  • Add CalculateFee function
  • Delete GetById function from Asset class and replace it to Node.GetAsset function
  • Add GetTransactionByIdOrNull function
  • Add BroadcastAndWait function
  • Delete DefaultNode and change this mechanism to always getting node by chainId
  • Add new Node constructor
  • Add version field to all transaction type with correct latest default version
  • Add GetFlatObjectsWithHeaders to Http class
  • Add GenerateBinaryId method
  • Add GetTransactionsByAddressAfterId and GetTransactionsByAddressAfterTimestamp methods to Node class
  • Add TransactionCount method to Node class (by block’s height)

We published new NuGet package version 1.1.6:

  • Add possibility to get the Waves balance with GetBalance(asset)
  • Add methods:
    • GetTransactionHeight
    • WaitForTransactionConfirmation
    • GetTransactiosByAddressAfterId and
    • GetTransactionsByAddressAfterTimestamp
  • Implement InvokeScriptTransaction

Hello. I’m new to waves platform, I setup our own waves node, for I’m creating a web wallet for my stablecoin project. Basically, I will create a wallet address for every user who signs up in our app. I’m reviewing your source codes and I’m wondering why you didn’t use the “/addresses” post method anywhere in your codes to generate a wallet address. How do you accomplish it using your existing library.

I modified the node.cs to use a custom node instead of using only either the testnode or mainnet.