Question on contract instances #1027
-
To my understanding, a contract is a WASM program (I'm assuming a hash of it). Does the key for this program contain metadata? In other words, can two instances of the same WASM program exist under different keys, but also (verifiably) running the exact same code? Or can only one instance of a WASM program exist in any given network? Following this, if multiple instances of the same contract are supported, would it be possible for two contracts to interact with eachother only if they share the same code (or some previous version of some known code)? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Sorry for the slow reply. Contracts are identified on the network by:
Where the hash algorithm is Blake3. The parameters are an arbitrary block of bytes that's typically used to configure the contract - for example it would often contain the contract owner's public key. So you could have two contracts with the same wasm code but different parameters and these would have completely different identifiers, but if both code and parameters are the same then it would be the same contract.
A contract can read the state of any other contract (including contracts with the same wasm code) using the "related contracts" mechanism (which is under-documented right now, but see contract_interface.rs). |
Beta Was this translation helpful? Give feedback.
Sorry for the slow reply. Contracts are identified on the network by:
Where the hash algorithm is Blake3.
The parameters are an arbitrary block of bytes that's typically used to configure the contract - for example it would often contain the contract owner's public key.
So you could have two contracts with the same wasm code but different parameters and these would have completely different …