Alexandria.NET library for SophiaTX blockchain
-
As a prerequisite for the nuget package to work, please have openssl installed on your machine (download openssl and install on Windows environment using https://slproweb.com/products/Win32OpenSSL.html) ("brew install openssl" on Mac environment)
-
Get the latest nuget package from nuget.org (https://www.nuget.org)
-
Please select the package depending on your platform requirements 64 or 32 (x86) bit.
-
Add the nuget package into the project (using Nuget Package Manager)
-
Rebuild the project and use the below mentioned functions to get connected with SophiaTX Blockchain
protected readonly SophiaClient _client = new SophiaClient(IpAddress, DemonPort, WalletPort);
Get Feed History
_client.Transaction.GetFeedHistory(CurrencySymbol);
Get details about the Blockchain
_client.Transaction.About();
Get a list of functions and How-To available on the sophia blockchain
_client.Transaction.Help();
Get recent transaction and block information on the blockchain
_client.Transaction.Info();
Get block infromation using blockId
_client.Transaction.GetBlock(blockNumber);
Get operations from a block
_client.Transaction.GetOpsInBlock(blockNumber, onlyVirtual);
Get Transaction details
var trx=_client.Transaction.GetTransaction(transactionId);
Generate Private Key and Public Key pair
_client.Key.GeneratePrivateKey(new byte[51], new byte[53]);
Get public key using private key
_client.Key.GetPublicKey(privateKey, new byte[53]);
Encrypt Memo with private key and receiver's public key for sending secure data across the blockchain
_client.Key.EncryptMemo(memo, PrivateKey, PublicKey2, new byte[1024]);
Decrypt the received using private key and sender's public key
_client.Key.DecryptMemo(encryptedMemo, PrivateKey2, PublicKey, new byte[1024]);
Send JSON data to list of recepients
var test = "{\"new_book_name\":\"test9999\"}";
var data = new SenderData
{
AppId = 2,
PrivateKey = PrivateKey,
Recipients = new List<string> {accountName1, acocuntName2},
Sender = accountName,
JsonDoc = test
};
_client.Data.SendJson(data);
Send plain text to list of recepients
var data = new SenderData
{
AppId = 2,
PrivateKey = PrivateKey,
Recipients = new List<string> {accountName1, acocuntName2},
Sender = accountName,
BinaryDoc = memo
};
_client.Data.SendBinary(data);
Send JSON data to list of recipients asynchronously
var test = "{\"new_book_name\":\"test9999\"}";
var data = new SenderData
{
AppId = 2,
PrivateKey = PrivateKey,
Recipients = new List<string> {accountName1, acocuntName2},
Sender = accountName,
JsonDoc = test
};
_client.Data.SendJsonAsync(data);
Send plain text to list of recipients asynchronously
var data = new SenderData
{
AppId = 2,
PrivateKey = PrivateKey,
Recipients = new List<string> {accountName1, acocuntName2},
Sender = accountName,
BinaryDoc = memo
};
_client.Data.SendBinaryAsync(data);
List recieved documents, sorted depending on the search type, start(ISOTimeStamp)
_client.Data.Receive(AppID, accountName, SearchType, start, numberOfEntries);
Create account using private key. Same public key can be used for all three keys required to create accoun.
Seed, can be any unique value string (have atleast 3 digits and no special characters ($, £, #, etc.)) for genrating new account name.
Creator, is an account with enough balance to pay for account creation.
_client.Account.CreateAccount(seed, jsonData, ownerKey, activeKey, memoKey, creator, creatorPrivateKey);
Get account details
_client.Account.GetAccount(accountName);
Delete account
_client.Account.DeleteAccount(accountName, PrivateKey);
Update account keys and JSON details
_client.Account.UpdateAccount(accountName, jsonData, ownerKey, activeKey, memoKey, privateKey);
Get account history
_client.Account.GetAccountHistory(accountName, from, limit);
Get account name from seed (used to create account)
_client.Account.GetAccountNameFromSeed(accountName);
Get account vesting balance
_client.Account.GetVestingBalance(accountName);
Get account balance
_client.Account.GetAccountBalance(accountName);
Check if account still exists
_client.Account.AccountExists(accountName);
Get account authority key
_client.Account.GetActiveAuthority(accountName);
Get account memo key
_client.Account.GetMemoKey(accountName);
Get account owner key
_client.Account.GetOwnerAuthority(accountName);
Create simple multi-signature authority
var pubkeys = new List<string> {publicKey1, publicKey2};
_client.Account.CreateSimpleMultisigAuthority(pubkeys, requiredSignatures);
Create simple managing authority
_client.Account.CreateSimpleManagedAuthority(managingAccountName);
Create simple multi-signature managing authority
var pubkeys = new List<string> {publicKey1, publicKey2};
_client.Account.CreateSimpleMultiManagedAuthority(pubkeys, requiredSignatures);
Transfer amount (argument in the format "250000.00 SPHTX") from one to other account
_client.Asset.Transfer(accountName, beneficiaryAccountName, amount, memo, privateKey);
Withdraw amount (argument in the format "250000.00 SPHTX") vesting account balance
_client.Asset.WithdrawVesting(acocuntName, ammount, PrivateKey);
Transfer amount to vesting account
_client.Asset.TransferToVesting(accountName, beneficiaryAccountName, amount, privateKey);
Get Active Witnesses
_client.Witness.GetActiveWitnesses();
Get List of all witnesses
_client.Witness.ListWitnesses(witnessName, numberOfEntries);
Get details of a witness
_client.Witness.GetWitness(witnessName);
Become a witness, price feed example can be as
var feed1 = new List<PrizeFeedQuoteMessage>
{
new PrizeFeedQuoteMessage
{
Currency = "USD",
PrizeFeedQuote = new PrizeFeedQuote {Base = "1 USD", Quote = "0.152063 SPHTX"}
}
};
var feed2= new List<PrizeFeedQuoteMessage>
{
new PrizeFeedQuoteMessage
{
Currency = "EUR",
PrizeFeedQuote = new PrizeFeedQuote {Base = "1 EUR", Quote = "0.154988 SPHTX"}
}
};
var pricefeed=new List<List<PrizeFeedQuoteMessage>>{feed1,feed2};
_client.Witness.UpdateWitness(accountName, url, blockSigningKey, accountCreationFee, minimumBlockSize, pricefeed, privateKey);
Set voting proxy
_client.Account.SetVotingProxy(accountName, proxyAccountName, PrivateKey);
Vote for a witness
_client.Witness.VoteForWitness(accountName, witnessName, voteType, privateKey);
Create application (the price parameter that specifies billing for the app (1 or 0))
_client.Application.CreateApplication(accountName, applicationName, URL, jsonData, priceParam, PrivateKey);
Update application
_client.Application.UpdateApplication(accountName, applicationName, URL, jsonData, priceParam, PrivateKey);
Delete application
_client.Application.DeleteApplication(accountName, applicationName, PrivateKey);
Buy Application
_client.Application.BuyApplication(accountName, appId, PrivateKey);
Cancel Application purchase
_client.Application.CancelApplicationBuying(sellerAccountName, buyerAccountName, appId, PrivateKey);
Get a list of all bought application and sorting is done depending on search type (bySeller or byBuyer)
_client.Application.GetApplicationBuyings(accountName, SearchType, numberOfEntries);
Get details of list of applications
var names = new List<string>{applicationName1, applicationName2};
_client.Application.GetApplications(names);
Call methods from different Api.
var args = new argumentObject(){};
_client.Transaction.CallPlugin(ApiName,MethodName,args);