#[repr(C)]pub struct ContractDeploymentHashPreimage {
pub deployer_address: ContractAddress,
pub nonce: SHA256Hash,
pub contract_hash: SHA256Hash,
}Expand description
Hash preimage for deriving deployed contract addresses.
When a contract deploys another contract, the new contract’s address is deterministically computed as:
ContractAddress = SHA256(ContractDeploymentHashPreimage)Under XDR encoding, this struct serializes as the concatenation of its
fields: deployer_address || nonce || contract_hash.
This is Thruput’s analogue of Ethereum’s CREATE2 opcode, allowing
deterministic address derivation. The deployer controls the nonce to
create addresses at will.
§Example
Contract A address: 0x1234...
Contract B hash: 0xabcd... (= SHA256(XDR(Contract B)))
Deployment nonce: 0x5678...
Result: SHA256(0x1234... || 0x5678... || 0xabcd...) = Contract B addressFields§
§deployer_address: ContractAddressThe address of the contract performing the deployment.
nonce: SHA256HashArbitrary 32-byte value chosen by the deployer.
Allows creating multiple instances of the same contract code at different addresses.
contract_hash: SHA256HashSHA-256 hash of the XDR-encoded Contract being deployed.
This hashes the entire union, not the bare code blob:
contract_hash = SHA256(XDR(Contract))The encoding covers the 4-byte ContractType discriminant followed by
the selected arm, so identical code deployed under a different contract
type yields a different hash. For kRv32 the arm is a ContractBlob,
which is itself a 4-byte length prefix followed by the code padded to a
4-byte boundary – hashing the raw code alone does not reproduce this
value.
Native and mock contracts are hashed the same way, over a union whose arm holds a contract identifier instead of a blob. They do not use separately predefined hash constants.
Trait Implementations§
Source§impl Clone for ContractDeploymentHashPreimage
impl Clone for ContractDeploymentHashPreimage
Source§fn clone(&self) -> ContractDeploymentHashPreimage
fn clone(&self) -> ContractDeploymentHashPreimage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl EncodesAs<ContractDeploymentHashPreimage> for ContractDeploymentHashPreimage
impl Eq for ContractDeploymentHashPreimage
Source§impl JsonSchema for ContractDeploymentHashPreimage
impl JsonSchema for ContractDeploymentHashPreimage
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for ContractDeploymentHashPreimage
impl Ord for ContractDeploymentHashPreimage
Source§fn cmp(&self, other: &ContractDeploymentHashPreimage) -> Ordering
fn cmp(&self, other: &ContractDeploymentHashPreimage) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ContractDeploymentHashPreimage
impl PartialOrd for ContractDeploymentHashPreimage
Source§impl<'_r> ReadXDR<'_r> for ContractDeploymentHashPreimage
impl<'_r> ReadXDR<'_r> for ContractDeploymentHashPreimage
Source§fn read_xdr<R>(r: &mut R) -> Result<ContractDeploymentHashPreimage, ReadError>where
R: Reader<'_r>,
fn read_xdr<R>(r: &mut R) -> Result<ContractDeploymentHashPreimage, ReadError>where
R: Reader<'_r>,
Source§fn read_xdr_in_place<R, '__xdrs_s>(
r: &mut R,
__xdrs_slot: Slot<'__xdrs_s, ContractDeploymentHashPreimage>,
) -> Result<Init<'__xdrs_s, ContractDeploymentHashPreimage>, ReadError>where
R: Reader<'_r>,
fn read_xdr_in_place<R, '__xdrs_s>(
r: &mut R,
__xdrs_slot: Slot<'__xdrs_s, ContractDeploymentHashPreimage>,
) -> Result<Init<'__xdrs_s, ContractDeploymentHashPreimage>, ReadError>where
R: Reader<'_r>,
slot, without first building it
on the stack. Read more