1

When this code runs, it throws an error "RpcResponseException: header not found", and I don't understand why or how to fix it. Any advice?

Notes: I am using Nethereum in C#.net and using Infura API

[Function("balanceOf", "uint256")]
public class BalanceOfFunction : FunctionMessage
{
    [Parameter("address", "_owner", 1)]
    public string Owner { get; set; }
}



public void QueryingForBalanceAtBlockNumberWorksAsExpected()
{
    HexBigInteger blockNumber = new HexBigInteger("10933333");
    var web3 = new Nethereum.Web3.Web3("https://mainnet.infura.io/v3/" + _InfuraAPIKey);

    string contractAddress = "0x514910771af9ca656af840dff83e8264ecf986ca"; //chainlink

    string accountAddress = "0x56d065849ef9c59c1bc5ba54b9f96caba5c88812";
    
    var balanceOfFunctionMessage = new BalanceOfFunction()
    {
        Owner = accountAddress,
    };

    var balanceHandler = web3.Eth.GetContractQueryHandler<BalanceOfFunction>();

    //THIS WILL THROW AN ERROR "RpcResponseException: header not found":
    var balanceInBaseUnits = balanceHandler.QueryAsync<BigInteger>(contractAddress, balanceOfFunctionMessage, new Nethereum.RPC.Eth.DTOs.BlockParameter(blockNumber)).Result;
}

1 Answer 1

1

I have been told that:

this will be due when trying to query a very old block and the public node is not an archiving one. (Maintaining all the previous States)

https://infura.io/pricing has an "add-on" for "Archiving Data" for $250/month which appears to be the answer.

also relevant: https://infura.io/docs/ethereum/add-ons/archiveData

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.