Пример #1
0
        private static void EthereumTestRpcDemo(EthereumAccount ethereumAccount)
        {
            var senderPrivateKey  = "0x4faec59e004fd62384813d760e55d6df65537b4ccf62f268253ad7d4243a7193";
            var reciverPrivateKey = "0x03fd5782c37523be6598ca0e5d091756635d144e42d518bb5f8db11cf931b447";

            Console.WriteLine($"Please run the docker image with the following command:{Environment.NewLine}" +
                              "docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest " +
                              $"--account=\"{senderPrivateKey}, 300000000000000000000\"" +
                              $" --account=\"{reciverPrivateKey}, 0\"");

            // Check if Account already stored in KeyStore
            try
            {
                var senderAccount  = ethereumAccount.GetPublicAddressAsync(c_senderId).Result;
                var reciverAccount = ethereumAccount.GetPublicAddressAsync(c_ReciverId).Result;
            }
            catch (Exception)
            {
                // TODO: Add Check for key not found exception
                ethereumAccount.CreateAccountAsync(c_senderId, senderPrivateKey).Wait();
                ethereumAccount.CreateAccountAsync(c_ReciverId, reciverPrivateKey).Wait();
            }
            finally
            {
                SendCoins(ethereumAccount);
            }
        }
        public async Task <ActionResult> CreateAccountAsync(HomeViewModel model)
        {
            var publicAddress = await m_ethereumAccount.CreateAccountAsync(model.SenderId);

            ViewBag.model = new HomeViewModel()
            {
                WalletAddress = publicAddress,
            };

            return(View("Index"));
        }
Пример #3
0
        private static void EthereumTestnetDemo(EthereumAccount ethereumAccount)
        {
            try
            {
                var senderAccount  = ethereumAccount.GetPublicAddressAsync(c_senderId).Result;
                var reciverAccount = ethereumAccount.GetPublicAddressAsync(c_ReciverId).Result;
            }
            catch (Exception)
            {
                // TODO: Add Check for key not found exception
                ethereumAccount.CreateAccountAsync(c_senderId, "0x6d1ae68da64400f4b29baf4bde6fc9796e71480e8f1a502ad6fc2dae92dce268").Wait();
                ethereumAccount.CreateAccountAsync(c_ReciverId).Wait();

                var senderPublicAddress = ethereumAccount.GetPublicAddressAsync(c_senderId);
                Console.WriteLine("Accounts were created. " +
                                  $"To continue the demo please send ether to address {senderPublicAddress}{Environment.NewLine}" +
                                  "You can send ether for: https://www.rinkeby.io/#faucet");
            }

            SendCoins(ethereumAccount);
        }