static int RunSpendAndReturnExitCode(SpendOptions opts) { // get asset details and calc fee in asset units var node = new Node(); var asset = new Node().GetAsset(ASSET_ID); var assetDetails = node.GetObject($"assets/details/{ASSET_ID}"); decimal minFee = new Decimal(Convert.ToInt32(assetDetails["minSponsoredAssetFee"])); var decimals = Convert.ToInt32(assetDetails["decimals"]); var fee = minFee / (int)Math.Pow(10, decimals); System.Diagnostics.Debug.Assert(fee < 1, "fee sponsorship is too expensive!!!"); // get account var account = GetAccount(opts.Seed, opts.Base58); Console.WriteLine($"Source Address: {account.Address}"); // encode attachment byte[] attachment = null; if (!string.IsNullOrEmpty(opts.Attachment)) { attachment = Encoding.UTF8.GetBytes(opts.Attachment); Console.WriteLine($"Base58 Attachment: {opts.Attachment} ({attachment.Length})"); } // create transaction to transfer our asset (using fee sponsorship) var tx = new TransferTransaction(account.PublicKey, DateTime.UtcNow, opts.Recipient, asset, opts.Amount, fee, asset, attachment); tx.Sign(account); Console.WriteLine("Transaction:"); Console.WriteLine(JsonConvert.SerializeObject(tx, Formatting.Indented)); // broadcast the transaction Console.WriteLine("Broadcasting transaction..."); Console.WriteLine(node.Broadcast(tx)); return(0); }