Exemplo n.º 1
0
        /// <summary>
        /// Send Asset Method
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        public async Task <Tuple <string, string> > Send(Address myaddress, Address opponetaddress, decimal amount)
        {
            var client     = SetClient();
            var generalApi = new GeneralApi(client);
            var from       = myaddress;
            var to         = opponetaddress;

            System.Diagnostics.Debug.WriteLine(myaddress);
            System.Diagnostics.Debug.WriteLine(opponetaddress);
            System.Diagnostics.Debug.WriteLine(amount);
            var privatekey = new[] { PrivateKey.Parse("263b6a4606168f64aca7c5ac1640ecb52a36142b0d96b07cb520de2eb4d237e5") };

            System.Diagnostics.Debug.WriteLine(PrivateKey.Parse("263b6a4606168f64aca7c5ac1640ecb52a36142b0d96b07cb520de2eb4d237e5"));
            // enter the send amount
            var moveCoin = new AssetMove(TableName, amount, from, to);

            System.Diagnostics.Debug.WriteLine(moveCoin);
            var move = new ITransactionEntry[] { moveCoin };

            System.Diagnostics.Debug.WriteLine(move);
            Transaction tx = TransactionCreator.SimpleSignedTransaction(moveCoin, privatekey);

            await this.SendTransaction(tx);

            var result = await Utils.WaitTx(generalApi, tx.Id);

            return(new Tuple <string, string>(tx.Id.ToString(), result));
        }
Exemplo n.º 2
0
 public async Task Send(decimal amount, Address to)
 {
     var from     = GetAddress();
     var moveCoin = new AssetMove("CookiePoint", amount, from, to);
     var tx       = TransactionCreator.SimpleSignedTransaction(
         new ITransactionEntry[] { moveCoin },
         new [] { _keyPair.PrivateKey });
     await _transactionService.SendTransaction(tx);
 }
Exemplo n.º 3
0
            /**
             * Mint asset to Alice address
             */
            async Task <string> GenerateAsset()
            {
                var aliceAddress  = _aliceWallet.GetAddress();
                var generateAsset = new AssetGen(TOKEN_NAME, 1000000m, aliceAddress);
                var memo          = new MemoEntry(new[] { "Generate 1000000m CookiePoints." });

                var tx = TransactionCreator.SimpleSignedTransaction(
                    new ITransactionEntry[] { generateAsset, memo },
                    new[] { _aliceWallet.GetPrivateKey() });

                await _transactionService.SendTransaction(tx);

                return(tx.Id.ToString());
            }
Exemplo n.º 4
0
        /// <summary>
        /// Generation Asset
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        public static async Task <string> Assetgenerate(IClient client)
        {
            //Asset infomation
            var generateAsset = new AssetGen(TableName, 1000000m,
                                             new PublicKeyAddress(Utils.GetUser0KeyPair().PublicKey));

            var tx = TransactionCreator.SimpleSignedTransaction(
                new ITransactionEntry[] { generateAsset },
                new[] { Utils.GetOwnerKeyPair().PrivateKey });


            await SendTransaction(tx);

            return(tx.Id.ToString());;
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Make NFT Table Method
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        private static async Task <string> CreateNFTTable(IClient client)
        {
            //Get PublicKey from Utils's GetOwnerKeyPair()
            var tableownerAddress = new PublicKeyAddress(Utils.GetOwnerKeyPair().PublicKey);
            var assetTable        = new CreateTable(new NFTTableDescriptor(
                                                        TableName, false, false, new[] { tableownerAddress }));

            //var memo = new MemoEntry(new[] { "NFT_TEST" });
            var tx = TransactionCreator.SimpleSignedTransaction(
                new ITransactionEntry[] { assetTable },
                new[] { Utils.GetTableAdminKeyPair().PrivateKey });

            await SendTransaction(tx);

            return(tx.Id.ToString());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Send Asset Method
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        public static async Task <string> Send(IClient client)
        {
            var from = new PublicKeyAddress(Utils.GetUser0KeyPair());
            var to   = new PublicKeyAddress(Utils.GetUser1KeyPair());

            var amount = Inputjudgement();

            var moveCoin = new AssetMove(TableName, amount, from, to);
            var tx       = TransactionCreator.SimpleSignedTransaction(
                new ITransactionEntry[] { moveCoin },
                new [] { Utils.GetUser0KeyPair().PrivateKey });

            await SendTransaction(tx);

            return(tx.Id.ToString());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Generation NFT
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        public static async Task <string> NFTgenerate(IClient client)
        {
            //Asset infomation
            Console.WriteLine("Please Types NFT TokenID");
            string Tokenid     = Console.ReadLine();
            var    generateNFT = new NFTAdd(TableName, Tokenid,
                                            new PublicKeyAddress(Utils.GetUser0KeyPair().PublicKey));

            var tx = TransactionCreator.SimpleSignedTransaction(
                new ITransactionEntry[] { generateNFT },
                new[] { Utils.GetOwnerKeyPair().PrivateKey });


            await SendTransaction(tx);

            return(tx.Id.ToString());;
        }
Exemplo n.º 8
0
            /**
             * Create the Asset table for Alice.
             */
            async Task <string> CreateTable()
            {
                var aliceAddress = _aliceWallet.GetAddress();

                // Create a new asset table with alice's address set as a owner.
                // A Table admin key is required to send this transaction.
                var assetTable = new CreateTable(new AssetTableDescriptor(
                                                     TOKEN_NAME, false, false, new[] { aliceAddress }));
                var memo = new MemoEntry(new[] { "Point system for Alice's shops" });

                var tx = TransactionCreator.SimpleSignedTransaction(
                    new ITransactionEntry[] { assetTable, memo },
                    new[] { PrivateKey.Parse(TABLE_ADMIN_PRIVATE_KEY) });

                await _transactionService.SendTransaction(tx);

                return(tx.Id.ToString());
            }
Exemplo n.º 9
0
        /// <summary>
        /// Send Asset Method
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        public async Task <Tuple <string, string> > Send(KeyPair formerprivatekey, Address myaddress, Address opponetaddress, decimal amount)
        {
            var client     = this.SetClient();
            var generalApi = new GeneralApi(client);
            var from       = myaddress;
            var to         = opponetaddress;

            // enter the send amount
            var moveCoin = new AssetMove(TableName, amount, from, to);
            var tx       = TransactionCreator.SimpleSignedTransaction(
                new ITransactionEntry[] { moveCoin },
                new[] { formerprivatekey.PrivateKey });

            await this.SendTransaction(tx);

            var result = await WaitTx(generalApi, tx.Id);

            return(new Tuple <string, string>(tx.Id.ToString(), result));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Send Asset Method
        /// </summary>
        /// <param name="client"></param>
        /// <returns>tx.Id</returns>
        public static async Task <string> NFTSend(IClient client)
        {
            var _generalClient = new GeneralApi(client);

            Console.WriteLine("Please Types NFT TokenID");
            string Tokenid = Console.ReadLine();
            var    to      = new PublicKeyAddress(Utils.GetUser1KeyPair());
            //enter the send amount

            var moveCoin = new NFTMove(TableName, Tokenid, to);
            var tx       = TransactionCreator.SimpleSignedTransaction(
                new ITransactionEntry[] { moveCoin },
                new [] { Utils.GetUser0KeyPair().PrivateKey });//Sender Privatekey

            await SendTransaction(tx);

            var result = await Utils.WaitTx(_generalClient, tx.Id);

            return(result);
        }