AddParam() public method

public AddParam ( object value ) : void
value object
return void
Ejemplo n.º 1
0
        public Block GetBlockByNumber(int blockNumber, BlockTag blockTag, bool returnFullObject)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockByNumber);

            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToHexString());
            }

            rpcRequest.AddParam(returnFullObject);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json      = JsonConvert.SerializeObject(rpcResult.Result);
            var block     = JsonConvert.DeserializeObject <Block>(json);

            return(block);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the number of transactions sent from an address.
        /// </summary>
        /// <param name="address">address</param>
        /// <param name="blockTag">Block Param</param>
        /// <param name="blockNumber">integer block number,</param>
        /// <returns>integer of the number of transactions send from this address.</returns>
        public long GetTransactionCount(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionCount);

            rpcRequest.AddParam(address);

            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToString());
            }

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var balance   = Convert.ToInt64(rpcResult.Result, 16);

            return(balance);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the balance of the account of given address.
        /// </summary>
        /// <param name="address">address to check for balance.</param>
        /// <param name="blockTag"> integer block number</param>
        /// <param name="blockNumber">Block param</param>
        /// <returns></returns>
        public BigInteger GetBalance(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBalance);

            rpcRequest.AddParam(address);
            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToString());
            }

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            if (rpcResult.Result == null)
            {
                return(0);
            }

            string value   = rpcResult.Result.ToString();
            var    balance = value.ToBigInteger();

            return(balance);
        }
Ejemplo n.º 4
0
        public Block GetBlockByHash(string hash, bool returnFullBlock)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockByHash);

            rpcRequest.AddParam(hash);
            rpcRequest.AddParam(returnFullBlock);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json      = JsonConvert.SerializeObject(rpcResult.Result);

            var block            = JsonConvert.DeserializeObject <Block>(json);
            var jsonTransactions = JsonConvert.SerializeObject(rpcResult.Result.transactions);

            if (returnFullBlock)
            {
                block.TransactionsFull = JsonConvert.DeserializeObject <List <Transaction> >(jsonTransactions);

                if (block.TransactionsFull.Count > 0)
                {
                    int i = 100;
                }
            }
            else
            {
                block.TransactionHashes = JsonConvert.DeserializeObject <string>(jsonTransactions);
            }


            return(block);
        }
        public string Call(Transaction transaction)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_call);
            rpcRequest.AddParam(transaction);
            rpcRequest.AddParam(BlockTag.Latest.ToJsonMethodName());

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            return rpcResult.Result;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Used for submitting mining hashrate.
        /// </summary>
        /// <param name="hashRate">a hexadecimal string representation (32 bytes) of the hash rate</param>
        /// <param name="clientId">A random hexadecimal(32 bytes) ID identifying the client</param>
        /// <returns></returns>
        public bool SubmitHashrate(string hashRate, string clientId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_submitHashrate);
            var rpcResult  = new RpcConnector().MakeRequest(rpcRequest);

            rpcRequest.AddParam(hashRate);
            rpcRequest.AddParam(clientId);

            return(rpcResult.Result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Signs data with a given address.
        /// </summary>
        /// <param name="address">address</param>
        /// <param name="data">Data to sign</param>
        /// <returns>Signed data</returns>
        public string Sign(string address, string data)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_sign);

            rpcRequest.AddParam(address);
            rpcRequest.AddParam(data);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Used for submitting a proof-of-work solution.
        /// </summary>
        /// <param name="nonce">The nonce found(64 bits)</param>
        /// <param name="powHash">The header's pow-hash (256 bits)</param>
        /// <param name="mix">The mix digest(256 bits)</param>
        /// <returns> returns true if the provided solution is valid, otherwise false.</returns>
        public bool SubmitWork(string nonce, string powHash, string mix)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_submitWork);
            var rpcResult  = new RpcConnector().MakeRequest(rpcRequest);

            rpcRequest.AddParam(nonce);
            rpcRequest.AddParam(powHash);
            rpcRequest.AddParam(mix);

            return(rpcResult.Result);
        }
Ejemplo n.º 9
0
        public string Call(Transaction transaction)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_call);

            rpcRequest.AddParam(transaction);
            rpcRequest.AddParam(BlockTag.Latest.ToJsonMethodName());

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 10
0
        public Transaction GetTransactionByBlockHashAndIndex(string hash, int index)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionByBlockHashAndIndex);

            rpcRequest.AddParam(hash);
            rpcRequest.AddParam(index.ToHexString());
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json      = JsonConvert.SerializeObject(rpcResult.Result);
            var tx        = JsonConvert.DeserializeObject <Transaction>(json);

            return(tx);
        }
Ejemplo n.º 11
0
        public Transaction GetTransactionByHash(string hash)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionByHash);

            rpcRequest.AddParam(hash);
            rpcRequest.AddParam("true");
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json      = JsonConvert.SerializeObject(rpcResult.Result);
            var tx        = JsonConvert.DeserializeObject <Transaction>(json);

            return(tx);
        }
Ejemplo n.º 12
0
        public Block GetUncleByBlockNumberAndIndex(int blockNumber, int index)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getUncleByBlockNumberAndIndex);

            rpcRequest.AddParam(blockNumber.ToHexString());
            rpcRequest.AddParam(index.ToHexString());

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json      = JsonConvert.SerializeObject(rpcResult.Result);
            var block     = JsonConvert.DeserializeObject <Block>(json);

            return(block);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Unlocks account using password
        /// </summary>
        /// <param name="account">The account address</param>
        /// <param name="password">The password for the account</param>
        /// <returns></returns>
        public bool UnlockAccount(string account, string password)
        {
            var rpcRequest = new RpcRequest(RpcMethod.personal_unlockAccount);

            rpcRequest.AddParam(account);
            rpcRequest.AddParam(password);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            if (rpcResult.Error != null)
            {
                return(false);
            }

            return(rpcResult.Result);
        }
Ejemplo n.º 14
0
        public RpcResult CompileSolidity(string contract)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_compileSolidity);

            rpcRequest.AddParam(contract);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult);
        }
        public RpcResult CompileSolidity(string contract)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_compileSolidity);

            rpcRequest.AddParam(contract);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return rpcResult;
        }
Ejemplo n.º 16
0
        public bool UninstallFilter(string filterId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_uninstallFilter);

            rpcRequest.AddParam(filterId);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates new message call transaction or a contract creation for signed transactions.
        /// </summary>
        /// <param name="data">The signed transaction data.</param>
        /// <returns> the transaction hash, or the zero hash if the transaction is not yet available.</returns>
        public string SendRawTransaction(string data)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_sendRawTransaction);

            rpcRequest.AddParam(new { data = data });
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///  Returns Keccak-256 (not the standardized SHA3-256) of the given data.
        /// </summary>
        /// <param name="value"> the data to convert into a SHA3 hash</param>
        /// <returns>The SHA3 result of the given string.</returns>
        public string GetWeb3Sha3(string value)
        {
            var rpcRequest = new RpcRequest(RpcMethod.web3_sha3);

            rpcRequest.AddParam(value);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 19
0
        public string NewAccount(string password)
        {
            var rpcRequest = new RpcRequest(RpcMethod.personal_newAccount);

            rpcRequest.AddParam(password);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call GetFilterChanges.
        /// </summary>
        /// <param name="fromBlock">(optional, default: "latest") Integer block number, </param>
        /// <param name="toBlock"></param>
        /// <param name="address"></param>
        /// <param name="topics"></param>
        /// <returns></returns>
        public string NewFilter(Filter filter)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_newFilter);

            rpcRequest.AddParam(filter);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Returns the number of uncles in a block from a block matching the given block number.
        /// </summary>
        /// <param name="blockNumber">integer of a block number</param>
        /// <returns>integer of the number of uncles in this block.</returns>
        public long GetUncleCountByBlockNumber(int blockNumber)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getUncleCountByBlockNumber);

            rpcRequest.AddParam(blockNumber.ToHexString());
            var rpcResult      = new RpcConnector().MakeRequest(rpcRequest);
            var ethBlockNumber = Convert.ToInt64(rpcResult.Result, 16);

            return(ethBlockNumber);
        }
Ejemplo n.º 22
0
        public string SendTransaction(Transaction transaction)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_sendTransaction);

            rpcRequest.AddParam(transaction);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 23
0
        public string EstimateGas(Transaction transaction)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_estimateGas);

            rpcRequest.AddParam(transaction);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            string gas = rpcResult.Result.ToString();

            //var estimatedGas = gas.HexToInt();

            return(gas);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Returns code at a given address.
        /// </summary>
        /// <param name="address">address</param>
        /// <param name="blockTag"></param>
        /// <param name="blockNumber">integer block number,</param>
        /// <returns></returns>
        public string GetCode(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getCode);

            rpcRequest.AddParam(address);

            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToHexString());
            };
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 25
0
        public string[] GetLogs(Log log)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getLogs);

            rpcRequest.AddParam(log);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var list      = new List <string>();

            foreach (var account in rpcResult.Result)
            {
                list.Add(account.Value);
            }
            return(list.ToArray());
        }
Ejemplo n.º 26
0
        public List <string> GetBlockFilterChanges(string filterId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getFilterChanges);

            rpcRequest.AddParam(filterId);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var list      = new List <string>();

            foreach (var blockHash in rpcResult.Result)
            {
                list.Add(blockHash.ToString());
            }
            return(list);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Returns the number of uncles in a block from a block matching the given block hash.
        /// </summary>
        /// <param name="hashBlock">hash of a block</param>
        /// <returns> integer of the number of uncles in this block.</returns>
        public long GetUncleCountByBlockHash(string hashBlock)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getUncleCountByBlockHash);

            rpcRequest.AddParam(hashBlock);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            if (rpcResult.Result == null)
            {
                return(0);
            }
            var ethBlockNumber = Convert.ToInt64(rpcResult.Result, 16);

            return(ethBlockNumber);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Returns the number of transactions in a block from a block matching the given block hash.
        /// </summary>
        /// <param name="blockHash"> hash of a block</param>
        /// <returns> integer of the number of transactions in this block.</returns>
        public long GetBlockTransactionCountByHash(string blockHash)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockTransactionCountByHash);

            //todo validate the 20 byte block hash
            rpcRequest.AddParam(blockHash);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            if (rpcResult.Result == null)
            {
                return(0);
            }
            var count = Convert.ToInt64(rpcResult.Result, 16);

            return(count);
        }
Ejemplo n.º 29
0
        public Log[] GetFilterChanges(string filterId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getFilterChanges);

            rpcRequest.AddParam(filterId);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var list      = new List <Log>();

            foreach (var account in rpcResult.Result)
            {
                var log = new Log(account);

                list.Add(log);
            }
            return(list.ToArray());
        }
Ejemplo n.º 30
0
        public string ShhPost(string from, string to, string[] topics, string payload, string priority, string ttl)
        {
            var rpcRequest = new RpcRequest(RpcMethod.shh_post);

            var whisper = new Whisper()
            {
                From     = "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1",
                To       = "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1",
                Payload  = "0x7b2274797065223a226d6",
                Priority = "0x64",
                Ttl      = "0x64",
            };

            rpcRequest.AddParam(whisper);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Creates new message call transaction or a contract creation, if the data field contains code.
        /// </summary>
        /// <param name="from">The address the transaction is send from.</param>
        /// <param name="to">(optional when creating new contract) The address the transaction is directed to.</param>
        /// <param name="gas">(optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.</param>
        /// <param name="data">(optional) The compiled code of a contract</param>
        /// <param name="gasPrice">(optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas</param>
        /// <param name="value">(optional) Integer of the value send with this transaction</param>
        /// <param name="nonce">(optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.</param>
        /// <returns>the transaction hash, or the zero hash if the transaction is not yet available.</returns>
        public string SendTransaction(string from, string to, int gas, string data, int gasPrice = -1, int value = -1, int nonce = -1)
        {
            var rpcRequest        = new RpcRequest(RpcMethod.eth_sendTransaction);
            var transactionParams = new Transaction();

            transactionParams.To = to;

            if (from != null)
            {
                transactionParams.From = from;
            }

            if (data != null)
            {
                transactionParams.Data = data;
            }

            if (gas > -1)
            {
                transactionParams.Gas = gas.ToHexString();
            }

            if (gasPrice > -1)
            {
                transactionParams.GasPrice = gas.ToHexString();
            }

            if (value > -1)
            {
                transactionParams.Value = value.ToHexString();
            }

            if (nonce > -1)
            {
                transactionParams.Nonce = nonce.ToHexString();
            }

            rpcRequest.AddParam(transactionParams);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return(rpcResult.Result);
        }
        /// <summary>
        /// Returns the number of uncles in a block from a block matching the given block number.
        /// </summary>
        /// <param name="blockNumber">integer of a block number</param>
        /// <returns>integer of the number of uncles in this block.</returns>
        public long GetUncleCountByBlockNumber(int blockNumber)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getUncleCountByBlockNumber);
            rpcRequest.AddParam(blockNumber.ToHexString());
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var ethBlockNumber = Convert.ToInt64(rpcResult.Result, 16);

            return ethBlockNumber;
        }
        /// <summary>
        /// Unlocks account using password
        /// </summary>
        /// <param name="account">The account address</param>
        /// <param name="password">The password for the account</param>
        /// <returns></returns>
        public bool UnlockAccount(string account, string password)
        {
            var rpcRequest = new RpcRequest(RpcMethod.personal_unlockAccount);
            rpcRequest.AddParam(account);
            rpcRequest.AddParam(password);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            if (rpcResult.Error != null)
            {
                return false;
            }

            return rpcResult.Result;
        }
        public Block GetBlockByNumber(int blockNumber, BlockTag blockTag, bool returnFullObject)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockByNumber);
            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToHexString());
            }

            rpcRequest.AddParam(returnFullObject);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json = JsonConvert.SerializeObject(rpcResult.Result);
            var block = JsonConvert.DeserializeObject<Block>(json);
            return block;
        }
        /// <summary>
        /// Returns the number of transactions in a block from a block matching the given block hash.
        /// </summary>
        /// <param name="blockHash"> hash of a block</param>
        /// <returns> integer of the number of transactions in this block.</returns>
        public long GetBlockTransactionCountByHash(string blockHash)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockTransactionCountByHash);
            //todo validate the 20 byte block hash
            rpcRequest.AddParam(blockHash);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            if (rpcResult.Result == null)
                return 0;
            var count = Convert.ToInt64(rpcResult.Result, 16);

            return count;
        }
        public Log[] GetFilterChanges(string filterId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getFilterChanges);
            rpcRequest.AddParam(filterId);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var list = new List<Log>();

            foreach (var account in rpcResult.Result)
            {
                var log = new Log(account);

                list.Add(log);
            }
            return list.ToArray();
        }
        public Transaction GetTransactionByBlockNumberAndIndex(int blockNumber, int index)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionByBlockNumberAndIndex);
            rpcRequest.AddParam(blockNumber.ToHexString());
            rpcRequest.AddParam(index.ToHexString());

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json = JsonConvert.SerializeObject(rpcResult.Result);
            var tx = JsonConvert.DeserializeObject<Transaction>(json);

            return tx;
        }
        public Transaction GetTransactionReceipt(string transactionHash)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionReceipt);
            rpcRequest.AddParam(transactionHash);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json = JsonConvert.SerializeObject(rpcResult.Result);
            var tx = JsonConvert.DeserializeObject<Transaction>(json);

            return tx;
        }
        public string ShhPost(string from, string to, string[] topics, string payload, string priority, string ttl)
        {
            var rpcRequest = new RpcRequest(RpcMethod.shh_post);

            var whisper = new Whisper()
            {
                From = "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1",
                To = "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1",
                Payload =  "0x7b2274797065223a226d6",
                Priority = "0x64",
                Ttl = "0x64",
            };

            rpcRequest.AddParam(whisper);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            return rpcResult.Result;
        }
        public string EstimateGas(Transaction transaction)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_estimateGas);
            rpcRequest.AddParam(transaction);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            string gas = rpcResult.Result.ToString();
            //var estimatedGas = gas.HexToInt();

            return gas;
        }
 /// <summary>
 /// Signs data with a given address.
 /// </summary>
 /// <param name="address">address</param>
 /// <param name="data">Data to sign</param>
 /// <returns>Signed data</returns>
 public string Sign(string address, string data)
 {
     var rpcRequest = new RpcRequest(RpcMethod.eth_sign);
     rpcRequest.AddParam(address);
     rpcRequest.AddParam(data);
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     return rpcResult.Result;
 }
        /// <summary>
        /// Used for submitting mining hashrate.
        /// </summary>
        /// <param name="hashRate">a hexadecimal string representation (32 bytes) of the hash rate</param>
        /// <param name="clientId">A random hexadecimal(32 bytes) ID identifying the client</param>
        /// <returns></returns>
        public bool SubmitHashrate(string hashRate, string clientId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_submitHashrate);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            rpcRequest.AddParam(hashRate);
            rpcRequest.AddParam(clientId);

            return rpcResult.Result;
        }
        /// <summary>
        /// Used for submitting a proof-of-work solution.
        /// </summary>
        /// <param name="nonce">The nonce found(64 bits)</param>
        /// <param name="powHash">The header's pow-hash (256 bits)</param>
        /// <param name="mix">The mix digest(256 bits)</param>
        /// <returns> returns true if the provided solution is valid, otherwise false.</returns>
        public bool SubmitWork(string nonce, string powHash, string mix)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_submitWork);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            rpcRequest.AddParam(nonce);
            rpcRequest.AddParam(powHash);
            rpcRequest.AddParam(mix);

            return rpcResult.Result;
        }
 public bool UninstallFilter(string filterId)
 {
     var rpcRequest = new RpcRequest(RpcMethod.eth_uninstallFilter);
     rpcRequest.AddParam(filterId);
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     return rpcResult.Result;
 }
 /// <summary>
 /// Returns the number of uncles in a block from a block matching the given block hash.
 /// </summary>
 /// <param name="hashBlock">hash of a block</param>
 /// <returns> integer of the number of uncles in this block.</returns>
 public long GetUncleCountByBlockHash(string hashBlock)
 {
     var rpcRequest = new RpcRequest(RpcMethod.eth_getUncleCountByBlockHash);
     rpcRequest.AddParam(hashBlock);
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     if (rpcResult.Result == null)
         return 0;
     var ethBlockNumber = Convert.ToInt64(rpcResult.Result, 16);
     return ethBlockNumber;
 }
        public string SendTransaction(Transaction transaction)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_sendTransaction);

            rpcRequest.AddParam(transaction);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return rpcResult.Result;
        }
        public Block GetUncleByBlockNumberAndIndex(int blockNumber, int index)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getUncleByBlockNumberAndIndex);
            rpcRequest.AddParam(blockNumber.ToHexString());
            rpcRequest.AddParam(index.ToHexString());

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json = JsonConvert.SerializeObject(rpcResult.Result);
            var block = JsonConvert.DeserializeObject<Block>(json);

            return block;
        }
        /// <summary>
        /// Creates new message call transaction or a contract creation, if the data field contains code.
        /// </summary>
        /// <param name="from">The address the transaction is send from.</param>
        /// <param name="to">(optional when creating new contract) The address the transaction is directed to.</param>
        /// <param name="gas">(optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas.</param>
        /// <param name="data">(optional) The compiled code of a contract</param>
        /// <param name="gasPrice">(optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas</param>
        /// <param name="value">(optional) Integer of the value send with this transaction</param>
        /// <param name="nonce">(optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.</param>
        /// <returns>the transaction hash, or the zero hash if the transaction is not yet available.</returns>
        public string SendTransaction(string from, string to, int gas, string data, int gasPrice = -1, int value = -1, int nonce = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_sendTransaction);
            var transactionParams = new Transaction();
            transactionParams.To = to;

            if (from != null)
                transactionParams.From = from;

            if (data != null)
                transactionParams.Data = data;

            if (gas > -1)
                transactionParams.Gas = gas.ToHexString();

            if (gasPrice > -1)
                transactionParams.GasPrice = gas.ToHexString();

            if (value > -1)
                transactionParams.Value = value.ToHexString();

            if (nonce > -1)
                transactionParams.Nonce = nonce.ToHexString();

            rpcRequest.AddParam(transactionParams);

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return rpcResult.Result;
        }
        /// <summary>
        /// Returns the number of transactions sent from an address.
        /// </summary>
        /// <param name="address">address</param>
        /// <param name="blockTag">Block Param</param>
        /// <param name="blockNumber">integer block number,</param>
        /// <returns>integer of the number of transactions send from this address.</returns>
        public long GetTransactionCount(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionCount);
            rpcRequest.AddParam(address);

            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToString());
            }

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var balance = Convert.ToInt64(rpcResult.Result, 16);
            return balance;
        }
 /// <summary>
 /// Creates new message call transaction or a contract creation for signed transactions.
 /// </summary>
 /// <param name="data">The signed transaction data.</param>
 /// <returns> the transaction hash, or the zero hash if the transaction is not yet available.</returns>
 public string SendRawTransaction(string data)
 {
     var rpcRequest = new RpcRequest(RpcMethod.eth_sendRawTransaction);
     rpcRequest.AddParam(new { data = data });
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     return rpcResult.Result;
 }
 public string[] GetLogs(Log log)
 {
     var rpcRequest = new RpcRequest(RpcMethod.eth_getLogs);
     rpcRequest.AddParam(log);
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     var list = new List<string>();
     foreach (var account in rpcResult.Result)
     {
         list.Add(account.Value);
     }
     return list.ToArray();
 }
        /// <summary>
        /// Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call GetFilterChanges.
        /// </summary>
        /// <param name="fromBlock">(optional, default: "latest") Integer block number, </param>
        /// <param name="toBlock"></param>
        /// <param name="address"></param>
        /// <param name="topics"></param>
        /// <returns></returns>
        public string NewFilter(Filter filter)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_newFilter);

            rpcRequest.AddParam(filter);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return rpcResult.Result;
        }
        /// <summary>
        /// Returns code at a given address.
        /// </summary>
        /// <param name="address">address</param>
        /// <param name="blockTag"></param>
        /// <param name="blockNumber">integer block number,</param>
        /// <returns></returns>
        public string GetCode(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getCode);
            rpcRequest.AddParam(address);

            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToHexString());
            };
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            return rpcResult.Result;
        }
 public string NewAccount(string password)
 {
     var rpcRequest = new RpcRequest(RpcMethod.personal_newAccount);
     rpcRequest.AddParam(password);
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     return rpcResult.Result;
 }
        public List<string> GetBlockFilterChanges(string filterId)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getFilterChanges);
            rpcRequest.AddParam(filterId);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var list = new List<string>();

            foreach (var blockHash in rpcResult.Result)
            {
                list.Add(blockHash.ToString());
            }
            return list;
        }
 /// <summary>
 ///  Returns Keccak-256 (not the standardized SHA3-256) of the given data.
 /// </summary>
 /// <param name="value"> the data to convert into a SHA3 hash</param>
 /// <returns>The SHA3 result of the given string.</returns>
 public string GetWeb3Sha3(string value)
 {
     var rpcRequest = new RpcRequest(RpcMethod.web3_sha3);
     rpcRequest.AddParam(value);
     var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
     return rpcResult.Result;
 }
        /// <summary>
        /// Returns the balance of the account of given address.
        /// </summary>
        /// <param name="address">address to check for balance.</param>
        /// <param name="blockTag"> integer block number</param>
        /// <param name="blockNumber">Block param</param>
        /// <returns></returns>
        public BigInteger GetBalance(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBalance);
            rpcRequest.AddParam(address);
            if (blockTag != BlockTag.Quantity && blockNumber > -1)
            {
                throw new Exception("Balance tag and block number cannot both be provided, chose either");
            }

            if (blockTag != BlockTag.Quantity)
            {
                rpcRequest.AddParam(blockTag.ToJsonMethodName());
            }
            else
            {
                rpcRequest.AddParam(blockNumber.ToString());
            }

            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);

            if (rpcResult.Result == null)
            {
                return 0;
            }

            string value = rpcResult.Result.ToString();
            var balance = value.ToBigInteger();

            return balance;
        }
        public Block GetBlockByHash(string hash,bool returnFullBlock)
        {
            var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockByHash);
            rpcRequest.AddParam(hash);
            rpcRequest.AddParam(returnFullBlock);
            var rpcResult = new RpcConnector().MakeRequest(rpcRequest);
            var json = JsonConvert.SerializeObject(rpcResult.Result);

            var block = JsonConvert.DeserializeObject<Block>(json);
            var jsonTransactions = JsonConvert.SerializeObject(rpcResult.Result.transactions);

            if (returnFullBlock)
            {
                block.TransactionsFull = JsonConvert.DeserializeObject<List<Transaction>>(jsonTransactions);

                if (block.TransactionsFull.Count > 0)
                {
                    int i = 100;
                }
            }
            else
            {
                block.TransactionHashes = JsonConvert.DeserializeObject<string>(jsonTransactions);
            }

            return block;
        }