private void setupWatchContractCall(string guid)
        {
            ContractDeployment deployment = GetContractDeployment <WatchContractDeployment>();

            // setup the service and common parameter
            watchContractService = new WatchContractService(web3, deployment.DeploymentAddress);
            GUID = BigInteger.Parse(guid);
        }
        private ContractDeployment GetContractDeployment <T>() where T : ContractDeploymentMessage, new()
        {
            T contract = new T();
            ContractDeployment      deployment = null;
            WatchContractDeployment watchContractDeployment = null;
            SimpleStorageDeployment simpleStorageDeployment = null;

            if (contract is WatchContractDeployment)
            {
                watchContractDeployment = contract as WatchContractDeployment;
            }
            else if (contract is SimpleStorageDeployment)
            {
                simpleStorageDeployment = contract as SimpleStorageDeployment;
            }
            try {
                deployment = this.context.ContractDeployments.Where(s => s.ByteCode == contract.ByteCode && s.ServerUrl == this.url).First();
            } catch (InvalidOperationException ex) {
                logger.LogError($"contract does not currently exist: {ex}");
            }
            if (deployment == null)
            {
                deployment = new ContractDeployment();
                if (watchContractDeployment != null)
                {
                    watchContractDeployment.GasPrice = 0;
                    TransactionReceipt receipt = WatchContractService.DeployContractAndWaitForReceiptAsync(web3, watchContractDeployment).GetAwaiter().GetResult();
                    deployment.DeploymentAddress = receipt.ContractAddress;
                    deployment.ByteCode          = watchContractDeployment.ByteCode;
                }
                else if (simpleStorageDeployment != null)
                {
                    simpleStorageDeployment.GasPrice = 0;
                    TransactionReceipt receipt = SimpleStorageService.DeployContractAndWaitForReceiptAsync(web3, simpleStorageDeployment).GetAwaiter().GetResult();
                    deployment.DeploymentAddress = receipt.ContractAddress;
                    deployment.ByteCode          = simpleStorageDeployment.ByteCode;
                }
                deployment.ServerUrl = this.url;
                this.context.Add(deployment);
                this.context.SaveChanges();
            }
            return(deployment);
        }