Exemple #1
0
        public Task <ResultWrapper <UInt256?> > eth_getBalance(Address address, BlockParameter blockParameter = null)
        {
            SearchResult <BlockHeader> searchResult = _blockFinder.SearchForHeader(blockParameter);

            if (searchResult.IsError)
            {
                return(Task.FromResult(ResultWrapper <UInt256?> .Fail(searchResult)));
            }

            BlockHeader header = searchResult.Object;

            if (!HasStateForBlock(header))
            {
                return(Task.FromResult(ResultWrapper <UInt256?> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable)));
            }

            Account account = _stateReader.GetAccount(header.StateRoot, address);

            return(Task.FromResult(ResultWrapper <UInt256?> .Success(account?.Balance ?? UInt256.Zero)));
        }