Error when calling actor class constructor

On the ic network, when I execute a function which (among other things) calls the constructor of an actor class, I get the error:

The Replica returned an error: code 4, message: “Creating a canister requires a fee of 100000000000 that is deducted from the canister’s initial balance but only 0 cycles were received with the create_canister request.”

This, of course, does not happen when I test the code locally.
Should I put Cycles.add(100000000000) before calling the constructor? (it’s not done in the docs on actor classes)

Thanks,

EDIT: Solved below

Cycles.add() is in fact needed, but the amount of cycles to transfer is more than 100000000000. An insufficient amount can trigger somewhat obscure errors like:

The Replica returned an error: code 4, message: “IC0503: Canister … trapped explicitly: could not perform call”

3 Likes