# Delegation certificate

The hardware wallet stake key registration and delegation certificates must be submitted to the blockchain in a separate transaction. This transaction must be signed with the hardware wallet (for the hardware wallet stake key) and with the payment key (used to pay the transaction fees). Any payment address/key can be used for this. In the scripts below, the pledge wallet (first pool owner) is used.

In a new subfolder in the `transactions` subfolder, and create and execute the following scripts:

`transaction.sh`:

```bash
#!/bin/bash


source ../../pool-scripts/env

ADDRESS=$(cat ${NODE_HOME}/keys/payment-0.addr)
TRANS=$(cardano-cli query utxo ${NET} --address $ADDRESS | tail -n +3 | sort -k3rn | tail -n 1)
UTXO=$(echo ${TRANS} | awk '{print $1}')
ID=$(echo ${TRANS} | awk '{print $2}')
TXIN="${UTXO}#${ID}"

cardano-cli transaction build \
${NET} \
--cddl-format \
--witness-override 2 \
--tx-in ${TXIN} \
--change-address $(cat ${NODE_HOME}/keys/payment-0.addr) \
--certificate-file ${NODE_HOME}/pool-certificates/ledger-stake-registration.cert \
--certificate-file ${NODE_HOME}/pool-certificates/ledger-stake-delegation.cert \
--out-file tx.raw
```

`witness-payment.sh`:

```bash
#!/bin/bash


source ../../pool-scripts/env

cardano-cli transaction witness \
--tx-body-file tx.raw \
--signing-key-file ${NODE_HOME}/keys/payment-0.skey \
${NET} \
--out-file tx-payment.witness
```

`witness-hw-stake.sh` (executing this requires confirmation in the hardware wallet):

```bash
#!/bin/bash


source ../../pool-scripts/env

cardano-hw-cli transaction witness \
--tx-file tx.raw \
--hw-signing-file ${NODE_HOME}/keys/ledger-stake.hwsfile \
${NET} \
--out-file tx-ledger-stake.witness
```

`transaction-assemble.sh`:

```bash
#!/bin/bash


cardano-cli transaction assemble \
--tx-body-file tx.raw \
--witness-file tx-payment.witness \
--witness-file tx-ledger-stake.witness \
--out-file tx.multisign
```

`submit.sh`:

```bash
#!/bin/bash


source ../../pool-scripts/env

cardano-cli transaction submit \
--tx-file tx.multisign \
${NET}
```

With this transaction, the process of adding the hardware wallet as a stake pool owner is complete.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apexpool.gitbook.io/stake-pool-scripts/hardware-wallet-for-pledge/transactions/delegation-certificate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
