diff --git a/complete_build.sh b/complete_build.sh index 075b7ea..eb4dc64 100755 --- a/complete_build.sh +++ b/complete_build.sh @@ -14,10 +14,10 @@ rm -fr build/ || true echo -e "\033[1;34m Building Contracts \033[0m" # remove all traces for production -aiken build --trace-level silent --filter-traces user-defined +# aiken build --trace-level silent --filter-traces user-defined # keep the traces for testing -# aiken build --trace-level verbose --filter-traces all +aiken build --trace-level verbose --filter-traces all ran=$(jq -r '.random_string' config.json) ran_cbor=$(python3 -c "import cbor2;hex_string='${ran}';data = bytes.fromhex(hex_string);encoded = cbor2.dumps(data);print(encoded.hex())") diff --git a/config.json b/config.json index eca80ab..a6257ca 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,9 @@ { "__comment1__": "Genesis UTxO From Starter Wallet", - "genesis_tx_id": "d91cc6ef03ac89d5534535f236b40d9933a438a09cdc468ed878ad7a197e61fe", - "genesis_tx_idx": 1, + "genesis_tx_id": "57d3a65415bc240fafbd636afde43ae32a42fdf0b46edced0666953cbe161cf1", + "genesis_tx_idx": 0, "__comment2__": "Random String For Data Reference", - "random_string": "10" + "random_string": "11", + "__comment3__": "Change address for reference and genesis", + "change_address": "addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp" } \ No newline at end of file diff --git a/headless/00_createScriptReferences.sh b/headless/00_createScriptReferences.sh index 4daed39..f35eba2 100755 --- a/headless/00_createScriptReferences.sh +++ b/headless/00_createScriptReferences.sh @@ -14,6 +14,10 @@ reference_address=$(cat ./wallets/reference-wallet/payment.addr) reference_script_path="../contracts/reference_contract.plutus" script_reference_address=$(${cli} address build --payment-script-file ${reference_script_path} ${network}) +# address to send the leftover ada too +change_address=$(jq -r '.change_address' ../config.json) + + echo -e "\033[0;35m\nGathering UTxO Information \033[0m" ${cli} query utxo \ ${network} \ @@ -62,12 +66,9 @@ do --tx-out-reference-script-file ${contract} \ --fee 900000 - FEE=$(cardano-cli transaction calculate-min-fee \ + FEE=$(${cli} transaction calculate-min-fee \ --tx-body-file ./tmp/tx.draft \ - ${network} \ --protocol-params-file ./tmp/protocol.json \ - --tx-in-count 1 \ - --tx-out-count 2 \ --witness-count 1) echo -e "\033[0;35mFEE: ${FEE} \033[0m" fee=$(echo $FEE | rev | cut -c 9- | rev) @@ -90,12 +91,44 @@ do --out-file ./tmp/utxo-${file_name}.signed \ ${network} - ref_tx_in=$(${cli} transaction txid --tx-body-file ./tmp/tx.draft)#0 + tx_id=$(${cli} transaction txid --tx-body-file ./tmp/tx.draft) + ref_tx_in=${tx_id}#0 echo - echo -e "\033[0;36mNext UTxO: $ref_tx_in \033[0m" + echo -e "\033[0;36m$file_name: $tx_id#1 \033[0m" done +${cli} transaction build-raw \ + --babbage-era \ + --protocol-params-file ./tmp/protocol.json \ + --out-file ./tmp/tx.draft \ + --tx-in ${ref_tx_in} \ + --tx-out="${change_address} + ${changeAmount}" \ + --fee 900000 + +FEE=$(${cli} transaction calculate-min-fee \ + --tx-body-file ./tmp/tx.draft \ + --protocol-params-file ./tmp/protocol.json \ + --witness-count 1) +echo -e "\033[0;35mFEE: ${FEE} \033[0m" +fee=$(echo $FEE | rev | cut -c 9- | rev) + +changeAmount=$((${changeAmount} - ${fee})) + +${cli} transaction build-raw \ + --babbage-era \ + --protocol-params-file ./tmp/protocol.json \ + --out-file ./tmp/tx.draft \ + --tx-in ${ref_tx_in} \ + --tx-out="${change_address} + ${changeAmount}" \ + --fee ${fee} + +${cli} transaction sign \ + --signing-key-file ./wallets/reference-wallet/payment.skey \ + --tx-body-file ./tmp/tx.draft \ + --out-file ./tmp/change-tx.signed \ + ${network} + echo -e "\033[1;37m --------------------------------------------------------------------------------\033[0m" # now submit them in that order for contract in $(ls "../contracts"/* | sort -V) @@ -108,4 +141,8 @@ do --tx-file ./tmp/utxo-${file_name}.signed done +${cli} transaction submit \ + ${network} \ + --tx-file ./tmp/change-tx.signed + echo -e "\033[0;32m\nDone!\033[0m" \ No newline at end of file diff --git a/headless/01_genesisMint.sh b/headless/01_genesisMint.sh index 70b0905..821d177 100755 --- a/headless/01_genesisMint.sh +++ b/headless/01_genesisMint.sh @@ -19,7 +19,7 @@ genesis_policy_id=$(cat ../hashes/genesis_contract.hash) starter_address=$(cat wallets/starter-wallet/payment.addr) starter_pkh=$(${cli} address key-hash --payment-verification-key-file wallets/starter-wallet/payment.vkey) -change_address="addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp" +change_address=$(jq -r '.change_address' ../config.json) # collat wallet collat_address=$(cat wallets/collat-wallet/payment.addr) @@ -80,17 +80,10 @@ collat_utxo=$(jq -r 'keys[0]' tmp/collat_utxo.json) genesis_ref_utxo=$(${cli} transaction txid --tx-file tmp/utxo-genesis_contract.plutus.signed ) -# slot contraints -slot=$(${cli} query tip ${network} | jq .slot) -current_slot=$(($slot - 1)) -final_slot=$(($slot + 2500)) - echo -e "\033[0;36m Building Tx \033[0m" FEE=$(${cli} transaction build \ --babbage-era \ --out-file tmp/tx.draft \ - --invalid-before ${current_slot} \ - --invalid-hereafter ${final_slot} \ --change-address ${change_address} \ --tx-in-collateral="${collat_utxo}" \ --tx-in ${starter_tx_in} \ diff --git a/headless/cogno/01_createCogno.sh b/headless/cogno/01_createCogno.sh index 5899c1a..508d1f9 100755 --- a/headless/cogno/01_createCogno.sh +++ b/headless/cogno/01_createCogno.sh @@ -69,7 +69,6 @@ UTXO_VALUE=$(${cli} transaction calculate-min-required-utxo \ --tx-out="${cogno_script_address} + 5000000 + ${MINT_ASSET}" | tr -dc '0-9') cogno_address_out="${cogno_script_address} + ${UTXO_VALUE} + ${MINT_ASSET}" - echo "Cogno OUTPUT:" ${cogno_address_out} # # exit diff --git a/headless/data/cogno/token.name b/headless/data/cogno/token.name index ea49282..01ddd5e 100644 --- a/headless/data/cogno/token.name +++ b/headless/data/cogno/token.name @@ -1 +1 @@ -cafebabe00ac8e5e2f504e19d70a15539d99f863bb0bebc3f5c445fa9b42a566 +cafebabe0035b6040bb1810776a1bea50e956e754fffd48f95bb53f01558c945 diff --git a/headless/data/reference/reference-datum.json b/headless/data/reference/reference-datum.json index 8f1e577..4c63b51 100644 --- a/headless/data/reference/reference-datum.json +++ b/headless/data/reference/reference-datum.json @@ -2,16 +2,16 @@ "constructor": 0, "fields": [ { - "bytes": "cfa60e85f9dcd52a44c4552e1c9d692deaa43837dff2097546914389" + "bytes": "bf06b7349e9f67106d10fa677ab0d3fcd6a6f25cd4bd73e42118c376" }, { - "bytes": "cdab6680f11d19226419cd9012d3f57dbb1d775cb5d0d80f18b6a361" + "bytes": "5b5aca6197430cdf2e6e4158dbda759807b3ffb7df3a348ebf686025" }, { - "bytes": "9da1352787785d38a71d4eb715a68517d4a00729dfa1cd28ed72f99f" + "bytes": "a52f3dcacf39c033f3da45f02432cc98dacd87cedd63ed4e240e2533" }, { - "bytes": "35653ce5fea9d0bd92ea079b9d7b8bd03f980936bf4fb9c5c62babaf" + "bytes": "e8b4169efe8424a182637c33e663628fc03f89c39a6e531d24a5fef2" } ] } diff --git a/headless/data/thread/thread-datum.json b/headless/data/thread/thread-datum.json index c9772fe..b38edbb 100644 --- a/headless/data/thread/thread-datum.json +++ b/headless/data/thread/thread-datum.json @@ -21,7 +21,7 @@ ] }, { - "bytes": "cafebabe00ac8e5e2f504e19d70a15539d99f863bb0bebc3f5c445fa9b42a566" + "bytes": "cafebabe0035b6040bb1810776a1bea50e956e754fffd48f95bb53f01558c945" } ] } \ No newline at end of file diff --git a/headless/data/thread/token.name b/headless/data/thread/token.name index b3a4c43..d515e65 100644 --- a/headless/data/thread/token.name +++ b/headless/data/thread/token.name @@ -1 +1 @@ -1abe11ed007c7a9687a042efabf5acecce82030b010ce630e87c264981e183b2 +1abe11ed00bc76a2013c2b81ac62a6cf0ae1b1338cae024eb6375b5658f3e452 diff --git a/headless/data/thread/updated-thread-datum.json b/headless/data/thread/updated-thread-datum.json index c9772fe..b38edbb 100644 --- a/headless/data/thread/updated-thread-datum.json +++ b/headless/data/thread/updated-thread-datum.json @@ -21,7 +21,7 @@ ] }, { - "bytes": "cafebabe00ac8e5e2f504e19d70a15539d99f863bb0bebc3f5c445fa9b42a566" + "bytes": "cafebabe0035b6040bb1810776a1bea50e956e754fffd48f95bb53f01558c945" } ] } \ No newline at end of file diff --git a/headless/trade_token.sh b/headless/send_all.sh similarity index 90% rename from headless/trade_token.sh rename to headless/send_all.sh index 92d5b7d..b8acf3a 100755 --- a/headless/trade_token.sh +++ b/headless/send_all.sh @@ -10,12 +10,12 @@ rm ./tmp/tx.signed || true ${cli} query protocol-parameters ${network} --out-file ./tmp/protocol.json # Sender Address -sender_path="wallets/user-1-wallet/" +sender_path="wallets/reference-wallet/" sender_address=$(cat ${sender_path}payment.addr) # Receiver Address # receiver_address=$(cat ${sender_path}payment.addr) -receiver_address="addr_test1qrvnxkaylr4upwxfxctpxpcumj0fl6fdujdc72j8sgpraa9l4gu9er4t0w7udjvt2pqngddn6q4h8h3uv38p8p9cq82qav4lmp" +receiver_address=$(jq -r '.change_address' ../config.json) # # exit # diff --git a/validators/cogno_minter.ak b/validators/cogno_minter.ak index 2d3ab08..268d8ca 100644 --- a/validators/cogno_minter.ak +++ b/validators/cogno_minter.ak @@ -74,7 +74,7 @@ validator( value.from_asset(currency_symbol, token_name, 1), outputs, )?, - // can not spend anything from cogno address + // single output going to the cogno address count.outputs_by_addr(outputs, cogno_addr, 1)?, } }