static void Main(string[] args) { //V2.BasicExample.Main(args); return; //V2.AssetExample.Main(args); return; //V2.AtomicTransferExample.Main(args); return; //V2.contract.CompileTeal.Main(args); return; V2.contract.ContractAccount.Main(args); return; //V2.contract.LogicSignature.Main(args); return; //V2.contract.DryrunDedugging.Main(args); return; //V2.IndexerExamples.Main(args); return; //V2.RekeyExample.Main(args); return; //V2.AccountTest.Main(args); return; //V2.contract.DryrunStatefulExample.Main(args); return; //V2.contract.StatefulContract.Main(args); return; //AssetExample.Main(args); return; //BidExample.Main(args); return; //GroupSigExample.Main(args); return; //LogicSigExample.Main(args); return; //MultisigExample.Main(args); return; // the SDK also support purestake, just use the two lines below replace the line 28~32 //string ALGOD_API_ADDR = "https://testnet-algorand.api.purestake.io/ps1"; //string ALGOD_API_TOKEN = "YOUR API PURESTAKE KEY"; // If the protocol is not specified in the address, http is added. string ALGOD_API_ADDR = args[0]; if (ALGOD_API_ADDR.IndexOf("//") == -1) { ALGOD_API_ADDR = "http://" + ALGOD_API_ADDR; } string ALGOD_API_TOKEN = args[1]; string SRC_ACCOUNT = "typical permit hurdle hat song detail cattle merge oxygen crowd arctic cargo smooth fly rice vacuum lounge yard frown predict west wife latin absent cup"; string DEST_ADDR = "7XVBE6T6FMUR6TI2XGSVSOPJHKQE2SDVPMFA3QUZNWM7IY6D4K2L23ZN2A"; if (!Address.IsValid(DEST_ADDR)) { Console.WriteLine("The address " + DEST_ADDR + " is not valid!"); } Account src = new Account(SRC_ACCOUNT); Console.WriteLine("My account address is:" + src.Address.ToString()); if (src.ToMnemonic() != SRC_ACCOUNT) { Console.WriteLine("ToMnemonic function is wriong!"); } //sign and verify bytes function test var bytes = Encoding.UTF8.GetBytes("examples"); var siguture = src.SignBytes(bytes); Address srcAddr = new Address(src.Address.ToString()); var verifyed = srcAddr.VerifyBytes(bytes, siguture); AlgodApi algodApiInstance = new AlgodApi(ALGOD_API_ADDR, ALGOD_API_TOKEN); try { Supply supply = algodApiInstance.GetSupply(); Console.WriteLine("Total Algorand Supply: " + supply.TotalMoney); Console.WriteLine("Online Algorand Supply: " + supply.OnlineMoney); } catch (ApiException e) { Console.WriteLine("Exception when calling algod#getSupply:" + e.Message); } try { TransactionParams trans = algodApiInstance.TransactionParams(); var lr = (long?)trans.LastRound; Block block = algodApiInstance.GetBlock((long?)trans.LastRound); Console.WriteLine("Lastround: " + trans.LastRound.ToString()); Console.WriteLine("Block txns: " + block.Txns.ToJson()); } catch (ApiException e) { Console.WriteLine("Exception when calling algod#getSupply:" + e.Message); } TransactionParams transParams = null; try { transParams = algodApiInstance.TransactionParams(); } catch (ApiException e) { throw new Exception("Could not get params", e); } var amount = Utils.AlgosToMicroalgos(1); var tx = Utils.GetPaymentTransaction(src.Address, new Address(DEST_ADDR), amount, "pay message", transParams); //Transaction tx = new Transaction(src.Address, new Address(DEST_ADDR), amount, firstRound, lastRound, genesisID, genesisHash); var signedTx = src.SignTransaction(tx); Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID); // send the transaction to the network try { var id = Utils.SubmitTransaction(algodApiInstance, signedTx); Console.WriteLine("Successfully sent tx with id: " + id.TxId); Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, id.TxId)); } catch (ApiException e) { // This is generally expected, but should give us an informative error message. Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message); } Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist."); Console.ReadKey(); }
/// <summary> /// Creates new message call transaction on the block chain, gets the transaction /// receipt, and returns the first (oldest) event log of the given type. /// </summary> /// <returns>Throws exception if not found.</returns> public async Task <TEventLog> FirstEventLog <TEventLog>(TransactionParams transactionParams = null) where TEventLog : EventLog { var transaction = await TransactionReceipt(transactionParams); return(transaction.FirstEventLog <TEventLog>()); }
static void Main(string[] args) { AlgodApi algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab"); TransactionParams transparams = null; try { transparams = algodApiInstance.TransactionParams(); } catch (ApiException err) { throw new Exception("Could not get params", err); } //4CLRLFJQK3WKEIHKOYTFJ5TT7W2KKQJQUXVJM4GZYLOHG5FC3C3PNF5XMQ var acc1 = "4CLRLFJQK3WKEIHKOYTFJ5TT7W2KKQJQUXVJM4GZYLOHG5FC3C3PNF5XMQ"; var acc2 = "AE47UNNWHF2XCVFF4DAB7WPHKKNL5MFEW2YQ6DTK3HYNGO4GCG32WQAA5I"; //AE47UNNWHF2XCVFF4DAB7WPHKKNL5MFEW2YQ6DTK3HYNGO4GCG32WQAA5I var Key = "brain under subject brown letter select auto artwork inject display reflect clerk index prosper trick host true stable fork tone drum please loud abstract reject"; Account account = new Account(); Console.WriteLine(account.Address.ToString()); //Console.WriteLine($"{account.Address.ToString()} and {account.ToMnemonic()}"); //brain under subject brown letter select auto artwork inject display reflect clerk index prosper trick host true stable fork tone drum please loud abstract reject //LLMTMNBRXUF5ARJZLYYJEJPVOGDJ2SBYOHQDWXHOPIODS6ANXBL4S6BECE //var accountAddress = "LLMTMNBRXUF5ARJZLYYJEJPVOGDJ2SBYOHQDWXHOPIODS6ANXBL4S6BECE"; //var accountInfo = algodApiInstance.AccountInformation("LLMTMNBRXUF5ARJZLYYJEJPVOGDJ2SBYOHQDWXHOPIODS6ANXBL4S6BECE"); //Console.WriteLine($"The address {accountAddress} has a Balance of: {accountInfo.Amount} microAlgos"); ////Let's create a grouped transaction //var amount = Utils.AlgosToMicroalgos(1); //var tx1 = Utils.GetPaymentTransaction(new Address(accountAddress), new Address(acc1), amount, "Perfoming First Grouped Transactions", transparams); //var tx2 = Utils.GetPaymentTransaction(new Address(accountAddress), new Address(acc2), amount, "Perfoming Second Grouped Transactions", transparams); //Digest gid = TxGroup.ComputeGroupID(new Algorand.Transaction[] { tx1, tx2 }); //tx1.AssignGroupID(gid); //tx2.AssignGroupID(gid); //var signedTx1 = account.SignTransaction(tx1); //var signedTx2 = account.SignTransaction(tx2); //try //{ // List<byte> byteList = new List<byte>(Algorand.Encoder.EncodeToMsgPack(signedTx1)); // byteList.AddRange(Algorand.Encoder.EncodeToMsgPack(signedTx2)); // var acc = algodApiInstance.AccountInformation(accountAddress); // var before = $"Account 1 Balance before: {acc.Amount.ToString()}"; // var id = algodApiInstance.RawTransaction(byteList.ToArray()); // var wait = Utils.WaitTransactionToComplete(algodApiInstance, id.TxId); // Console.WriteLine(wait); // Console.WriteLine($"Transfer sent to Tx group with id: {id}"); // acc = algodApiInstance.AccountInformation(accountAddress.ToString()); //} //catch(ApiException err) //{ // Console.WriteLine($"Exception when calling algodrawtransactions: {err.Message}"); //} }
public Task <Hash> SendTransaction(TransactionParams transactionParams) { throw new NotImplementedException(); }
public virtual Task <Hash> SendTransaction(TransactionParams transactionParams) { return(_proxyClient.SendTransaction(transactionParams)); }
// GET: BuyGames/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var buyGame = await _context.BuyGame .SingleOrDefaultAsync(m => m.Id == id); AlgodApi algodApiInstance = new AlgodApi("https://testnet-algorand.api.purestake.io/ps1", "B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab"); //BuyerMnemonnic Account src = new Account("ordinary certain payment annual plate slot squeeze recycle neck whip transfer cat photo error bus frost magnet arrange filter used soon medal liquid abstract father"); //Console.WriteLine(account3.Address.ToString()); //var c = "AJ7GLWNUT6TEJYUGNYAZQ7342TK7DBZLWBMIMK3NBN6NZCWJHLNYCRYQ7I"; var buyerAddress = "36DTG5ITNWLAVZBSZ6BXPWP7UTSPEOL3K4HWIEUYML7RKUCBZQP5XBR7XY"; var b = "EUFD3MONZCV6P65OHVHDTDY2B7OYALLNDORL2GJPB4RATJB4K2O3CUUVOU"; var c = "OQIM6O74DXB454SCLT7KH7GJ5HJJE6DQDPPW6JNPVSRZ6RU4GVQMGKTH2Q"; //Console.WriteLine(account1.Address.ToString()); //Console.WriteLine(account2.Address.ToString()); var accountInfo = algodApiInstance.AccountInformation(c.ToString()); Console.WriteLine(string.Format($"Account Balance: {0} microAlgos", accountInfo.Amount)); var acts = algodApiInstance.AccountInformation(buyerAddress.ToString()); var befores = "Account 1 balance before: " + acts.Amount.ToString(); Console.WriteLine(acts); Console.WriteLine(befores); TransactionParams transParams = null; try { transParams = algodApiInstance.TransactionParams(); } catch (ApiException err) { throw new Exception("Could not get params", err); } var amount = Utils.AlgosToMicroalgos(1); var tx = Utils.GetPaymentTransaction(new Address(buyerAddress), new Address(b), amount, "pay message", transParams); var signedTx = src.SignTransaction(tx); Console.WriteLine("Signed transaction with txid: " + signedTx.transactionID); // send the transaction to the network try { var ids = Utils.SubmitTransaction(algodApiInstance, signedTx); Console.WriteLine("Successfully sent tx with id: " + ids.TxId); Console.WriteLine(Utils.WaitTransactionToComplete(algodApiInstance, ids.TxId)); } catch (ApiException e) { // This is generally expected, but should give us an informative error message. Console.WriteLine("Exception when calling algod#rawTransaction: " + e.Message); } Console.WriteLine("You have successefully arrived the end of this test, please press and key to exist."); Console.ReadKey(); if (buyGame == null) { return(NotFound()); } return(View(buyGame)); }
/// <summary> /// Performs first an RPC call to get the function return value, then an RPC sendTransaction and getTransactionReceipt. /// </summary> public async Task <(TReturn Result, TransactionReceipt Receipt)> CallAndTransact(TransactionParams transactionParams = null) { transactionParams = _contract.GetTransactionParams(transactionParams); transactionParams.Data = _callData; var callParams = _contract.GetCallParams(new CallParams { Data = transactionParams.Data, From = transactionParams.From, Gas = transactionParams.Gas, GasPrice = transactionParams.GasPrice, To = transactionParams.To, Value = transactionParams.Value }); callParams.Data = _callData; var result = await Call(callParams); var receipt = await TransactionReceipt(transactionParams); return(result, receipt); }
/// <summary> /// Creates new message call transaction on the block chain, gets the transaction /// receipt, and returns all event logs that can be matched to an event type. /// Unmatched logs are left out of the result. /// </summary> public async Task <EventLog[]> EventLogs(TransactionParams transactionParams = null) { var transaction = await TransactionReceipt(transactionParams); return(EventLogUtil.EventLogs(transaction)); }
public async Task <IActionResult> GetAllTransactions([FromQuery] TransactionParams param) { return(HandlePageResult(await Mediator.Send(new TransactionList.Query { Params = param }))); }