public EthereumServiceAgent(ISubscriberService subscriberService, ISmartContractStoreServiceAgent smartContractServiceAgent)
        {
            _smartContractServiceAgent = smartContractServiceAgent;

            var configurationPackage = subscriberService.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            var blockchainSection    = configurationPackage.Settings.Sections["Blockchain"].Parameters;
            var transactionNodeVip   = blockchainSection["TransactionNodeVip"].Value;

            // this blockchain account is only used to send and public smart contracts, not to actually create telemetry transactions.
            _blockchainAdminAccount    = blockchainSection["BlockchainAdminAccount"].Value;
            _blockchainAdminPassphrase = blockchainSection["BlockchainAdminPassphrase"].Value;

            if (string.IsNullOrEmpty(transactionNodeVip))
            {
                throw new Exception("TransactionNodeVip is not set in Service Fabric configuration package.");
            }

            if (string.IsNullOrEmpty(_blockchainAdminAccount))
            {
                throw new Exception("BlockchainAdminAccount is not set in Service Fabric configuration package.");
            }

            if (string.IsNullOrEmpty(_blockchainAdminPassphrase))
            {
                throw new Exception("BlockchainAdminPassphrase is not set in Service Fabric configuration package.");
            }

            _web3 = new Web3(transactionNodeVip);
        }
        public EthereumDeviceMovementServiceAgent(ISubscriberService subscriberService,
                                                  ISmartContractServiceAgent smartContractServiceAgent,
                                                  IDeviceStoreServiceAgent deviceStoreServiceAgent,
                                                  IBlockchainServiceAgent blockchainServiceAgent,
                                                  ITrackerStoreServiceAgent trackerStoreServiceAgent)
        {
            _smartContractServiceAgent = smartContractServiceAgent ?? throw new ArgumentNullException(nameof(smartContractServiceAgent));
            _deviceStoreServiceAgent   = deviceStoreServiceAgent ?? throw new ArgumentNullException(nameof(deviceStoreServiceAgent));
            _blockchainServiceAgent    = blockchainServiceAgent ?? throw new ArgumentNullException(nameof(blockchainServiceAgent));
            _trackerStoreServiceAgent  = trackerStoreServiceAgent ?? throw new ArgumentNullException(nameof(trackerStoreServiceAgent));
            _subscriberService         = subscriberService ?? throw new ArgumentNullException(nameof(subscriberService));

            var configurationPackage = _subscriberService.Context.CodePackageActivationContext.GetConfigurationPackageObject("Config");
            var blockchainSection    = configurationPackage.Settings.Sections["Blockchain"].Parameters;
            var transactionNodeVip   = blockchainSection["TransactionNodeVip"].Value;

            // this blockchain account is only used to send and public smart contracts, not to actually create telemetry transactions.
            _blockchainAdminAccount    = blockchainSection["BlockchainAdminAccount"].Value;
            _blockchainAdminPassphrase = blockchainSection["BlockchainAdminPassphrase"].Value;
            _deviceTwinFuncs           = new Dictionary <string, Func <DeviceTwinTagsDto> >();
            if (string.IsNullOrEmpty(transactionNodeVip))
            {
                throw new Exception("TransactionNodeVip is not set in Service Fabric configuration package.");
            }

            if (string.IsNullOrEmpty(_blockchainAdminAccount))
            {
                throw new Exception("BlockchainAdminAccount is not set in Service Fabric configuration package.");
            }

            if (string.IsNullOrEmpty(_blockchainAdminPassphrase))
            {
                throw new Exception("BlockchainAdminPassphrase is not set in Service Fabric configuration package.");
            }

            _web3 = new Web3(transactionNodeVip);
        }