Exactly what the title says. I've tried quite a few different ways but "creep.transferEnergy(Game.controller);" is the only one that didn't return an error.
I'm pretty sure transferEnergy() doesn't work for the controller, here's the code I found works for simple automation of the upgrade process.
if(creep.carry.energy < creep.carryCapacity) {
var sources = creep.room.find(FIND_SOURCES);
creep.moveTo(sources[0]);
creep.harvest(sources[0]);
}
else {
creep.moveTo(creep.room.controller);
creep.upgradeController(creep.room.controller)
}