I feel like I missed something very obvious but after an hour of fiddling/googling I cannot get this to work. Code:
#Generate data from exponential model xd
Try
optimx(params, function(x) firstorder(x[1], x[2]))