cardano-cli
installed since it is used to actually build and sign transactions.
Template bash scripts that follow these steps are available here.
- Installing
- Minting an address book beacon and adding the first entry
- Adding an entry
- Burn the address book beacon
Instructions are adapted from the plutus-pioneers-program week 1 exercise.
-
Install NixOS cross-referencing the following resources.
- https://nixos.org/download.html
- https://docs.plutus-community.com
- A few resources to understand the what and why regarding NixOS
-
Set-up IOHK binary caches How to set up the IOHK binary caches. "If you do not do this, you will end up building GHC, which takes several hours. If you find yourself building GHC, stop and fix the cache."
-
After adding the cache, you will need to restart the nix service. This can be done by executing
sudo systemctl restart nix
or by restarting your machine. If the cache was configured properly, you should see a lot ofcopying path ... from 'https://cache.iog.io'
when you executenix-shell
in the next step. -
Execute the following:
git clone https://github.com/fallen-icarus/cardano-address-book
git clone https://github.com/input-output-hk/plutus-apps
cd plutus-apps
git checkout v1.0.0
nix-shell # this may take a while the first time
# Your terminal should now have a nix-shell prompt
cd ../cardano-address-book
cabal clean
cabal update
cabal build all
The cardano-address-book
CLI program should now be at dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-address-book-0.1.0.0/x/cardano-address-book/build/cardano-address-book/cardano-address-book
. Move the program to somewhere in your $PATH.
You can now exit the nix-shell with exit
.
All cardano-address-book
subcommands have an associated --help
option. The functionality is meant to feel like cardano-cli
.
cardano-address-book beacon policy-script \
--out-file beacon.plutus
cardano-cli transaction policyid \
--script-file beacon.plutus
beacon = policyId ++ "." ++ paymentPubKeyHash
cardano-address-book beacon create-redeemer \
--mint-beacon <payment_pubkey_hash> \
--out-file mint.json
cardano-address-book create-entry \
--alias <alias1> \
--address <alias1_address> \
--alias <alias2> \
--address <alias2_address> \
--out-file entry.json
You can add as many alias
/address
pairs as you want.
cardano-cli query protocol-parameters \
--testnet-magic 1 \
--out-file protocol.json
cardano-cli transaction build \
--tx-in <utxo_to_pay_fee> \
--tx-out "$(cat pubkey.addr) + 2000000 lovelace + 1 <beacon_full_name>" \
--mint "1 <beacon_full_name>" \
--mint-script-file beacon.plutus \
--mint-redeemer-file mint.json \
--change-address $(cat pubkey.addr) \
--tx-in-collateral <utxo_for_collateral> \
--metadata-json-file entry.json \
--required-signer-hash <payment_pubkey_hash> \
--testnet-magic 1 \
--protocol-params-file protocol.json \
--out-file tx.body
cardano-cli transaction sign \
--tx-body-file tx.body \
--signing-key-file pubkey.skey \
--testnet-magic 1 \
--out-file tx.signed
cardano-cli transaction submit \
--testnet-magic 1 \
--tx-file tx.signed
cardano-address-book beacon policy-script \
--out-file beacon.plutus
The script will not be executed; it is just needed to get the full beacon name for manually balancing the transaction.
cardano-cli transaction policyid \
--script-file beacon.plutus
beacon = policyId ++ "." ++ paymentPubKeyHash
cardano-address-book create-entry \
--alias <alias1> \
--address <alias1_address> \
--out-file entry.json
If you use an alias already in the address book, the address book will update the alias to have the newly supplied address.
cardano-cli transaction build \
--tx-in <utxo_to_pay_fee> \
--tx-in <utxo_with_beacon> \
--tx-out "$(cat pubkey.addr) 2000000 lovelace + 1 <beacon_full_name>" \
--change-address $(cat pubkey.addr) \
--metadata-json-file entry.json \
--testnet-magic 1 \
--out-file tx.body
cardano-cli transaction sign \
--tx-body-file tx.body \
--signing-key-file pubkey.skey \
--testnet-magic 1 \
--out-file tx.signed
cardano-cli transaction submit \
--testnet-magic 1 \
--tx-file tx.signed
cardano-address-book beacon policy-script \
--out-file beacon.plutus
cardano-cli transaction policyid \
--script-file beacon.plutus
beacon = policyId ++ "." ++ paymentPubKeyHash
cardano-address-book beacon create-redeemer \
--burn-beacon \
--out-file burn.json
cardano-cli query protocol-parameters \
--testnet-magic 1 \
--out-file protocol.json
cardano-cli transaction build \
--tx-in <utxo_to_pay_fee> \
--tx-in <utxo_with_beacon> \
--mint "-1 <beacon_full_name>" \
--mint-script-file beacon.plutus \
--mint-redeemer-file burn.json \
--change-address $(cat pubkey.addr) \
--tx-in-collateral <utxo_for_collateral> \
--testnet-magic 1 \
--protocol-params-file protocol.json \
--out-file tx.body
cardano-cli transaction sign \
--tx-body-file tx.body \
--signing-key-file pubkey.skey \
--testnet-magic 1 \
--out-file tx.signed
cardano-cli transaction submit \
--testnet-magic 1 \
--tx-file tx.signed