forked from input-output-hk/plutus-pioneer-program
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mint-token-cli.sh
executable file
·53 lines (44 loc) · 1.21 KB
/
mint-token-cli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
oref=$1
amt=$2
tn=$3
addrFile=$4
skeyFile=$5
echo "oref: $oref"
echo "amt: $amt"
echo "tn: $tn"
echo "address file: $addrFile"
echo "signing key file: $skeyFile"
ppFile=testnet/protocol-parameters.json
cardano-cli query protocol-parameters $MAGIC --out-file $ppFile
policyFile=testnet/token.plutus
cabal exec token-policy $policyFile $oref $amt $tn
unsignedFile=testnet/tx.unsigned
signedFile=testnet/tx.signed
pid=$(cardano-cli transaction policyid --script-file $policyFile)
tnHex=$(cabal exec token-name -- $tn)
addr=$(cat $addrFile)
v="$amt $pid.$tnHex"
echo "currency symbol: $pid"
echo "token name (hex): $tnHex"
echo "minted value: $v"
echo "address: $addr"
cardano-cli transaction build \
$MAGIC \
--tx-in $oref \
--tx-in-collateral $oref \
--tx-out "$addr + 1500000 lovelace + $v" \
--mint "$v" \
--mint-script-file $policyFile \
--mint-redeemer-file testnet/unit.json \
--change-address $addr \
--protocol-params-file $ppFile \
--out-file $unsignedFile \
cardano-cli transaction sign \
--tx-body-file $unsignedFile \
--signing-key-file $skeyFile \
$MAGIC \
--out-file $signedFile
cardano-cli transaction submit \
$MAGIC \
--tx-file $signedFile