0

I have a validator that uses Address in datum. I also have an address generated (payment.vkey, payment.skey, payment.addr, stake.vkey, stake.skey, stake.addr). I'm able to get PubKeyHash using command line like this:

cardano-cli address key-hash --payment-verification-key-file payment.vkey

That gives an addressPaymentCredential that I'm able to embed to datum when building the transaction in cli. It has the same information as (addressPaymentCredential, _). How would I go about getting a full address with addressStakingCredential in it, that is, (addressPaymentCredential, addressStakingCredential)?

I think that the JSON structure of Address in datum should be like this:

{
  "constructor": 0,
  "fields": [
    {
      "constructor": 0,
      "fields": [
        {
          "bytes": PubKeyHash
        }
      ]
    },
    {
      "constructor": 1,
      "fields": [
        {
          "bytes": StakingCredentialHash
        }
      ]
    }
  ]
}

My problem is I don't know how to get StakingCredentialHash.

TLDR: How do I embedd an Address instead of just PubKeyHash into the datum in cardano cli? I have the address credentials in payment.* and stake.* files.

6
  • why not just use the address instead of PubKeyHash in your example?
    – noone392
    Jan 7 at 17:52
  • @noone392 You mean in the JSON? The whole JSON is an Address which is composed of two parts, one of them being PubKeyHash. My validator used PubKeyHash, but I'm trying to replace it with Address. I did that and now I need to change the datum JSON appropriately. Or do you mean something else?
    – ijkl26
    Jan 7 at 18:27
  • I am not following you. The JSON file is not the address it is the whole formatting required for a datum entry. you said you said you wanted the address instead of the public key hash. So just delete "bytes": PubKeyHash and replace with "bytes": address? or if you want to add the address then add another "fields" key
    – noone392
    Jan 7 at 20:29
  • Yes, I want to transform my address into the datum entry. The JSON I provided is slightly modified output of ToData a, where a = Address(addressCredential, addressStakingCredential). In the JSON provided, I can replace PubKeyHash (which is just a placeholder there) with the output of cardano-cli address key-hash --payment-verification-key-file payment.vkey. My problem is that I can't figure out, what I need to replace the StakingCredentialHash placeholder with. I have the stake.vkey file, but I need some command to transform it in a similar manner to how I did with payment.vkey.
    – ijkl26
    Jan 7 at 20:44
  • i really can't follow what your asking. to transform stake.vkey in the same maneer just run "cardano-cli address key-hash --payment-verification-key-file stake.vkey"
    – noone392
    Jan 7 at 23:27

1 Answer 1

0

The problem was that I was trying to use the cardano-cli command for address to a stake-address. The command for payment credential (PubKeyHash) is correct in the question:

cardano-cli address key-hash --payment-verification-key-file payment.vkey

The correct command for staking credential should be like this:

cardano-cli stake-address key-hash --stake-verification-key-file stake.vkey

Outputs of those 2 commands can be used to build correct Address in datum.

Also, the JSON I provided in the question is incorrect, the staking credential part should be deeper than the payment credential part, you can get the correct JSON by printing the datum in emulator using a command like in an answer to this question.

2
  • So then, are you embedding an address-hash of some sort in the datum? As far as I know, you can't recreate the full address using the hashes of the constituent keys. I'm just curious - is the purpose of this to embed the address hash or some sort of address-verification method into the datum?
    – zhekson
    Jan 8 at 13:28
  • I think that payment credential and staking credential are just hashes, so you can verify that an output goes to an address from datum without the need to reconstruct the full address.
    – ijkl26
    Jan 8 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.