private async Task <string> DeployDeposit(string token)
        {
            var deploymentMessage = new DepositDeployment
            {
                Token = token
            };

            var deploymentHandler  = web3.Eth.GetContractDeploymentHandler <DepositDeployment>();
            var transactionReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage);

            var contractAddress = transactionReceipt.ContractAddress;

            return(contractAddress);
        }
Exemple #2
0
        public async Task TestStuff()
        {
            var url        = "http://127.0.0.1:8545"; // "http://testchain.nethereum.com:8545";
            var privateKey = "0x8f74caf4d4e74ee73e960fcb6f77f8a7ee80070507ffa99123559faf7066322e";
            var account    = new Account(privateKey);
            var web3       = new Web3(account, url);

            var deploymentMessage = new DepositDeployment
            {
                Token = ""
            };

            var deploymentHandler  = web3.Eth.GetContractDeploymentHandler <DepositDeployment>();
            var transactionReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage);

            var contractAddress = transactionReceipt.ContractAddress;

            //var balanceOfFunctionMessage = new BalanceOfFunction()
            //{
            //    Owner = account.Address,
            //};

            //var balanceHandler = web3.Eth.GetContractQueryHandler<BalanceOfFunction>();
            //var balance = await balanceHandler.QueryAsync<BigInteger>(contractAddress, balanceOfFunctionMessage);


            var receiverAddress = "0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe";
            var transferHandler = web3.Eth.GetContractTransactionHandler <TransferFunction>();
            var transfer        = new TransferFunction()
            {
                To          = receiverAddress,
                TokenAmount = 100
            };
            var tr = await transferHandler.SendRequestAndWaitForReceiptAsync(contractAddress, transfer);


            Console.WriteLine();
        }
        public static async Task <DepositService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, DepositDeployment depositDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            var receipt = await DeployContractAndWaitForReceiptAsync(web3, depositDeployment, cancellationTokenSource);

            return(new DepositService(web3, receipt.ContractAddress));
        }
 public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, DepositDeployment depositDeployment)
 {
     return(web3.Eth.GetContractDeploymentHandler <DepositDeployment>().SendRequestAsync(depositDeployment));
 }
 public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, DepositDeployment depositDeployment, CancellationTokenSource cancellationTokenSource = null)
 {
     return(web3.Eth.GetContractDeploymentHandler <DepositDeployment>().SendRequestAndWaitForReceiptAsync(depositDeployment, cancellationTokenSource));
 }