Пример #1
0
        public Eth(RpcClient client):base(client)
        {
            this.Client = client;
           
           

            DeployContract = new DeployContract(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 EthTransactionsService(client);
            Filters = new EthFilterService(client);
            Blocks = new EthBlockService(client);
            Uncles = new EthUncleService(client);
            Mining = new EthMiningService(client);
            Compile = new EthCompilerService(client);

            this.DefaultBlock = BlockParameter.CreateLatest();

        }
Пример #2
0
        static async Task <BlockWithTransactions> GetBlockWithTx(ulong blockNumber)
        {
            var blockNumberParameter = new Nethereum.RPC.Eth.DTOs.BlockParameter(blockNumber);
            var block = await web3ConsumeBlocks.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockNumberParameter);

            return(block);
        }
Пример #3
0
        private void SetDefaultBlock()
        {
            this.GetBalance.DefaultBlock = DefaultBlock;
            this.GetCode.DefaultBlock = DefaultBlock;
            this.GetStorageAt.DefaultBlock = DefaultBlock;
            this.Transactions.SetDefaultBlock(defaultBlock);

        }
Пример #4
0
        static async Task <string> GetTransactions(BigInteger timespan)
        {
            var web3 = new Web3("http://127.0.0.1:7545");

            //testing with the ethereum /truffle example from the petshop tutorial
            var json     = JObject.Load(new JsonTextReader(new StreamReader(System.IO.File.OpenRead(orderSystemJson))));
            var abi      = json["abi"].ToString();
            var bytecode = json["bytecode"].ToString();
            var ganacheOrderSystemContractAddress = json["networks"]["5777"]["address"].ToString();

            var unlockAccountResult = await web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, senderPassword, 1200).ConfigureAwait(false);

            var unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds - timespan;

            var transactionsByHash = new EthGetTransactionByHash(web3.Client);
            //var theresult = await transactionsByHash.SendRequestAsync(senderAddress);
            var abiMap = GetABIFunctionMap(json["abi"]);

            var arrayOfTransactions = new List <EthTransaction>();
            var maxBlockNumber      = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();

            var LastMaxBlockNumber = maxBlockNumber;

            long txTotalCount = 0;

            for (ulong blockNumber = 0; blockNumber <= LastMaxBlockNumber.Value; blockNumber++)
            {
                var blockParameter = new Nethereum.RPC.Eth.DTOs.BlockParameter(blockNumber);
                var block          = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(blockParameter);

                var trans   = block.Transactions;
                int txCount = trans.Length;
                txTotalCount += txCount;


                foreach (var tx in trans)
                {
                    try
                    {
                        var bn        = tx.BlockNumber.Value;
                        var transHash = tx.TransactionHash;
                        var ti        = tx.TransactionIndex.Value;
                        var nc        = tx.Nonce.Value;
                        var from      = tx.From;

                        var rpt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transHash);

                        var status = rpt.Status.Value;

                        var to = tx.To;
                        if (to == null)
                        {
                            to = "to:NULL";
                        }

                        var v  = tx.Value.Value;
                        var g  = tx.Gas.Value;
                        var gp = tx.GasPrice.Value;
                        Console.WriteLine(transHash.ToString() + " " + ti.ToString() + " " + nc.ToString() + " " + from.ToString() + " " + to.ToString() + " " + v.ToString() + " " + g.ToString() + " " + gp.ToString());
                        if (rpt.Logs.Count > 0)
                        {
                            foreach (var rp in rpt.Logs)
                            {
                                var tpic = rp["topics"];
                                Console.WriteLine("logs : " + tpic[0].ToString());
                                string funcVal = string.Empty;

                                abiMap.TryGetValue(tpic[0].ToString(), out funcVal);
                                if (funcVal != null)
                                {
                                    arrayOfTransactions.Add(new EthTransaction(block.Number.Value.ToString(), transHash, funcVal, from));
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("ScanTxExample.Tx:\t" + ex.ToString());
                        if (ex.InnerException != null)
                        {
                            Console.WriteLine("ScanTxExample.Tx:\t" + ex.InnerException.ToString());
                        }
                    }
                }
                Console.WriteLine();
            }
            return(JsonConvert.SerializeObject(arrayOfTransactions));
        }
Пример #5
0
 public NewFilterInput()
 {
     FromBlock = new BlockParameter();
     ToBlock = new BlockParameter();
 }
Пример #6
0
 public void SetDefaultBlock(BlockParameter blockParameter)
 {
     Call.DefaultBlock = blockParameter;
     GetTransactionCount.DefaultBlock = blockParameter;
 }
Пример #7
0
        public IEnumerator SendRequest(System.String address, Nethereum.RPC.Eth.DTOs.BlockParameter block)
        {
            var request = _ethGetTransactionCount.BuildRequest(address, block);

            yield return(SendRequest(request));
        }
Пример #8
0
        public IEnumerator SendRequest(Nethereum.RPC.Eth.DTOs.CallInput callInput, Nethereum.RPC.Eth.DTOs.BlockParameter block)
        {
            var request = _ethCall.BuildRequest(callInput, block);

            yield return(SendRequest(request));
        }
Пример #9
0
        public IEnumerator SendRequest(Nethereum.RPC.Eth.DTOs.BlockParameter blockParameter, Nethereum.Hex.HexTypes.HexBigInteger uncleIndex)
        {
            var request = _ethGetUncleByBlockNumberAndIndex.BuildRequest(blockParameter, uncleIndex);

            yield return(SendRequest(request));
        }
Пример #10
0
        public IEnumerator SendRequest(System.String address, Nethereum.Hex.HexTypes.HexBigInteger position, Nethereum.RPC.Eth.DTOs.BlockParameter block)
        {
            var request = _ethGetStorageAt.BuildRequest(address, position, block);

            yield return(SendRequest(request));
        }
Пример #11
0
        public IEnumerator SendRequest(Nethereum.RPC.Eth.DTOs.BlockParameter block)
        {
            var request = _ethGetBlockTransactionCountByNumber.BuildRequest(block);

            yield return(SendRequest(request));
        }