Cardano-cli transaction build in Python env on Windows

(txhash,txix,funds)=Mint.get_utxo(address)

#Output of UTXO, 1.4 min
output=1400000

## Generate Metdata:
asset_name_hex=str("bTest").encode('UTF-8').hex()
test_file=[{"mediaType":"image/png","name":asset_name_hex,"src":test_ipfs}]

final,hex_toke=Mint.metadata_gen(check_policyID,asset_name_hex,real_name="TTC001",ipfs=test_ipfs,files=[test_file])

print(hex_toke)   #hex_toke is produce as policy_id.asset_name from metadata_gen function

#Build Transaction

output_gen=f"\"1 {hex_toke}\""
print(output_gen)
path2meta="C:\\Cardano\\Test_NFT\\meta.json"
path2script="C:\\Cardano\\Test_NFT\\policy\\script.policy"

#### CURRENTLY THIS WILL NOT WORK AS IT IS NOT RECOGNIZE FILE PATHS

cmd= [f"cardano-cli transaction build --mainnet --alonza-era -fee 0 --tx-in {txhash}#{txix} --tx-out {address}+{output}+{output_gen} \
 --change-address {address} --mint={output_gen} --minting-script-file {path2script} \
 --metadata-json-file {path2meta} --invalid-hereafter={slot} --witness-override 2 --out-file matx.raw"]


k=subprocess.Popen(cmd,  shell=True, text=True, stdout=subprocess.PIPE)

I am trying to build a simple all-Python NFT minter and I am getting stuck on building a transaction with cardano-cli.

I have tried at least 20 different variations of the file path and cmd scripts. Right now I am getting an error in my terminal saying that “System can not find specified file path”. Any help would be greatly appreciate. I am currently running Python 3.9 out of VS on Windows 10.

In the cmd variable, you need to give every parameter as a separate element in the list.
cmd = [“cardano-cli”, “transaction”, “build”, …]

1 Like