Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CLI in order to allow tx outs with datum hashes and other fixe…
…s to enable Plutus script submission
- Loading branch information
Showing
10 changed files
with
169 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
# Unoffiical bash strict mode. | ||
# See: http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -u | ||
set -o pipefail | ||
|
||
# cardano-cli address build --payment-script-file scripts/plutus/always-succeeds-txin.plutus --testnet-magic 42 | ||
# Always succeeding PLUTUS SCRIPT ADDRESS - addr_test1wzpu87f5k52qvua9wn6gncg0m6hle4w86w5c4m9ryk6dxmsrw7evr | ||
|
||
#UTXOADDR=$(cardano-cli address build --testnet-magic 42 --payment-verification-key-file example/shelley/utxo-keys/utxo1.vkey) | ||
|
||
#TXIN=$(cardano-cli transaction txid --tx-body-file tx3.txbody)# | ||
|
||
#cardano-cli query protocol-parameters --testnet-magic 42 --out-file example/pparams.json | ||
|
||
# This script demonstrates how to lock a txin with a plutus script. NB: In this example any datum will succeed | ||
|
||
# Step 1: Create a tx ouput with a datum hash at the script address. In order for a tx ouput to be locked | ||
# by a plutus script, it must have a datahash. | ||
# We also need collateral tx inputs so we splut the utxo as well to accomodate this. | ||
|
||
plutusscriptaddr=$(cardano-cli address build --payment-script-file scripts/plutus/always-succeeds-txin.plutus --testnet-magic 42) | ||
|
||
utxovkey=example/shelley/utxo-keys/utxo1.vkey | ||
utxoskey=example/shelley/utxo-keys/utxo1.skey | ||
|
||
utxoaddr=$(cardano-cli address build --testnet-magic 42 --payment-verification-key-file $utxovkey) | ||
|
||
utxo=$(cardano-cli query utxo --address $utxoaddr --cardano-mode --testnet-magic 42 --out-file utxo.json) | ||
|
||
txin=$(jq -r 'keys[]' utxo.json) | ||
|
||
cardano-cli transaction build-raw \ | ||
--alonzo-era \ | ||
--fee 0 \ | ||
--tx-in $txin \ | ||
--tx-out $plutusscriptaddr+500000000 --datum-hash 9e1199a988ba72ffd6e9c269cadb3b53b5f360ff99f112d9b2ee30c4d74ad88b \ | ||
--tx-out $utxoaddr+500000000 \ | ||
--out-file create-datum-output.body | ||
|
||
cardano-cli transaction sign \ | ||
--tx-body-file create-datum-output.body \ | ||
--testnet-magic 42 \ | ||
--signing-key-file $utxoskey\ | ||
--out-file create-datum-output.tx | ||
|
||
# Step 2 | ||
# After "locking" our tx output at the script address, we can now can attempt to spend | ||
# the "locked" tx output below. | ||
|
||
plutusutxo=$(cardano-cli query utxo --address $plutusscriptaddr --testnet-magic 42 --out-file plutusutxo.json) | ||
plutusutxotxin=$(jq -r 'keys[]' plutusutxo.json) | ||
|
||
cardano-cli query protocol-parameters --testnet-magic 42 --out-file example/pparams.json | ||
|
||
cardano-cli transaction build-raw \ | ||
--alonzo-era \ | ||
--fee 0 \ | ||
--tx-in $plutusutxotxin \ | ||
--tx-in-collateral $txin \ | ||
--tx-out $utxoaddr+500000000 \ | ||
--txin-script-file ./scripts/plutus/always-succeeds-txin.plutus \ | ||
--datum-value 42 \ | ||
--protocol-params-file example/pparams.json\ | ||
--redeemer-value 42 \ | ||
--execution-units "(0,0)" \ | ||
--out-file test-alonzo.body | ||
|
||
cardano-cli transaction sign \ | ||
--tx-body-file test-alonzo.body \ | ||
--testnet-magic 42 \ | ||
--signing-key-file example/shelley/utxo-keys/utxo1.skey \ | ||
--out-file alonzo.tx | ||
# | ||
# cardano-cli transaction submit --tx-file alonzo.tx --testnet-magic 42 | ||
# | ||
# | ||
#> cabal exec cardano-cli -- query utxo --address addr_test1vrnzmw3tcq6llyh79tu7ym86p2gfhj47ap0wqcwkweqpnaq0r6yg4 --cardano-mode --testnet-magic 42 |