コード例 #1
0
        public async Task <Account> CreateWallet(string uniquekey)
        {
            var ecKey      = Nethereum.Signer.EthECKey.GenerateKey();
            var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
            var account    = new Nethereum.Web3.Accounts.Account(privateKey);

            return(account);
        }
コード例 #2
0
        public Account GenerateNewAccount()
        {
            EthECKey ecKey      = Nethereum.Signer.EthECKey.GenerateKey();
            string   privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
            Account  account    = new Nethereum.Web3.Accounts.Account(privateKey);

            return(account);
        }
コード例 #3
0
        public async void TestMethod1Async()
        {
            string privateKey = "768737baf760264de8b8f9352ed135af8b7f69b9a6158ff616a00d81e03ab71a";
            var    account    = new Nethereum.Web3.Accounts.Account(privateKey);
            var    eth        = new EthService(new Web3(account, @"http://api-ropsten.etherscan.io"));

            //Test();
            var balance = await eth.GetBalance("0xFbF065C72Ad57611d26DCcd5041806fB5A988D92");

            Console.WriteLine("the balance is :" + balance);
            Assert.IsTrue(balance > 0);
        }
コード例 #4
0
        public IActionResult CreateNewAccount()
        {
            try
            {
                var ecKey      = Nethereum.Signer.EthECKey.GenerateKey();
                var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
                var account    = new Nethereum.Web3.Accounts.Account(privateKey);

                return(Json(new AccountModel(account.Address, account.PrivateKey)));
            }
            catch (Exception ex)
            {
                return(ReturnError(ex));
            }
        }
コード例 #5
0
ファイル: AccountHelper.cs プロジェクト: ranjancse26/RSK-KMS
        public static RSKAccount CreateNewAccount()
        {
            try
            {
                var ecKey      = Nethereum.Signer.EthECKey.GenerateKey();
                var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
                var account    = new Nethereum.Web3.Accounts.Account(privateKey);

                return(new RSKAccount
                {
                    Address = account.Address.ToLower(),
                    PrivateKey = account.PrivateKey
                });
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.StackTrace);
            }
            return(null);
        }
コード例 #6
0
        /// <summary>
        /// Run this configuration before the app starts!
        /// </summary>
        /// <returns></returns>
        public static async Task RunConfiguration()
        {
            DiContainer.SetDefaultLifetime <PerContainerLifetime>();
            DiContainer.Register <Models.Repository>();

            var account = new Nethereum.Web3.Accounts.Account(privateKey1);


            var web3 = new Nethereum.Web3.Web3(account, "HTTP://127.0.0.1:7545");

            //string result = await  web3.TransactionManager.SendTransactionAsync(account.Address, recieverAddress, new HexBigInteger(11000000000000000000));



            var contract         = web3.Eth.GetContract(MultiplyerABI, MultiplyTestContractAddress);
            var multiplyFunction = contract.GetFunction("multiply");
            var result           = await multiplyFunction.CallAsync <int>(8);

            var testFunction = contract.GetFunction("test");
            var testResult   = await testFunction.SendTransactionAsync(account.Address, 3);

            var multiplyResultAgain = await multiplyFunction.CallAsync <int>(7);


            var contractPoE      = web3.Eth.GetContract(ABIForProofOFExistance, proofOfExistanceAddress);
            var notoriseFunction = contractPoE.GetFunction("notorize");
            await notoriseFunction.SendTransactionAsync(account.Address, "Something");


            /*
             * var contractFoodchain = web3.Eth.GetContract(foodchainABI, foodchainAddress);
             * var notoriseFunction = contract.GetFunction("notorize");
             * await notoriseFunction.SendTransactionAsync("Something");
             */



            int m = 6;
            //var account = Nethereum.Web3.Accounts.Account.LoadFromKeyStore()
        }
コード例 #7
0
ファイル: ClinicTransfer.cs プロジェクト: SaakG/BlockChain
        private async Task transferOnwer2(string contractaddress, string privatekey1, string privatekey2, string eth_owner)
        {
            var url     = "http://127.0.0.1:7545";
            var account = new Nethereum.Web3.Accounts.Account(privatekey1);
            var web31   = new Web3(account, url);
            var iot     = new TransferOwnerShips
            {
                newOwner = eth_owner
            };
            var balanceHandler = web31.Eth.GetContractQueryHandler <TransferOwnerShips>();
            var balance        = await balanceHandler.QueryAsync <int>(contractaddress, iot);

            if (balance == 1)
            {
                MessageBox.Show("OwnerShipTransfer Successfully");
                using (var reader = new StreamReader(@"C:\Users\C.z\source\repos\BlockChain Project\BlockChain Project\DeployedContract.txt"))
                {
                    while (!reader.EndOfStream)
                    {
                        var line   = reader.ReadLine();
                        var values = line.Split(',');
                        if (contractaddress == values[0])
                        {
                            var csv = new StringBuilder();

                            //in your loop
                            string Item1 = values[0];
                            string Item2 = eth_owner;
                            string Item3 = values[2];
                            string Item4 = values[3];
                            string Item5 = values[4];
                            string Item6 = values[5];
                            //Suggestion made by KyleMit
                            var newLine = string.Format("{0},{1},{2},{3},{4},{5}", Item1, Item2, Item3, Item4, Item5, Item6);
                            csv.AppendLine(newLine);

                            //after your loop
                            MessageBox.Show(csv.ToString());
                            File.AppendAllText(@"C:\Users\C.z\source\repos\BlockChain Project\BlockChain Project\DeployedContract.txt", csv.ToString());
                        }
                        else
                        {
                            var csv = new StringBuilder();

                            //in your loop
                            string Item1 = values[0];
                            string Item2 = values[1];
                            string Item3 = values[2];
                            string Item4 = values[3];
                            string Item5 = values[4];
                            string Item6 = values[5];
                            //Suggestion made by KyleMit
                            var newLine = string.Format("{0},{1},{2},{3},{4},{5}", Item1, Item2, Item3, Item4, Item5, Item6);
                            csv.AppendLine(newLine);

                            //after your loop
                            MessageBox.Show(csv.ToString());
                            File.AppendAllText(@"C:\Users\C.z\source\repos\BlockChain Project\BlockChain Project\DeployedContract.txt", csv.ToString());
                        }
                    }
                }
            }
            this.Hide();
            Form2 s = new Form2();

            s.Show();
        }
コード例 #8
0
ファイル: OathService.cs プロジェクト: timchenyx/theroom
        public OathService()
        {
            var account = new Nethereum.Web3.Accounts.Account(privateKey);

            web3 = new Web3(account, web3Url);
        }