How are smart contract addresses (those that start with
I would like to know whether
CHAIN_ID is somehow used in its computation, or it is possible to have two KT1 contracts with identical addresses on different chains.
Tezos Stack Exchange is a question and answer site for users, experts, and developers of the Tezos blockchain project. It only takes a minute to sign up.Sign up to join this community
KT1 addresses are computed from origination nonce. The origination nonce is made of operation hash (the operation that creates the origination) and its index (the index starts from 0 and it gets incremented for each origination in the operation).
The operation hash depends on block header of the branch where it was included.The
CHAIN_ID depends on genesis block hash.
So on chains with different
CHAIN_IDs the block hashes will differ, because they depend on their predecessors, and so you should never get the same KT1 addresses.
In case someone needs precise calculations.
Say, you have an operation group hash
onvsLP3JFZia2mzZKWaFuFkWg2L5p3BDUhzh5Kr6CiDDN3rtQ1D and an origination index
0 which is increased for every origination operation in the group including internal operations. In order to calculate originated contract hash you need to do:
In the result you get
When you call
run_code RPC endpoint a dummy contract is originated. Its address is calculated the same way, but a zero opg hash (
\x00 32 times) is used. For every
CREATE_CONTRACT instruction the origination index is increased.
The dummy originated contract address is thus always
You have a good answer. If you want to learn more see these threads.