Ejemplo n.º 1
0
        private static async Task DeployContractProxyAsync()
        {
            var dgtImplementation                  = new DGTImplementationDeployment();
            var dgtImplementationHandler           = GetWeb3Object.Eth.GetContractDeploymentHandler <DGTImplementationDeployment>();
            var dgtImplementationReceiptDeployment = await dgtImplementationHandler.SendRequestAndWaitForReceiptAsync(dgtImplementation);

            ContractAddress = dgtImplementationReceiptDeployment.ContractAddress;

            Console.WriteLine(ContractAddress);


            var adminUpgradeabilityProxyDeployment = new AdminUpgradeabilityProxyDeployment();

            adminUpgradeabilityProxyDeployment.Implementation = dgtImplementationReceiptDeployment.ContractAddress;
            var adminUpgradeabilityProxyDeploymentHandler = GetWeb3Object.Eth.GetContractDeploymentHandler <AdminUpgradeabilityProxyDeployment>();
            var adminUpgradeabilityProxyReceiptDeployment = await adminUpgradeabilityProxyDeploymentHandler.SendRequestAndWaitForReceiptAsync(adminUpgradeabilityProxyDeployment);


            ProxyAddress = adminUpgradeabilityProxyReceiptDeployment.ContractAddress;

            Console.WriteLine(ProxyAddress);

            Thread.Sleep(2000);

            var contractHandler     = GetWeb3Object.Eth.GetContractHandler(ProxyAddress);
            var changeAdminFunction = new ChangeAdminFunction();

            changeAdminFunction.NewAdmin = MainAddress;
            var changeAdminFunctionTxnReceipt = await contractHandler.SendRequestAndWaitForReceiptAsync(changeAdminFunction);

            try
            {
                // Need proxy contract object of ContractAddress
                contractHandler = GetWeb3Object.Eth.GetContractHandler(ContractAddress);
                var initializeFunctionTxnReceipt = await contractHandler.SendRequestAndWaitForReceiptAsync <InitializeFunction>();

                Console.WriteLine(initializeFunctionTxnReceipt.TransactionHash);
            }
            catch (Exception e)
            {
                var es = e.StackTrace;
            }
        }
 public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, AdminUpgradeabilityProxyDeployment adminUpgradeabilityProxyDeployment)
 {
     return(web3.Eth.GetContractDeploymentHandler <AdminUpgradeabilityProxyDeployment>().SendRequestAsync(adminUpgradeabilityProxyDeployment));
 }
        public static async Task <AdminUpgradeabilityProxyService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, AdminUpgradeabilityProxyDeployment adminUpgradeabilityProxyDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            var receipt = await DeployContractAndWaitForReceiptAsync(web3, adminUpgradeabilityProxyDeployment, cancellationTokenSource);

            return(new AdminUpgradeabilityProxyService(web3, receipt.ContractAddress));
        }
 public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, AdminUpgradeabilityProxyDeployment adminUpgradeabilityProxyDeployment, CancellationTokenSource cancellationTokenSource = null)
 {
     return(web3.Eth.GetContractDeploymentHandler <AdminUpgradeabilityProxyDeployment>().SendRequestAndWaitForReceiptAsync(adminUpgradeabilityProxyDeployment, cancellationTokenSource));
 }