Although my current Steemit project is frozen (I wrote about that already in the above-mentioned post), I decided to finish at least this library to enable other .NET developers bringing their idea to life. So here we go, SteemConnect.Net is available both as a Nuget package and on Github.
The library is built as .NetStandard (2.0) library. Every operation sent to the blockchain returns a transaction object. Should the API return an error, the response will contain the error message coming from the blockchain.
Let's have a quick look how to get started:
Initialize Library:
Config.Instance.Init("APIKEY", "APISECRET", "CALLBACK");
Create Login-Url:
var scopes = new string[] { Constants.PARAM_ACTION_OFFLINE, Constants.PARAM_ACTION_LOGIN, Constants.PARAM_ACTION_VOTE, Constants.PARAM_ACTION_COMMENT, Constants.PARAM_ACTION_CUSTOMJSON, Constants.PARAM_ACTION_DELETECOMMENT, Constants.PARAM_ACTION_COMMENT_OPTIONS, Constants.PARAN_ACTION_CLAIMREWARDBALANCE };
var loginUrl = Authentication.GetLoginUrl(scopes, null, true);
The call to the loginUrl will show the login dialog to the user and return your callback url with the login code. Just pass this response as is to GetAccessTokenAsync method.
Get AccessToken
SteemConnectEntity<AccessTokenResponse> accessTokenResponse = await Authentication.GetAccessTokenAsync(response, true);
This will return an AccessToken as well as a RefreshToken. It is your task to save them securely in your app or website.
Get user data
After obtaining the AccessToken, you can fetch the user data:
SteemConnectEntity<User> user = await SteemConnectRequest.GetUserDataAsync(AccessTokenResponse.Value.Accesstoken);
Create a new post with additional options
var meta = JsonConvert.SerializeObject(new BroadcastMetaData("DEV_APP/0.0.1", "busy", new string[] { "test", "dev", "testing" }, PostFormat.MarkDown));
var beneficiaries = new BeneficiariesExtension();
beneficiaries.Beneficiaries.Add(new Beneficiary("beneficiary", 5000));
var permlink = "qs-app-dev-test-" + DateTime.Now.Ticks.ToString();
var commentOptions = new CommentOptions(username, permlink, false, 1000, 0, true, null);
var post = await SteemConnectRequest.CreateNewCommentAsync(AccessTokenResponse.Value.Accesstoken, string.Empty, "test", username, permlink, "Post Title", "Post Body ", meta, commentOptions);
There is no full documentation yet, I am working on that. However, the repository on Github contains a console test program that should help everyone to figure everything out.
Even if the main project that has lead to this library is frozen for the moment, I do have some ideas left. I will use this library for sure, but felt it is the right time to make it avalaible for all that want to use it.
If you have questions or need help, feel free to open an issue on Github or ping me here on Steemit. If you want to contribute, feel free to open a pull request with your changes as well.