2

As we know, Tezos protocol activator accepts the bootstrap_contracts parameter to originate specified contracts when the blockchain is launched. For example, Tezos mainnet was launched with some "Vested" contracts, specified in the parameters. They look like this:

"bootstrap_contracts": [
  {
    "amount": "9553982475158",
    "delegate": "tz3RDC3Jdn4j15J7bBHZd29EUee9gVB1CxD9",
    "script": {
      "code": ...,
      "storage": ...
    }
  },
  ...
]

After the protocol is activated, we can see that the contract is successfully originated with the address KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG:

[
  "KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG",
  {
    "balance": "9553982475158",
    "big_map": [],
    "code": [...],
    "counter": "0",
    "delegate": "tz3RDC3Jdn4j15J7bBHZd29EUee9gVB1CxD9",
    "delegated": [],
    "frozen_balance": [],
    "manager": "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU",
    "paid_bytes": "5775",
    "storage": {...},
    "used_bytes": "5775"
  }
]

Question: how to calculate the KT1QuofAgnsWffHzLA7D78rxytJruGHDe7XG address looking on the protocol parameters, without checking the blockchain context.

2 Answers 2

1

The contract address cannot be known without looking at the blockchain context because the contract address is created when the transaction with origination operation is baked into the blockchain.

3
  • As you said, the contract address is "created". What I need is the algorithm of creation to be able to reproduce it and get the same address myself. Also, if you look at the block with level = 1, you won't see any origination operations, as well as you won't see any baker who could bake it, because there is nothing before the protocol is activated.
    – Groxan
    Nov 19, 2020 at 17:48
  • 1
    The identity of the baker who would bake the first block exists, even before the protocol is activated. We do not have access to the private parts of their identity, and thus, cannot simulate their behavior. Dec 1, 2020 at 0:47
  • Hmm, so you are saying that KT-addresses of the bootstrap contracts depend on the baker who injects the first block after genesis, right? So the baker actually forges and signs normal origination operations, but they (including the signatures) are simply not stored anywhere, right?
    – Groxan
    Dec 1, 2020 at 11:49
1

The KT address is derived from the signed operations bytes that originated the account. To calculate it you will need to first hash the operations bytes with blake2b (32 bytes). Then you prepend an index of 4 bytes that starts at 0 ([0, 0, 0, 0]) and is incremented by one for every additional origination (in case it's a batch of multiple originations). Then you hash it one more time and finally base58 encode it with the 'KT' prefix.

1
  • Thanks! But I don't have signed operation bytes... We are talking about protocol parameters - look at the blocks[1].header.content.parameters.bootstrap_contracts. The only thing I have is an array of { "amount": "", "delegate": "", "script": "" }. That's it.
    – Groxan
    Nov 21, 2020 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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