user2248: After spending some time learning Plutus with emulators, I decided to start learning how to actually deploy and use the scripts in the testnet. In this process, I installed cardano-cli and created multiple key files, such as "payment.addr", "payment.skey", "payment.vkey", etc. But now, the validator script that I created requires as one of it's parameters a Plutus AssocMap associating public key hashes to integers.
My question is, based on the keys I created, how can I find out their PubKeyHash? I believe this is related to "payment.addr", but I'm not sure.

user2794: You can use the "cardano-address address inspect" syntax to get the public key hash from an address without requiring the verification key. Requiring the verification key assumes having access to the file while addresses can be shared without having to know the owner.
This link can help: https://github.com/input-output-hk/cardano-addresses

user2068: I am working on this as well... I am not sure but this seems quite promising
https://input-output-hk.github.io/cardano-addresses/demo/
Maybe this is usefull as well
https://cips.cardano.org/cips/cip19/#shelleyaddresses

user2248: If anyone is trying to do this using cardano-serialization-lib and Nami:
const PUBKEY_HASH = async () => {
  const cardano = window.cardano;

  const pkh = Loader.Cardano.BaseAddress.from_address(
    Loader.Cardano.Address.from_bytes(
      Buffer.from(await cardano.getChangeAddress(), "hex")
    )
  )
    .payment_cred()
    .to_keyhash();

  return pkh;
};

Assuming you are using a loader like the one from spacebudz and you are importing Buffer import { Buffer } from "buffer";
UPDATE
Made a more abstract version that takes a string (the bech32 address) and returns another string (the public key hash)
function addrToPubKeyHash(bech32Addr) {
  const pkh = Loader.Cardano.BaseAddress.from_address(
    Loader.Cardano.Address.from_bech32(bech32Addr)
  )
    .payment_cred()
    .to_keyhash();

  return toHex(pkh.to_bytes());
}


user1231: I think you're looking for this:

cardano-cli address key-hash --payment-verification-key STRING
cardano-cli address key-hash --payment-verification-key-file FILE

You should use your payment.vkey

2248: <p>After spending some time learning Plutus with emulators, I decided to start learning how to actually deploy and use the scripts in the testnet. In this process, I installed cardano-cli and created multiple key files, such as &quot;payment.addr&quot;, &quot;payment.skey&quot;, &quot;payment.vkey&quot;, etc. But now, the validator script that I created requires as one of it's parameters a Plutus <code>AssocMap</code> associating public key hashes to integers.</p>
<p>My question is, based on the keys I created, how can I find out their <code>PubKeyHash</code>? I believe this is related to &quot;payment.addr&quot;, but I'm not sure.</p>
 2794: <p>You can use the &quot;cardano-address address inspect&quot; syntax to get the public key hash from an address without requiring the verification key. Requiring the verification key assumes having access to the file while addresses can be shared without having to know the owner.
This link can help: <a href="https://github.com/input-output-hk/cardano-addresses" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-addresses</a></p>
 2068: <p>I am working on this as well... I am not sure but this seems quite promising</p>
<p><a href="https://input-output-hk.github.io/cardano-addresses/demo/" rel="nofollow noreferrer">https://input-output-hk.github.io/cardano-addresses/demo/</a></p>
<p>Maybe this is usefull as well</p>
<p><a href="https://cips.cardano.org/cips/cip19/#shelleyaddresses" rel="nofollow noreferrer">https://cips.cardano.org/cips/cip19/#shelleyaddresses</a></p>
 2248: <p>If anyone is trying to do this using cardano-serialization-lib and Nami:</p>
<pre><code>const PUBKEY_HASH = async () =&gt; {
  const cardano = window.cardano;

  const pkh = Loader.Cardano.BaseAddress.from_address(
    Loader.Cardano.Address.from_bytes(
      Buffer.from(await cardano.getChangeAddress(), &quot;hex&quot;)
    )
  )
    .payment_cred()
    .to_keyhash();

  return pkh;
};
</code></pre>
<p>Assuming you are using a loader like the one from <a href="https://github.com/Berry-Pool/spacebudz/blob/main/src/cardano/market/loader.js" rel="noreferrer">spacebudz</a> and you are importing Buffer <code>import { Buffer } from &quot;buffer&quot;;</code></p>
<p><strong>UPDATE</strong></p>
<p>Made a more abstract version that takes a string (the bech32 address) and returns another string (the public key hash)</p>
<pre><code>function addrToPubKeyHash(bech32Addr) {
  const pkh = Loader.Cardano.BaseAddress.from_address(
    Loader.Cardano.Address.from_bech32(bech32Addr)
  )
    .payment_cred()
    .to_keyhash();

  return toHex(pkh.to_bytes());
}
</code></pre>
 1231: <p>I think you're looking for this:</p>
<ul>
<li><code>cardano-cli address key-hash --payment-verification-key STRING</code></li>
<li><code>cardano-cli address key-hash --payment-verification-key-file FILE</code></li>
</ul>
<p>You should use your <code>payment.vkey</code></p>
