Beispiel #1
0
        private void LoadAccounts()
        {
            Accounts = new List <Account>();

            var accounts = EthereumService.GetAccounts();



            foreach (var account in accounts)
            {
                var a = new Account();
                a.Address = account;

                var filter = new Filter(fromBlock: "0x01")
                {
                    Address = a.Address
                };

                a.FilterId = EthereumService.NewFilter(filter);
                Accounts.Add(a);
                ListViewItem item = new ListViewItem(a.Address);
                var          sign = EthereumService.Sign(a.Address, "Pass@123");
                lstboxAccountList.Items.Add(a.Address);

                a.Unlocked = sign != null;
                EthereumService.UnlockAccount(a.Address, "Pass@123");
            }
        }
Beispiel #2
0
        private void LoadAccounts()
        {
            Accounts = new List <Account>();

            var accounts = EthereumService.GetAccounts();

            cmdAccounts.Items.Clear();

            foreach (var account in accounts)
            {
                var a = new Account();
                a.Address = account;

                var filter = new Filter(fromBlock: "0x01")
                {
                    Address = a.Address
                };

                a.FilterId = EthereumService.NewFilter(filter);
                Accounts.Add(a);

                var sign = EthereumService.Sign(a.Address, "Pass@123");

                a.Unlocked = sign != null;

                cmdAccounts.Items.Add(a);
                EthereumService.UnlockAccount(a.Address, "Pass@123");
            }

            if (accounts.Any())
            {
                cmdAccounts.SelectedIndex = 0;
            }
        }
Beispiel #3
0
        private List <EthAccount> LoadAccounts()
        {
            var privateConnection = new ConnectionOptions()
            {
                Port = "8545",
                Url  = "http://localhost"
            };

            ethereumService = new EthereumService(privateConnection);
            Accounts        = new List <EthAccount>();

            var accounts = ethereumService.GetAccounts();



            foreach (var account in accounts)
            {
                var a = new EthAccount();
                a.Address = account;

                var filter = new Filter(fromBlock: "0x01")
                {
                    Address = a.Address
                };

                a.FilterId = ethereumService.NewFilter(filter);
                Accounts.Add(a);
                var sign = ethereumService.Sign(a.Address, "Pass@123");
                a.Unlocked = sign != null;

                ethereumService.UnlockAccount(a.Address, "Pass@123");

                bool result = ethereumService.UnlockAccount(account, "Pass@123");
                if (result)
                {
                    var balance = ethereumService.GetBalance(account, BlockTag.Latest);
                    //var specifier = "0,0.000";
                    a.Balance = balance.WeiToEther();//string.Format("{0} Eth", balance.WeiToEther().ToString("0,0.000"));
                }
            }
            return(Accounts);
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            var privateConnection = new ConnectionOptions()
            {
                Port = "8545",
                Url  = "http://127.0.0.1"
            };


            var ethereumService = new EthereumService(privateConnection);

            var accounts = ethereumService.GetAccounts();

            foreach (var account in accounts)
            {
                var balance = ethereumService.GetBalance(account, BlockTag.Latest);
                Console.WriteLine("account {0}: {1}", account, EtherCurrencyConverter.Convert(balance));
            }

            var blockNumber = ethereumService.GetBlockNumber();

            Console.WriteLine("BlockNumber : {0}", blockNumber);

            for (var i = 0; i < blockNumber; i++)
            {
                var block = ethereumService.GetBlockByNumber(i, BlockTag.Quantity, true);
                var txNum = ethereumService.GetBlockTransactionCountByNumber(BlockTag.Quantity, i);
                if (txNum > 0)
                {
                    Console.WriteLine("{0} - {1}", i, txNum);
                }
            }

            var res = ethereumService.UnlockAccount(accounts[0], "");

            Console.WriteLine(res);
            //var tx = new Transaction
            //{
            //    From = accounts[0],
            //    To = accounts[1],
            //    Value = "2"
            //};
            //var hash = ethereumService.SendTransaction(accounts[0], accounts[1], 90000, ByteString.ConvertStringToHexUnicode("This is my test data"), 1, 2);

            Console.WriteLine(ByteString.ConvertStringToHexUnicode("This is my test data"));

            //Thread.Sleep(5000);
            //Console.WriteLine(hash);
            var tx = ethereumService.GetTransactionByHash("0xf48d237256ab63872d093fc0bcb4c9ea4a205c5dd6ad47a37558e11dd9d1f5df");

            //var tx = ethereumService.GetTransactionByHash(hash);
            Console.WriteLine("Tx: {0}", tx.Input);
            Console.WriteLine("Tx: {0}", ByteString.ConvertHexToStringUnicode(tx.Input.Substring(2)));
        }
Beispiel #5
0
        private void btnUnlock_Click(object sender, EventArgs e)
        {
            var result = EthereumService.UnlockAccount(Account, txtPassword.Text);

            if (!result)
            {
                MessageBox.Show("Incorrect password");
            }
            else
            {
                this.Close();
            }
        }
Beispiel #6
0
        private void btnShowBalance_Click(object sender, EventArgs e)
        {
            string account = lstboxAccountList.SelectedItem.ToString();
            bool   result  = EthereumService.UnlockAccount(account, "Pass@123");

            if (result)
            {
                var balance = EthereumService.GetBalance(account, BlockTag.Latest);

                MessageBox.Show(account + " - " + string.Format("{0} Eth", balance.WeiToEther()));
            }
            else
            {
                MessageBox.Show("No Balance in this account");
            }
        }
        private void btnUnlock_Click(object sender, EventArgs e)
        {
            bool result = false;

            try
            {
                result = EthereumService.UnlockAccount(Account, txtPassword.Text);
            }
            catch (Exception ex)
            { }
            if (!result)
            {
                MessageBox.Show("Incorrect password");
            }
            else
            {
                this.Close();
            }
        }