@@ -39,48 +39,51 @@ CURRENT_EPOCH=\$(CARDANO_NODE_SOCKET_PATH=node-pool${N}/ipc/node.sock ./cardano-
39
39
echo ">>>> Current Epoch: \$ {CURRENT_EPOCH}"
40
40
EOF
41
41
42
- # Prepare transactions for activating stake pools
42
+ # Prepare transactions for delegating to stake pools
43
43
for N in ${POOL_NODES_N} ; do
44
-
45
- # We'll transfer funds to the user1, which delegates to pool1
46
- # We'll register certs to:
47
- # 1. delegate from the user1 stake address to the stake pool
48
44
cat >> delegate.sh << EOF
49
-
50
45
AMOUNT_STAKED=\$ (( $N *1000000 + DELEGATION_ROUND*1 ))
51
46
47
+ # Get the UTxO
52
48
TX_IN=\$ (CARDANO_NODE_SOCKET_PATH=node-pool${N} /ipc/node.sock ./cardano-cli query utxo \\
53
- --testnet-magic ${NETWORK_MAGIC} --address \$ (cat addresses/utxo${N} .addr) --out-file tmp.txt \\
54
- && cat tmp.txt | jq -r 'to_entries | [last] | .[0].key' \\
55
- && rm -f tmp.txt)
56
-
57
- CARDANO_NODE_SOCKET_PATH=node-pool${N} /ipc/node.sock ./cardano-cli transaction build \\
58
- --alonzo-era \\
59
- --tx-in \$ {TX_IN} \\
60
- --tx-out \$ (cat addresses/user${N} .addr)+\$ {AMOUNT_STAKED} \\
61
- --change-address \$ (cat addresses/utxo${N} .addr) \\
62
- --testnet-magic ${NETWORK_MAGIC} \\
63
- --certificate-file addresses/user${N} -stake.deleg.cert \\
64
- --invalid-hereafter 100000 \\
65
- --out-file node-pool${N} /tx/tx${N} -\$ {DELEGATION_ROUND}.txbody \\
66
- --witness-override 2
67
-
68
- EOF
69
-
70
- # So we'll need to sign this with a the following keys:
71
- # 1. the user1 stake address key, due to the delegation cert
72
- cat >> delegate.sh << EOF
49
+ --testnet-magic ${NETWORK_MAGIC} --address \$ (cat addresses/utxo${N} .addr) --out-file /dev/stdout \\
50
+ | jq -r 'to_entries | [last] | .[0].key')
51
+
52
+ # Build the transaction
53
+ if [ "\$ DELEGATION_ROUND" -eq 1 ]; then
54
+ # First delegation round, we need to include registration certificate and delegation certificate
55
+ CARDANO_NODE_SOCKET_PATH=node-pool${N} /ipc/node.sock ./cardano-cli transaction build \\
56
+ --tx-in \$ {TX_IN} \\
57
+ --tx-out \$ (cat addresses/user${N} .addr)+\$ {AMOUNT_STAKED} \\
58
+ --change-address \$ (cat addresses/utxo${N} .addr) \\
59
+ --testnet-magic ${NETWORK_MAGIC} \\
60
+ --certificate-file addresses/user${N} -stake.reg.cert \\
61
+ --certificate-file addresses/user${N} -stake.deleg.cert \\
62
+ --invalid-hereafter 100000 \\
63
+ --out-file node-pool${N} /tx/tx${N} -\$ {DELEGATION_ROUND}.txbody \\
64
+ --witness-override 2
65
+ else
66
+ # All other delegation rounds, we need to include only delegation certificate
67
+ CARDANO_NODE_SOCKET_PATH=node-pool${N} /ipc/node.sock ./cardano-cli transaction build \\
68
+ --tx-in \$ {TX_IN} \\
69
+ --tx-out \$ (cat addresses/user${N} .addr)+\$ {AMOUNT_STAKED} \\
70
+ --change-address \$ (cat addresses/utxo${N} .addr) \\
71
+ --testnet-magic ${NETWORK_MAGIC} \\
72
+ --certificate-file addresses/user${N} -stake.deleg.cert \\
73
+ --invalid-hereafter 100000 \\
74
+ --out-file node-pool${N} /tx/tx${N} -\$ {DELEGATION_ROUND}.txbody \\
75
+ --witness-override 2
76
+ fi
77
+
78
+ # Sign the transaction
73
79
CARDANO_NODE_SOCKET_PATH=node-pool${N} /ipc/node.sock ./cardano-cli transaction sign \\
74
80
--signing-key-file addresses/utxo${N} .skey \\
75
81
--signing-key-file addresses/user${N} -stake.skey \\
76
82
--testnet-magic ${NETWORK_MAGIC} \\
77
83
--tx-body-file node-pool${N} /tx/tx${N} -\$ {DELEGATION_ROUND}.txbody \\
78
84
--out-file node-pool${N} /tx/tx${N} -\$ {DELEGATION_ROUND}.tx
79
85
80
- EOF
81
-
82
- # Copy submit transaction to delegate.sh script
83
- cat >> delegate.sh << EOF
86
+ # Submit the transaction
84
87
CARDANO_NODE_SOCKET_PATH=node-pool${N} /ipc/node.sock ./cardano-cli transaction submit \\
85
88
--tx-file node-pool${N} /tx/tx${N} -\$ {DELEGATION_ROUND}.tx \\
86
89
--testnet-magic ${NETWORK_MAGIC}
0 commit comments