Exemplo n.º 1
0
        public void WhenGetMinGasPriceThenReturns()
        {
            GasPriceService gps = new GasPriceService();

            var mgpgw = gps.GetRskMinGasPrice();

            Console.WriteLine(mgpgw);
        }
Exemplo n.º 2
0
        public void WhenGetMeasureThenAllData()
        {
            var ms = new GasPriceService();

            var m = ms.GetGasMeasure();

            Console.WriteLine("ETH: " + m.EthGasPriceInUsd());
            Console.WriteLine("RSK: " + m.RskGasPriceInUsd());
        }
Exemplo n.º 3
0
        public void WhenNavigateToStationThenGetThePrices()
        {
            var gps = new GasPriceService();

            var gp = gps.GetEthGasPrice();

            Console.WriteLine(gp.Item1);
            Console.WriteLine(gp.Item2);
            Console.WriteLine(gp.Item3);
        }
Exemplo n.º 4
0
        public void GasPriceService_GetRskMinGasPrice()
        {
            // Arrange
            IGasPriceService gasPriceService = new GasPriceService(ConfigurationManager.AppSettings["RskTestnetNodeUrl"]);

            // Act
            int gasPrice = gasPriceService.GetRskMinGasPrice();

            // Assert
            Assert.IsTrue(gasPrice > 0);
        }
Exemplo n.º 5
0
        public static void GasRunner([TimerTrigger("0 */5 * * * *", RunOnStartup = true)] TimerInfo timerInfo, TextWriter log)
        {
            log.WriteLine($"C# Timer trigger function executed at: {DateTime.Now}");

            var gs = new GasPriceService();
            var gm = gs.GetGasMeasure();

            var gp = new GasAzurePersistor(AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage));

            gp.Save(gm);

            log.WriteLine($"Result: RSK={gm.RskGasPriceInUsd()} - ETH={gm.EthGasPriceInUsd()}");
        }
Exemplo n.º 6
0
 public NdmCreatedServices(Address consumerAddress,
                           IAbiEncoder abiEncoder, IRlpDecoder <DataAsset> dataAssetRlpDecoder, IDepositService depositService,
                           GasPriceService gasPriceService, TransactionService transactionService,
                           INdmDataPublisher ndmDataPublisher, IJsonRpcNdmConsumerChannel jsonRpcNdmConsumerChannel,
                           INdmConsumerChannelManager ndmConsumerChannelManager, INdmBlockchainBridge blockchainBridge)
 {
     ConsumerAddress           = consumerAddress;
     AbiEncoder                = abiEncoder;
     DataAssetRlpDecoder       = dataAssetRlpDecoder;
     DepositService            = depositService;
     GasPriceService           = gasPriceService;
     TransactionService        = transactionService;
     NdmDataPublisher          = ndmDataPublisher;
     JsonRpcNdmConsumerChannel = jsonRpcNdmConsumerChannel;
     NdmConsumerChannelManager = ndmConsumerChannelManager;
     BlockchainBridge          = blockchainBridge;
 }
Exemplo n.º 7
0
 public NdmCreatedServices(
     Address consumerAddress,
     IAbiEncoder abiEncoder,
     IRlpDecoder <DataAsset> dataAssetRlpDecoder,
     IDepositService depositService,
     GasPriceService gasPriceService,
     TransactionService transactionService,
     INdmDataPublisher ndmDataPublisher,
     IJsonRpcNdmConsumerChannel jsonRpcNdmConsumerChannel,
     INdmConsumerChannelManager ndmConsumerChannelManager,
     INdmBlockchainBridge blockchainBridge)
 {
     ConsumerAddress           = consumerAddress ?? throw new ArgumentNullException(nameof(consumerAddress));
     AbiEncoder                = abiEncoder ?? throw new ArgumentNullException(nameof(abiEncoder));
     DataAssetRlpDecoder       = dataAssetRlpDecoder ?? throw new ArgumentNullException(nameof(dataAssetRlpDecoder));
     DepositService            = depositService ?? throw new ArgumentNullException(nameof(depositService));
     GasPriceService           = gasPriceService ?? throw new ArgumentNullException(nameof(gasPriceService));
     TransactionService        = transactionService ?? throw new ArgumentNullException(nameof(transactionService));
     NdmDataPublisher          = ndmDataPublisher ?? throw new ArgumentNullException(nameof(ndmDataPublisher));
     JsonRpcNdmConsumerChannel = jsonRpcNdmConsumerChannel ?? throw new ArgumentNullException(nameof(jsonRpcNdmConsumerChannel));
     NdmConsumerChannelManager = ndmConsumerChannelManager ?? throw new ArgumentNullException(nameof(ndmConsumerChannelManager));
     BlockchainBridge          = blockchainBridge ?? throw new ArgumentNullException(nameof(blockchainBridge));
 }
Exemplo n.º 8
0
        public INdmServices Init(NdmRequiredServices services)
        {
            AddDecoders();
            var config          = services.NdmConfig;
            var consumerAddress = string.IsNullOrWhiteSpace(config.ConsumerAddress)
                ? Address.Zero
                : new Address(config.ConsumerAddress);
            var contractAddress = string.IsNullOrWhiteSpace(config.ContractAddress)
                ? Address.Zero
                : new Address(config.ContractAddress);

            var configId                = config.Id;
            var configManager           = services.ConfigManager;
            var logManager              = services.LogManager;
            var timestamper             = services.Timestamper;
            var wallet                  = services.Wallet;
            var readOnlyTree            = new ReadOnlyBlockTree(services.BlockTree);
            var readOnlyDbProvider      = new ReadOnlyDbProvider(services.RocksProvider, false);
            var readOnlyTxProcessingEnv = new ReadOnlyTxProcessingEnv(readOnlyDbProvider, readOnlyTree,
                                                                      services.SpecProvider, logManager);
            var jsonRpcConfig    = services.ConfigProvider.GetConfig <IJsonRpcConfig>();
            var blockchainBridge = new BlockchainBridge(
                readOnlyTxProcessingEnv.StateReader,
                readOnlyTxProcessingEnv.StateProvider,
                readOnlyTxProcessingEnv.StorageProvider,
                readOnlyTxProcessingEnv.BlockTree,
                services.TransactionPool,
                services.ReceiptFinder,
                services.FilterStore,
                services.FilterManager,
                wallet,
                readOnlyTxProcessingEnv.TransactionProcessor,
                services.Ecdsa,
                services.BloomStorage,
                logManager,
                false,
                jsonRpcConfig.FindLogBlockDepthLimit);
            var dataAssetRlpDecoder = new DataAssetDecoder();
            var encoder             = new AbiEncoder();

            INdmBlockchainBridge ndmBlockchainBridge;

            if (config.ProxyEnabled)
            {
                if (config.JsonRpcUrlProxies == null || services.EthJsonRpcClientProxy == null)
                {
                    throw new InvalidDataException("JSON RPC proxy is enabled but the proxies were not initialized properly.");
                }

                services.JsonRpcClientProxy !.SetUrls(config.JsonRpcUrlProxies !);
                ndmBlockchainBridge = new NdmBlockchainBridgeProxy(services.EthJsonRpcClientProxy);
            }
            else
            {
                ndmBlockchainBridge = new NdmBlockchainBridge(blockchainBridge, services.TransactionPool);
            }

            var gasPriceService = new GasPriceService(services.HttpClient, configManager, configId, timestamper,
                                                      logManager);
            var transactionService = new TransactionService(ndmBlockchainBridge, wallet, configManager, configId,
                                                            logManager);
            var depositService            = new DepositService(ndmBlockchainBridge, encoder, wallet, contractAddress);
            var ndmConsumerChannelManager = services.NdmConsumerChannelManager;
            var ndmDataPublisher          = services.NdmDataPublisher;
            var jsonRpcNdmConsumerChannel = new JsonRpcNdmConsumerChannel(logManager);

            if (config.JsonRpcDataChannelEnabled)
            {
                ndmConsumerChannelManager.Add(jsonRpcNdmConsumerChannel);
            }

            return(new Services(services, new NdmCreatedServices(consumerAddress, encoder, dataAssetRlpDecoder,
                                                                 depositService, gasPriceService, transactionService, ndmDataPublisher, jsonRpcNdmConsumerChannel,
                                                                 ndmConsumerChannelManager, ndmBlockchainBridge)));
        }
Exemplo n.º 9
0
        public INdmServices Init(NdmRequiredServices services)
        {
            AddDecoders();
            var config          = services.NdmConfig;
            var consumerAddress = string.IsNullOrWhiteSpace(config.ConsumerAddress)
                ? Address.Zero
                : new Address(config.ConsumerAddress);
            var contractAddress = string.IsNullOrWhiteSpace(config.ContractAddress)
                ? Address.Zero
                : new Address(config.ContractAddress);

            var configId                = config.Id;
            var configManager           = services.ConfigManager;
            var logManager              = services.LogManager;
            var timestamper             = services.Timestamper;
            var wallet                  = services.Wallet;
            var readOnlyTree            = new ReadOnlyBlockTree(services.BlockTree);
            var readOnlyDbProvider      = new ReadOnlyDbProvider(services.RocksProvider, false);
            var readOnlyTxProcessingEnv = new ReadOnlyTxProcessingEnv(readOnlyDbProvider, readOnlyTree,
                                                                      services.SpecProvider, logManager);
            var blockchainBridge = new BlockchainBridge(
                readOnlyTxProcessingEnv.StateReader,
                readOnlyTxProcessingEnv.StateProvider,
                readOnlyTxProcessingEnv.StorageProvider,
                readOnlyTxProcessingEnv.BlockTree,
                services.TransactionPool,
                services.ReceiptStorage,
                services.FilterStore,
                services.FilterManager,
                wallet,
                readOnlyTxProcessingEnv.TransactionProcessor,
                services.Ecdsa);
            var dataAssetRlpDecoder = new DataAssetDecoder();
            var encoder             = new AbiEncoder();

            INdmBlockchainBridge ndmBlockchainBridge;

            if (config.ProxyEnabled)
            {
                services.JsonRpcClientProxy.SetUrls(config.JsonRpcUrlProxies);
                ndmBlockchainBridge = new NdmBlockchainBridgeProxy(services.EthJsonRpcClientProxy);
            }
            else
            {
                ndmBlockchainBridge = new NdmBlockchainBridge(blockchainBridge, services.TransactionPool);
            }

            var gasPriceService = new GasPriceService(services.HttpClient, configManager, configId, timestamper,
                                                      logManager);
            var transactionService = new TransactionService(ndmBlockchainBridge, wallet, configManager, configId,
                                                            logManager);
            var depositService            = new DepositService(ndmBlockchainBridge, encoder, wallet, contractAddress);
            var ndmConsumerChannelManager = services.NdmConsumerChannelManager;
            var ndmDataPublisher          = services.NdmDataPublisher;
            var jsonRpcNdmConsumerChannel = new JsonRpcNdmConsumerChannel();

//            ndmConsumerChannelManager.Add(jsonRpcNdmConsumerChannel);

            return(new Services(services, new NdmCreatedServices(consumerAddress, encoder, dataAssetRlpDecoder,
                                                                 depositService, gasPriceService, transactionService, ndmDataPublisher, jsonRpcNdmConsumerChannel,
                                                                 ndmConsumerChannelManager, ndmBlockchainBridge)));
        }
Exemplo n.º 10
0
        public INdmConsumerServices Init(INdmServices services)
        {
            AddDecoders();
            ILogManager logManager = services.RequiredServices.LogManager;
            ILogger     logger     = logManager.GetClassLogger();

            bool disableSendingDepositTransaction  = HasEnabledVariable("SENDING_DEPOSIT_TRANSACTION_DISABLED");
            bool instantDepositVerificationEnabled = HasEnabledVariable("INSTANT_DEPOSIT_VERIFICATION_ENABLED");
            bool backgroundServicesDisabled        = HasEnabledVariable("BACKGROUND_SERVICES_DISABLED");

            if (disableSendingDepositTransaction)
            {
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM sending deposit transaction is disabled ***");
                }
            }

            if (instantDepositVerificationEnabled)
            {
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM instant deposit verification is enabled ***");
                }
            }

            if (backgroundServicesDisabled)
            {
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM background services are disabled ***");
                }
            }

            INdmConfig ndmConfig       = services.RequiredServices.NdmConfig;
            string     configId        = ndmConfig.Id;
            IDbConfig  dbConfig        = services.RequiredServices.ConfigProvider.GetConfig <IDbConfig>();
            Address    contractAddress = string.IsNullOrWhiteSpace(ndmConfig.ContractAddress)
                ? Address.Zero
                : new Address(ndmConfig.ContractAddress);
            ConsumerRocksDbProvider rocksDbProvider = new ConsumerRocksDbProvider(services.RequiredServices.BaseDbPath, dbConfig,
                                                                                  logManager);
            DepositDetailsDecoder             depositDetailsRlpDecoder  = new DepositDetailsDecoder();
            DepositApprovalDecoder            depositApprovalRlpDecoder = new DepositApprovalDecoder();
            DataDeliveryReceiptDetailsDecoder receiptRlpDecoder         = new DataDeliveryReceiptDetailsDecoder();
            ConsumerSessionDecoder            sessionRlpDecoder         = new ConsumerSessionDecoder();
            ReceiptRequestValidator           receiptRequestValidator   = new ReceiptRequestValidator(logManager);

            IDepositDetailsRepository          depositRepository;
            IConsumerDepositApprovalRepository depositApprovalRepository;
            IProviderRepository        providerRepository;
            IReceiptRepository         receiptRepository;
            IConsumerSessionRepository sessionRepository;

            switch (ndmConfig.Persistence?.ToLowerInvariant())
            {
            case "mongo":
                IMongoDatabase?database = services.RequiredServices.MongoProvider.GetDatabase();
                if (database == null)
                {
                    throw new ApplicationException("Failed to initialize Mongo DB.");
                }

                depositRepository         = new DepositDetailsMongoRepository(database);
                depositApprovalRepository = new ConsumerDepositApprovalMongoRepository(database);
                providerRepository        = new ProviderMongoRepository(database);
                receiptRepository         = new ReceiptMongoRepository(database, "consumerReceipts");
                sessionRepository         = new ConsumerSessionMongoRepository(database);
                break;

            case "memory":
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM is using in memory database ***");
                }
                DepositsInMemoryDb depositsDatabase = new DepositsInMemoryDb();
                depositRepository         = new DepositDetailsInMemoryRepository(depositsDatabase);
                depositApprovalRepository = new ConsumerDepositApprovalInMemoryRepository();
                providerRepository        = new ProviderInMemoryRepository(depositsDatabase);
                receiptRepository         = new ReceiptInMemoryRepository();
                sessionRepository         = new ConsumerSessionInMemoryRepository();
                break;

            default:
                depositRepository = new DepositDetailsRocksRepository(rocksDbProvider.DepositsDb,
                                                                      depositDetailsRlpDecoder);
                depositApprovalRepository = new ConsumerDepositApprovalRocksRepository(
                    rocksDbProvider.ConsumerDepositApprovalsDb, depositApprovalRlpDecoder);
                providerRepository = new ProviderRocksRepository(rocksDbProvider.DepositsDb,
                                                                 depositDetailsRlpDecoder);
                receiptRepository = new ReceiptRocksRepository(rocksDbProvider.ConsumerReceiptsDb,
                                                               receiptRlpDecoder);
                sessionRepository = new ConsumerSessionRocksRepository(rocksDbProvider.ConsumerSessionsDb,
                                                                       sessionRlpDecoder);
                break;
            }

            uint                       requiredBlockConfirmations = ndmConfig.BlockConfirmations;
            IAbiEncoder                abiEncoder                = services.CreatedServices.AbiEncoder;
            INdmBlockchainBridge       blockchainBridge          = services.CreatedServices.BlockchainBridge;
            IBlockProcessor            blockProcessor            = services.RequiredServices.BlockProcessor;
            IConfigManager             configManager             = services.RequiredServices.ConfigManager;
            Address                    consumerAddress           = services.CreatedServices.ConsumerAddress;
            ICryptoRandom              cryptoRandom              = services.RequiredServices.CryptoRandom;
            IDepositService            depositService            = services.CreatedServices.DepositService;
            GasPriceService            gasPriceService           = services.CreatedServices.GasPriceService;
            IEthereumEcdsa             ecdsa                     = services.RequiredServices.Ecdsa;
            IEthRequestService         ethRequestService         = services.RequiredServices.EthRequestService;
            IJsonRpcNdmConsumerChannel jsonRpcNdmConsumerChannel = services.CreatedServices.JsonRpcNdmConsumerChannel;
            INdmNotifier               ndmNotifier               = services.RequiredServices.Notifier;
            PublicKey                  nodePublicKey             = services.RequiredServices.Enode.PublicKey;
            ITimestamper               timestamper               = services.RequiredServices.Timestamper;
            IWallet                    wallet                    = services.RequiredServices.Wallet;
            IHttpClient                httpClient                = services.RequiredServices.HttpClient;
            IJsonRpcClientProxy?       jsonRpcClientProxy        = services.RequiredServices.JsonRpcClientProxy;
            IEthJsonRpcClientProxy?    ethJsonRpcClientProxy     = services.RequiredServices.EthJsonRpcClientProxy;
            TransactionService         transactionService        = services.CreatedServices.TransactionService;
            IMonitoringService         monitoringService         = services.RequiredServices.MonitoringService;

            monitoringService?.RegisterMetrics(typeof(Metrics));

            DataRequestFactory     dataRequestFactory     = new DataRequestFactory(wallet, nodePublicKey);
            TransactionVerifier    transactionVerifier    = new TransactionVerifier(blockchainBridge, requiredBlockConfirmations);
            DepositUnitsCalculator depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, timestamper);
            DepositProvider        depositProvider        = new DepositProvider(depositRepository, depositUnitsCalculator, logManager);
            KycVerifier            kycVerifier            = new KycVerifier(depositApprovalRepository, logManager);
            ConsumerNotifier       consumerNotifier       = new ConsumerNotifier(ndmNotifier);

            DataAssetService   dataAssetService   = new DataAssetService(providerRepository, consumerNotifier, logManager);
            ProviderService    providerService    = new ProviderService(providerRepository, consumerNotifier, logManager);
            DataRequestService dataRequestService = new DataRequestService(dataRequestFactory, depositProvider, kycVerifier, wallet,
                                                                           providerService, timestamper, sessionRepository, consumerNotifier, logManager);

            SessionService sessionService = new SessionService(providerService, depositProvider, dataAssetService,
                                                               sessionRepository, timestamper, consumerNotifier, logManager);
            DataConsumerService dataConsumerService = new DataConsumerService(depositProvider, sessionService,
                                                                              consumerNotifier, timestamper, sessionRepository, logManager);
            DataStreamService dataStreamService = new DataStreamService(dataAssetService, depositProvider,
                                                                        providerService, sessionService, wallet, consumerNotifier, sessionRepository, logManager);
            DepositApprovalService depositApprovalService = new DepositApprovalService(dataAssetService, providerService,
                                                                                       depositApprovalRepository, timestamper, consumerNotifier, logManager);
            DepositConfirmationService depositConfirmationService = new DepositConfirmationService(blockchainBridge, consumerNotifier,
                                                                                                   depositRepository, depositService, logManager, requiredBlockConfirmations);

            IDepositManager depositManager = new DepositManager(depositService, depositUnitsCalculator,
                                                                dataAssetService, kycVerifier, providerService, abiEncoder, cryptoRandom, wallet, gasPriceService,
                                                                depositRepository, timestamper, logManager, requiredBlockConfirmations,
                                                                disableSendingDepositTransaction);

            if (instantDepositVerificationEnabled)
            {
                depositManager = new InstantDepositManager(depositManager, depositRepository, timestamper, logManager,
                                                           requiredBlockConfirmations);
            }

            DepositReportService depositReportService = new DepositReportService(depositRepository, receiptRepository, sessionRepository,
                                                                                 timestamper);
            ReceiptService receiptService = new ReceiptService(depositProvider, providerService, receiptRequestValidator,
                                                               sessionService, timestamper, receiptRepository, sessionRepository, abiEncoder, wallet, ecdsa,
                                                               nodePublicKey, logManager);
            RefundService refundService = new RefundService(blockchainBridge, abiEncoder, depositRepository,
                                                            contractAddress, logManager);
            RefundClaimant refundClaimant = new RefundClaimant(refundService, blockchainBridge, depositRepository,
                                                               transactionVerifier, gasPriceService, timestamper, logManager);
            AccountService accountService = new AccountService(configManager, dataStreamService, providerService,
                                                               sessionService, consumerNotifier, wallet, configId, consumerAddress, logManager);
            ProxyService    proxyService    = new ProxyService(jsonRpcClientProxy, configManager, configId, logManager);
            ConsumerService consumerService = new ConsumerService(accountService, dataAssetService, dataRequestService,
                                                                  dataConsumerService, dataStreamService, depositManager, depositApprovalService, providerService,
                                                                  receiptService, refundService, sessionService, proxyService);
            EthPriceService             ethPriceService             = new EthPriceService(httpClient, timestamper, logManager);
            ConsumerTransactionsService consumerTransactionsService = new ConsumerTransactionsService(transactionService, depositRepository,
                                                                                                      timestamper, logManager);
            ConsumerGasLimitsService gasLimitService = new ConsumerGasLimitsService(depositService, refundService);


            services.RequiredServices.RpcModuleProvider.Register(
                new SingletonModulePool <INdmRpcConsumerModule>(new NdmRpcConsumerModule(consumerService,
                                                                                         depositReportService, jsonRpcNdmConsumerChannel, ethRequestService, ethPriceService,
                                                                                         gasPriceService, consumerTransactionsService, gasLimitService, wallet, timestamper), true));

            if (!backgroundServicesDisabled)
            {
                bool useDepositTimer = ndmConfig.ProxyEnabled;
                ConsumerServicesBackgroundProcessor consumerServicesBackgroundProcessor = new ConsumerServicesBackgroundProcessor(accountService,
                                                                                                                                  refundClaimant, depositConfirmationService, ethPriceService, gasPriceService, blockProcessor,
                                                                                                                                  depositRepository, consumerNotifier, logManager, useDepositTimer, ethJsonRpcClientProxy);
                consumerServicesBackgroundProcessor.Init();
            }

            return(new NdmConsumerServices(accountService, consumerService));
        }
Exemplo n.º 11
0
        /// <summary>
        /// The AES Key/Value with the Private Key for Contract is for demonstration purpose only
        /// Feel free to use it.
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            string key   = "aesKey";
            string value = "testing";

            string rnsResolvedAddress = GetRnsResolvedAddress("ranjancse.rsk", true);

            string nodeUrl                = ConfigurationManager.AppSettings["RskTestnetNodeUrl"];
            var    privateKey             = ConfigurationManager.AppSettings["PrivateKey"];
            var    fromTransferPrivateKey = ConfigurationManager.AppSettings["FromTransferPrivateKey"];
            var    account                = new Nethereum.Web3.Accounts.Account(privateKey);

            IGasPriceService gasPriceService = new GasPriceService(nodeUrl);
            int gasPrice = gasPriceService.GetRskMinGasPrice();

            // Load some RBTC
            LoadSomeRBTC(nodeUrl, fromTransferPrivateKey,
                         account.Address, 0.001m, 0.06m);

            Stopwatch stopwatch = new Stopwatch();

            System.Console.WriteLine("Trying to pull the RSA certificate from the local store using the Thumbprint");

            // Get the certificate by Thumbprint
            string           thumbPrint   = ConfigurationManager.AppSettings["Thumbprint"].ToUpper();
            X509Certificate2 filteredCert = X509CertificateHelper.GetRSKCertificate(thumbPrint,
                                                                                    StoreLocation.LocalMachine);

            if (filteredCert == null)
            {
                System.Console.WriteLine($"Unable to find the RSK certificate by Thumbprint: " +
                                         $"{thumbPrint}");
                System.Console.ReadLine();
                return;
            }

            // Encrypt Text/Data
            var encryptedText = RSAEncryptionHelper.Encrypt(value, filteredCert);

            var  url  = ConfigurationManager.AppSettings["ContractDeploymentUrl"];
            Web3 web3 = new Web3(account, url);

            // Get the balance
            stopwatch.Start();
            var weiBalance  = AccountHelper.GetBalance(web3, account);
            var etherAmount = Web3.Convert.FromWei(weiBalance.Value);

            stopwatch.Stop();

            System.Console.WriteLine($"Account Balance: {etherAmount}");
            System.Console.WriteLine($"Time take to fetch the balance:" +
                                     $" {stopwatch.Elapsed.Seconds} seconds");

            // Gas estimated, in wei
            System.Console.WriteLine($"Estimated Gas Price: {gasPrice}");

            System.Console.WriteLine("Deploying the Iterable Mapping Library");
            stopwatch.Restart();

            // Deploy Iterable Mapping Library
            TransactionReceipt transactionReceiptDeployment;
            string             contractAddress;
            ContractHandler    contractHandler;

            RSKContractHelper.DeployIterableMappingContract(web3,
                                                            out transactionReceiptDeployment,
                                                            out contractAddress,
                                                            out contractHandler);
            stopwatch.Stop();

            System.Console.WriteLine($"Iterable Mapping Contarct Address: " +
                                     $"{contractAddress}");
            System.Console.WriteLine($"Time taken to deploy the Iterable mapping:" +
                                     $" {stopwatch.Elapsed.Seconds} seconds");

            System.Console.WriteLine("Deploying the RSK KMS Contract");

            // Deploy the RSK Contract
            stopwatch.Restart();
            contractHandler = RSKContractHelper.DeployRSKKeyManagmentContract(web3,
                                                                              transactionReceiptDeployment,
                                                                              out contractAddress);
            stopwatch.Stop();
            System.Console.WriteLine($"RSK Contract Address {contractAddress}");
            System.Console.WriteLine($"Time taken to deploy the RSK Contract: " +
                                     $"{stopwatch.Elapsed.Seconds} seconds");

            System.Console.WriteLine("Trying to set a value in RSK KMS Contract");

            /** Function: setItem**/
            var setItemRequest = new SetItemFunction
            {
                Key         = key,
                Value       = encryptedText,
                FromAddress = account.Address
            };

            setItemRequest.GasPrice = new BigInteger(gasPrice * 1.1);

            stopwatch.Restart();
            var setItemFunctionTxnReceipt = contractHandler
                                            .SendRequestAndWaitForReceiptAsync(setItemRequest)
                                            .ConfigureAwait(false)
                                            .GetAwaiter()
                                            .GetResult();

            stopwatch.Stop();
            System.Console.WriteLine($"Time taken to set the KMS Key Item: " +
                                     $"{stopwatch.Elapsed.Seconds} seconds");

            System.Console.WriteLine("Trying to get a value from the RSK KMS Contract");

            /** Function: getItem**/
            var getItemRequest = new GetItemFunction
            {
                Key         = key,
                FromAddress = account.Address
            };

            stopwatch.Restart();
            var getItemResponse = contractHandler
                                  .QueryAsync <GetItemFunction, string>(getItemRequest)
                                  .ConfigureAwait(false)
                                  .GetAwaiter()
                                  .GetResult();

            stopwatch.Stop();
            System.Console.WriteLine($"Time taken to get the KMS Key Item: " +
                                     $"{stopwatch.Elapsed.Seconds} seconds");

            if (!string.IsNullOrEmpty(getItemResponse))
            {
                var decryptedText = RSAEncryptionHelper.Decrypt(getItemResponse, filteredCert);
                System.Console.WriteLine($"Decrypted Text: {decryptedText}");
            }
            else
            {
                System.Console.WriteLine("The KMS Response as empty");
            }

            System.Console.WriteLine("Press any key to exit");
            System.Console.ReadLine();
        }