Performing write function to an EVM smart contract from a rust canister

I am trying to perform a write function to a smart contract deployed on sepolia. But whenever I call the write function I am getting this error:

(variant {Err="Failed to send transaction: "Transaction failed: HttpOutcallError(InvalidHttpJsonRpcResponse { status: 500, body: \"{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"id\\\":280397,\\\"error\\\":{\\\"code\\\":-32603,\\\"message\\\":\\\"Internal server error\\\"}}\", parsingError: None })""})

Here is my function:

#[ic_cdk::update]
async fn call_increase_count() -> Result<String, String> {
    let abi = get_abi();
    let canister_address = get_canister_eth_address().await;
    let nonce = get_nonce(&canister_address).await?;

    ic_cdk::println!("Canister address: {}", canister_address);
    ic_cdk::println!("Nonce: {:?}", nonce);

    let result = call_smart_contract(
        CONTRACT_ADDRESS.to_string(),
        &abi,
        "increaseCount",
        &[],
        true,
        Some(U64::from(11155111)), // Sepolia chain ID
        Some(CONTRACT_ADDRESS.to_string()),
        Some(U256::from(500000)), // Further increased gas limit
        Some(U256::from(0)),
        Some(nonce),
        Some(U256::from(3_000_000_000u64)), // Further increased max priority fee
        Some(U256::from(40_000_000_000u64)), // Further increased max fee
    )
    .await;
... 

This is my get nonce function:

async fn get_nonce(address: &str) -> Result<U256, String> {
    let rpc_services = RpcServices::EthSepolia(Some(vec![EthSepoliaService::Alchemy]));
    let config = None;
    let cycles = 10_000_000_000;

    let params = GetTransactionCountArgs {
        address: address.to_string(),
        block: BlockTag::Latest,
    };

    match EvmRpcCanister::eth_get_transaction_count(rpc_services, config, params, cycles).await {
        Ok((result,)) => match result {
            MultiGetTransactionCountResult::Consistent(count_result) => match count_result {
                GetTransactionCountResult::Ok(count) => Ok(U256::from(count)),
                GetTransactionCountResult::Err(err) => Err(format!("RPC error: {:?}", err)),
            },
            MultiGetTransactionCountResult::Inconsistent(_) => Err("Inconsistent RPC results".to_string()),
        },
        Err(e) => Err(format!("Failed to get nonce: {:?}", e)),
    }
}

Where might I be going wrong?

Hi there. Sorry you’re having trouble. Were there any other logs provided? a 500 indicates a server error that likely originated on the rpc provider side. Were you able to get past this error or are you still experiencing the same issue?

Hello. I am still experiencing the same issue. You can check out the “call_increase_count()” function in this canister: DFINITY Canister Candid UI