I am trying to build a Web3 Distributed Application using .Net Core. For Testing and development, I am using Ganache's private net. When I try to make a function call to a deployed smart contract from Netherium Web3 object like this:
var contractAddress = "0x5c2d640027901a19B94ee0f9EEFFdc1cB660898a";
var abi = @"[{""inputs"": [],""stateMutability"": ..... Complete ABI";
var contract = web3.Eth.GetContract(abi, contractAddress);
var getFunction = contract.GetFunction("getCount");
var addfunction = contract.GetFunction("addNewRecords");
// This is my account's address
var senderAddress = account.Address;
//this works fine
var result_1 = await getFunction.CallAsync<int>();
// This Function Works fine
var gas = await addfunction.EstimateGasAsync(senderAddress, null, null, "Umer", "FAll2022", "[email protected]");
//Here exception is thrown
var result = await addfunction.SendTransactionAndWaitForReceiptAsync(senderAddress, gas, null, null, "Umer", "FAll2022", "[email protected]");
The above code throws an exception
RpcResponseException: Method eth_feeHistory not supported.: eth_feeHistory
Note that when I call a query function like:
await getFunction.CallAsync<int>();
This returns the correct result, but call to a payable function gives such exception.
Here is the solidity code for two called functions
function addNewRecords(string memory _name, string memory _email, string memory _rollNumber) public payable returns(bool)
{
// Increase the count by 1
stdCount = stdCount + 1;
// Fetch the student details
// with the help of stdCount
std_Records[int(stdCount)] = Student(_name,_email,_rollNumber);
return true;
}
function getCount() public view returns(uint){
return stdCount;
}
Can you please help me in this. I am adding the full error trace
RpcResponseException: Method eth_feeHistory not supported.: eth_feeHistory
Nethereum.JsonRpc.Client.ClientBase.HandleRpcError(RpcResponseMessage response, string reqMsg)
Nethereum.JsonRpc.Client.ClientBase.SendInnerRequestAsync<T>(RpcRequestMessage reqMsg, string route)
Nethereum.JsonRpc.Client.ClientBase.SendRequestAsync<T>(RpcRequest request, string route)
Nethereum.RPC.Fee1559Suggestions.TimePreferenceFeeSuggestionStrategy.SuggestFeesAsync()
Nethereum.RPC.Fee1559Suggestions.TimePreferenceFeeSuggestionStrategy.SuggestFeeAsync(Nullable<BigInteger> maxPriorityFeePerGas)
Nethereum.RPC.TransactionManagers.TransactionManagerBase.SetTransactionFeesOrPricingAsync(TransactionInput transaction)
Nethereum.Web3.Accounts.AccountSignerTransactionManager.SignTransactionRetrievingNextNonceAsync(TransactionInput transaction)
Nethereum.Web3.Accounts.AccountSignerTransactionManager.SignAndSendTransactionAsync(TransactionInput transaction)
Nethereum.Web3.Accounts.AccountSignerTransactionManager.SendTransactionAsync(TransactionInput transactionInput)
Nethereum.RPC.TransactionReceipts.TransactionReceiptPollingService.SendRequestAndWaitForReceiptAsync(Func<Task<string>> transactionFunction, CancellationToken cancellationToken)
BlockChainAppWeb.Controllers.HomeController.IndexAsync(Category c) in HomeController.cs
+
var result_2 = await addfunction.SendTransactionAndWaitForReceiptAsync(senderAddress, gas, null, null, "Umer", "Farooq", "Abc");
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask<IActionResult> actionResultValueTask)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
I don't know your specific logic, so I built a basic example referring to the official documentation, you can refer to it.
My functions use C#:
This problem does not occur in my example.
In addition, I saw other posts saying to disable EIP1559 transactions, you can have a try: