Mix.install([
{:bsv, "~> 2.1"}
])
import IEx.Helpers
utxo =
BSV.UTXO.from_params!(%{
"txid" => "e791dd210ff6cfff912d6b1c6f4194df6ef79485580a01335b8e4840a5cf1940",
"vout" => 0,
"satoshis" => 5_000_000_000,
"script" =>
"4104c1ab1ac87ee26cd1799117007137c5682986e325698dd6f9d0f93889f2103d99d673b0dc9c939c7ce5310a32a45bb39adf06309861b6c4c71464eb11784aacd9ac"
})
# replace this with your privkey
privkey = "3cff04633088622e4599dc2ebf843f82cef3463b910d34a752a13622abae379b"
priv = BSV.PrivKey.from_binary!(privkey, encoding: :hex)
builder = %BSV.TxBuilder{
inputs: [
BSV.Contract.P2PK.unlock(utxo, %{privkey: priv})
],
outputs: [
BSV.Contract.P2PKH.lock(5_000_000_000 - 100, %{
address: BSV.Address.from_pubkey(BSV.PubKey.from_privkey(priv))
})
]
}
tx = BSV.TxBuilder.to_tx(builder)
BSV.Tx.to_binary(tx, encoding: :hex)