public EthApiService(IClient client, ITransactionManager transactionManager) : base(client)
        {
            Client = client;

            ChainId         = new EthChainId(client);
            Accounts        = new EthAccounts(client);
            CoinBase        = new EthCoinBase(client);
            GasPrice        = new EthGasPrice(client);
            GetBalance      = new EthGetBalance(client);
            GetCode         = new EthGetCode(client);
            GetStorageAt    = new EthGetStorageAt(client);
            ProtocolVersion = new EthProtocolVersion(client);
            Sign            = new EthSign(client);
            Syncing         = new EthSyncing(client);

            Transactions = new EthApiTransactionsService(client);
            Filters      = new EthApiFilterService(client);
            Blocks       = new EthApiBlockService(client);
            Uncles       = new EthApiUncleService(client);
            Mining       = new EthApiMiningService(client);
            Compile      = new EthApiCompilerService(client);

            DefaultBlock              = BlockParameter.CreateLatest();
            TransactionManager        = transactionManager;
            TransactionManager.Client = client; //Ensure is the same
        }
示例#2
0
        private static async Task <TransactionReceipt> GetTransactionReceiptAsync(EthApiTransactionsService transactionService, string transactionHash)
        {
            TransactionReceipt receipt = null;

            //wait for the contract to be mined to the address
            while (receipt == null)
            {
                await Task.Delay(1000);

                receipt = await transactionService.GetTransactionReceipt.SendRequestAsync(transactionHash);
            }
            return(receipt);
        }
        private async Task <HexBigInteger> EstimateGasLimit(string data, string to)
        {
            EthApiTransactionsService txService   = new EthApiTransactionsService(_web3.Client);
            HexBigInteger             gasEstimate = await txService.EstimateGas.SendRequestAsync(String.IsNullOrEmpty(to)
                                                                                                 ?new CallInput { Data = data }
                                                                                                 : new CallInput {
                Data = data, To = to
            });

            //Use this to compensate for some transactions using slightly more gas than estimated
            BigInteger gasLimit = gasEstimate.Value * EstimateMultiplier;

            return(new HexBigInteger(gasLimit));
        }