See T2503 for the pseudocode behind the generateTokenTxOutput function and how it'll be used by overarching token functions.
Part 1 caters for the genesis token tx where the relevant OP_RETURN script and token/xec outputs are added to the transaction builder.
Subsequent diff in this stack will cover the SEND/BURN OP_RETURN scripts and the additional outputs for token send/burn and token change.