public TideResponse CreateAccount(string publicKey, string username, bool seed = false) { try { var usernameHash = username.ConvertToUint64(); var account = $"tide{Helpers.RandomString(8)}"; var result = _eos.CreateTransaction(new Transaction { Actions = new List <Action> { new Action { Account = _settings.Onboarding, Authorization = new List <PermissionLevel> { new PermissionLevel { Actor = _settings.Account, Permission = "active" } }, Name = "adduser", Data = new { account, username = usernameHash } } } }).Result; _logger.LogMsg("Created user account"); return(new TideResponse(true, account, null)); } catch (Exception e) { _logger.LogMsg("Failed creating user account", ex: e); return(new TideResponse(false, e, "Failed creating user account.")); } }
public async Task PushTransaction() { try { await Scatter.Connect(); await Scatter.GetIdentity(new IdentityRequiredFields() { accounts = new List <ScatterSharp.Core.Api.Network>() { network }, location = new List <LocationFields>(), personal = new List <PersonalFields>() }); var eos = new Eos(new EosSharp.Core.EosConfigurator() { ChainId = network.chainId, HttpEndpoint = network.GetHttpEndpoint(), SignProvider = new ScatterSignatureProvider(Scatter) }); var account = Scatter.Identity.accounts.First(); var result = await eos.CreateTransaction(new EosSharp.Core.Api.v1.Transaction() { actions = new List <EosSharp.Core.Api.v1.Action>() { new EosSharp.Core.Api.v1.Action() { account = "eosio.token", authorization = new List <PermissionLevel>() { new PermissionLevel() { actor = account.name, permission = account.authority } }, name = "transfer", data = new Dictionary <string, string>() { { "from", account.name }, { "to", "auaglobalts5" }, { "quantity", "0.1000 EOS" }, { "memo", "" } } } } }); Console.WriteLine(JsonConvert.SerializeObject(result)); } catch (Exception ex) { Console.WriteLine(JsonConvert.SerializeObject(ex)); Assert.Fail(); } }
public async void PushTransaction() { try { ScatterSharp.Core.Api.Network network = new ScatterSharp.Core.Api.Network() { blockchain = ScatterConstants.Blockchains.EOSIO, host = "nodes.eos42.io", port = 443, chainId = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906" }; var fileStorage = new FileStorageProvider(Application.persistentDataPath + "/scatterapp.dat"); using (var scatter = new Scatter(new ScatterConfigurator() { AppName = "UNITY-WEBGL-SCATTER", Network = network, StorageProvider = fileStorage }, this)) { await scatter.Connect(); await scatter.GetIdentity(new IdentityRequiredFields() { accounts = new List <ScatterSharp.Core.Api.Network>() { network }, location = new List <LocationFields>(), personal = new List <PersonalFields>() }); var eos = new Eos(new EosSharp.Core.EosConfigurator() { ChainId = network.chainId, HttpEndpoint = network.GetHttpEndpoint(), SignProvider = new ScatterSignatureProvider(scatter) }); var account = scatter.Identity.accounts.First(); var result = await eos.CreateTransaction(new EosSharp.Core.Api.v1.Transaction() { actions = new List <EosSharp.Core.Api.v1.Action>() { new EosSharp.Core.Api.v1.Action() { account = "eosio.token", authorization = new List <PermissionLevel>() { new PermissionLevel() { actor = account.name, permission = account.authority } }, name = "transfer", data = new Dictionary <string, object>() { { "from", account.name }, { "to", "eosio" }, { "quantity", "0.0001 EOS" }, { "memo", "Unity3D WEBGL hello crypto world!" } } } } }); print(result); } } catch (Exception ex) { print(JsonConvert.SerializeObject(ex)); } }
public async void PushTransaction() { try { ScatterSharp.Core.Api.Network network = new ScatterSharp.Core.Api.Network() { blockchain = ScatterConstants.Blockchains.EOSIO, host = "jungle3.cryptolions.io", port = 443, chainId = "2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840" }; var fileStorage = new FileStorageProvider(Application.persistentDataPath + "/scatterapp.dat"); using (var scatter = new Scatter(new ScatterConfigurator() { AppName = "UNITY-PC-SCATTER", Network = network, StorageProvider = fileStorage }, this)) { await scatter.Connect(); await scatter.GetIdentity(new IdentityRequiredFields() { accounts = new List <ScatterSharp.Core.Api.Network>() { network }, location = new List <LocationFields>(), personal = new List <PersonalFields>() }); var eos = new Eos(new EosSharp.Core.EosConfigurator() { ChainId = network.chainId, HttpEndpoint = network.GetHttpEndpoint(), SignProvider = new ScatterSignatureProvider(scatter) }); var account = scatter.Identity.accounts.First(); var result = await eos.CreateTransaction(new EosSharp.Core.Api.v1.Transaction() { actions = new List <EosSharp.Core.Api.v1.Action>() { new EosSharp.Core.Api.v1.Action() { account = "eosio.token", authorization = new List <PermissionLevel>() { new PermissionLevel() { actor = account.name, permission = account.authority } }, name = "transfer", data = new Dictionary <string, object>() { { "from", account.name }, { "to", "eosio" }, { "quantity", "0.0001 EOS" }, { "memo", "Unity3D WEBGL hello crypto world!" } } } } }); print(result); } } catch (ApiErrorException ex) { print(JsonConvert.SerializeObject(ex.error)); } catch (ApiException ex) { print(ex.Content); } catch (Exception ex) { print(JsonConvert.SerializeObject(ex)); } }
public async Task <string> PurchaseTicket(Eos eos, int drawNumber, int[] ticket, string actionAccount, string actor, string ticketPurchaser) { string result = ""; int attempt = 1; while (string.IsNullOrEmpty(result)) { try { result = await eos.CreateTransaction(new Transaction() { actions = new List <EosSharp.Core.Api.v1.Action>() { new EosSharp.Core.Api.v1.Action() { account = actionAccount, authorization = new List <PermissionLevel>() { new PermissionLevel() { actor = actor, permission = "active" } }, name = "createticket", data = new { purchaser = ticketPurchaser, drawnumber = drawNumber, entrynumbers = ticket, genreward = false, } } } }); if (SendLogToConsole) { Console.WriteLine($"Attempt {attempt}, CreateTicket -> Thread Id : {Thread.CurrentThread.ManagedThreadId}, Transaction Id : {result}"); } } catch (ApiErrorException ex) { if (SendLogToConsole) { Console.WriteLine($"Error.Name: {ex.error.name}, Error.What {ex.error.what}, Ticket {TicketAsString(ticket)}"); foreach (var err in ex.error.details) { Console.WriteLine($"Message: {err.message}"); } } } catch (Exception ex) { if (SendLogToConsole) { Console.WriteLine($"{ex.Message}. Ticket {TicketAsString(ticket)}, Inner Exception {ex.InnerException}"); } } if (++attempt > MaxAttempts) { break; } } return(result); }