I am a little confused about how I use the block template... Basically what are the function calls I need to perform in order to mine a block template so I can then call submit block.
A block template is just that, a template for a block that a miner can perform work on (repeated hashing) to try and find a solution (a hash that meets the network difficulty) and then submit to the network.
So first a miner obtains a block template, typically using the daemon method get_block_template.
Next the miner relatedly updates the nonce space1 and performs a hash2 (using the RandomX hash function). If / when the resulting hash (which is just a number) meets the network difficulty, they can submit the block to the network using the daemon method submit_block.
Lastly, peer nodes validate that any proposed blocks hash meets the network difficulty. If no other miner submits a valid block (or chain of blocks) with more work done, after 60 blocks the miner gets paid the reward.
1 the nonce space can be any combination of the nonce field in the block header or in any reserved space of the miner transaction.
2 what actually gets hashed is a block hashing blob, which is a concatenation of the block header, a merkle root hash of the blocks transactions and a varint of the count of txs (src). A miner can either directly use the returned block hashing blob from get_block_template
or they can construct the block hashing blob themselves using the block template blob. The latter is required if the miner is changing the reserved space of the miner tx.