In a bowl, mix the chickpea flour and oil with a pinch of sea salt and 290ml water, and whisk until smooth. Leave to stand for 30 minutes.
Peel and finely slice the onions, pick and finely chop the rosemary and thinly slice the anchovies. Destone the olives.
Melt the butter in a pan over a low heat, then add the onions and sugar. Cook for 25 minutes, or until coloured, stirring occasionally.
Preheat the oven to 200ºC/gas 6. Heat a frying pan over a medium heat.
Stir the rosemary into the batter, then cook the socca in batches. Spoon tablespoons of batter into the hot pan and cook for 1 minute on each side, or until golden. Transfer to a tray lined with baking paper.
Top each socca with the caramelised onion, anchovies and olives, and bake for 10 minutes. Serve immediately.