How to purchase and transfer an NFT from a contract to sp.sender?

I’m referring to the warning here: Operations | SmartPy

Which says that operations are done after the entrypoint is completed.
So in my flow:

  1. The contract buys the NFT
  2. The contract sends it from itself to sp.sender.

I’m not sure who has the NFT at the beginning of 2) It should be the contract as it buying the NFT.

Also, how would I construct t.transfer_params?
I wrote that:

           nftContract = sp.contract(t.transfer_params, nftAddress, entrypoint="transfer")
           nftContract.transfer([
                sp.record(
                    from_ = sp.self_address(), 
                    txs=[sp.record(token_id=nftId, amount=1, to_=sp.sender)]
                ),
            ])

Where nftId and nftAddress are params passed to my entrypoint. Based on what you shared here: Transfering FA2 between two users - #2 by Jordan

But I get the following error:

(nftContract : sp.option(sp.contract(sp.list(sp.record(from_ = sp.address, txs = sp.list(sp.record(amount = sp.nat, to_ = sp.address, token_id = sp.nat).layout(("to_", ("token_id", "amount"))))).layout(("from_", "txs")))))) has no field \'transfer\' of type sp.unknown
Expected type \'TRecord++(transfer = sp.unknown)\', but got \'sp.option(sp.contract(sp.list(sp.record(from_ = sp.address, txs = sp.list(sp.record(amount = sp.nat, to_ = sp.address, token_id = sp.nat).layout(("to_", ("token_id", "amount"))))).layout(("from_", "txs")))))\'.
(__main__, line 65)

I believe the import from the library is not working
Thanks!