A bitcoin transaction has a list of inputs and a list of outputs as you can see below:
When you want to create a transaction, you start with one or several output transaction that wasn’t used. It what we call an UTXO (Unspent Transaction Output), that is to say an unspent transaction output that can be used as an input in a new transaction.
So, let’s say someone locked some Bitcoins for you in the second output of the transaction we have seen before. This means that you somehow have the private key that can be used to create the unlocking script of that UTXO.
There is now at least one UTXO in the blockchain that you can use to create your transaction. You can create the input transaction with:
And you create one output with:
An important point to remember is that you must spend the whole UTXO, you cannot use only a part of it.