public async void WatchEventRpc() { var client = new RpcClient(new Uri("https://mainnet.infura.io")); var ethGetBlockByHash = new EthGetBlockWithTransactionsByNumber(client); var bts = await ethGetBlockByHash.SendRequestAsync(new BlockParameter(7865954)); if (null != bts) { var author = bts.Author; } var ethGetGasEstimate = new EthGasPrice(client); var gas = await ethGetGasEstimate.SendRequestAsync(); Console.WriteLine(gas.Value); var apiService = new EthApiService(client); var bal = await apiService.GetBalance.SendRequestAsync("0xDcCC7b8dDf511f7CE2Ecf8672F57a4E277d73198"); Console.WriteLine(bal.Value); var gass = await apiService.GasPrice.SendRequestAsync(); Console.WriteLine(gass.Value); }
public async Task <string> WithdrawLocally(string transactionId, MaticTransactionOptions options) { EthGetTransactionByHash ethGetTransactionByHash = web3.Eth.Transactions.GetTransactionByHash; Transaction withdrawTransaction = await ethGetTransactionByHash.SendRequestAsync(transactionId); EthGetTransactionReceipt ethGetTransactionReceipt = web3.Eth.Transactions.GetTransactionReceipt; TransactionReceipt withdrawReceipt = await ethGetTransactionReceipt.SendRequestAsync(transactionId); EthGetBlockWithTransactionsByNumber ethGetBlockWithTransactionsByNumber = web3.Eth.Blocks.GetBlockWithTransactionsByNumber; BlockWithTransactions withdrawBlock = await ethGetBlockWithTransactionsByNumber.SendRequestAsync(withdrawReceipt.BlockNumber); //Draft Withdraw Object DraftWithdrawObject withdrawObject = new DraftWithdrawObject() { TxId = transactionId, Block = withdrawBlock, Tx = withdrawTransaction, Receipt = withdrawReceipt }; //Get Transaction Proof TransactionProofResponse transactionProof = await GetTxProof(withdrawObject.Tx, withdrawObject.Block); //Get Receipt Proof TransactionProofResponse receiptProof = await GetReceiptProof(withdrawObject.Receipt, withdrawObject.Block, web3); //Get Current Header Block HexBigInteger currentHeaderBlock = await maticRootChainContract.CurrenctHeaderBlock(); //Get the Header Header header = await maticRootChainContract.HeaderBlock(new HexBigInteger(currentHeaderBlock.Value - 1)); HexBigInteger headerNumber = new HexBigInteger(currentHeaderBlock.Value - 1); int start = header.Start; int end = header.End; Header headers = await GetHeaders(start, end, web3); MerkleTree tree = new MerkleTree(headers); string blockHeader = GetBlockHeader(withdrawObject.Block); string headerProof = await tree.GetProof(blockHeader); WithdrawBurntTokensModel withdrawBurntTokensModel = new WithdrawBurntTokensModel() { HeaderNumber = headerNumber, HeaderProof = "", BlockNumber = withdrawObject.Block.Number, BlockTimeStamp = withdrawObject.Block.Timestamp, TxRoot = withdrawObject.Block.TransactionsRoot, ReceiptRoot = withdrawObject.Block.ReceiptsRoot, Path = receiptProof.Path, TxBytes = withdrawObject.Tx.ToString(), TxProof = transactionProof.ParentNodes, ReceiptBytes = withdrawObject.Receipt.ToString(), ReceiptProof = receiptProof.ParentNodes }; string withdrawTxObject = await maticWithrawalManagerContract.WithdrawBurntTokens(withdrawBurntTokensModel, options); return(withdrawTxObject); }