From 2939c690baa7c94d5cc19927cde16b00843da428 Mon Sep 17 00:00:00 2001 From: Steve Goodman Date: Thu, 25 Apr 2024 10:19:29 +0300 Subject: [PATCH 1/2] Explain `deployer_address` --- .../pages/Smart_Contracts/contract-address.adoc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc index cb9d25c949..c28d3fa492 100644 --- a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc +++ b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc @@ -3,11 +3,17 @@ The contract address is a unique identifier of the contract on Starknet. It is a chain hash of the following information: -* `prefix` - The ASCII encoding of the constant string `STARKNET_CONTRACT_ADDRESS`. -* `deployer_address` - The deployer address, unless `deploy_from_zero` is `true`, in which case it is `0`. -* `salt` - The salt passed by the contract calling the syscall, provided by the transaction sender. -* `class_hash` - See xref:./class-hash.adoc#computing_the_cairo_1_class_hash[the class hash documentation]. -* `constructor_calldata_hash` - xref:Cryptography/hash-functions.adoc#pedersen_array_hash[Array hash] of the inputs to the constructor. +[horizontal,labelwidth="25"] +`prefix`:: The ASCII encoding of the constant string `STARKNET_CONTRACT_ADDRESS`. +`deployer_address`:: +* When the contract is deployed via a `DEPLOY_ACCOUNT` transaction: `0` +* When the contract is deployed via a `deploy` system call from another contract: +[horizontal,labelwidth="25"] +`0`::: `deploy_from_zero` = `true` +The caller's address::: `deploy_from_zero` = `false` +`salt`:: The salt passed by the contract calling the syscall, provided by the transaction sender. +`class_hash`:: See xref:./class-hash.adoc#computing_the_cairo_1_class_hash[the class hash documentation]. +`constructor_calldata_hash`:: xref:Cryptography/hash-functions.adoc#pedersen_array_hash[Array hash] of the inputs to the constructor. The address is computed as follows: @@ -31,3 +37,4 @@ It also thwarts replay attacks by influencing the transaction hash with a unique .Additional resources * For more information on the address computation, see https://github.com/starkware-libs/cairo/blob/2c96b181a6debe9a564b51dbeaaf48fa75808d53/corelib/src/starknet/contract_address.cairo[contract_address.cairo] in the Cairo code repository. +* xref:Smart_Contracts/system-calls-cairo1.adoc#deploy[`deploy` system call] From cc8ab0c3251d7220aff4b6fe2fdb2a70ddb39681 Mon Sep 17 00:00:00 2001 From: Steve Goodman Date: Thu, 25 Apr 2024 14:07:23 +0300 Subject: [PATCH 2/2] Explain `deployer_address` --- .../pages/Smart_Contracts/contract-address.adoc | 11 +++++------ .../pages/Smart_Contracts/system-calls-cairo1.adoc | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc index c28d3fa492..9daa0d50e6 100644 --- a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc +++ b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/contract-address.adoc @@ -3,14 +3,13 @@ The contract address is a unique identifier of the contract on Starknet. It is a chain hash of the following information: -[horizontal,labelwidth="25"] +[horizontal,labelwidth="26",role=stripes-odd] `prefix`:: The ASCII encoding of the constant string `STARKNET_CONTRACT_ADDRESS`. -`deployer_address`:: +`deployer_address`:: One of the following: * When the contract is deployed via a `DEPLOY_ACCOUNT` transaction: `0` -* When the contract is deployed via a `deploy` system call from another contract: -[horizontal,labelwidth="25"] -`0`::: `deploy_from_zero` = `true` -The caller's address::: `deploy_from_zero` = `false` +* When the contract is deployed via a `deploy` system call from another contract, the value of the `deploy_from_zero` parameter determines this value. ++ +For information on the `deploy_from_zero` parameter, see the xref:Smart_Contracts/system-calls-cairo1.adoc#deploy[`deploy` system call] `salt`:: The salt passed by the contract calling the syscall, provided by the transaction sender. `class_hash`:: See xref:./class-hash.adoc#computing_the_cairo_1_class_hash[the class hash documentation]. `constructor_calldata_hash`:: xref:Cryptography/hash-functions.adoc#pedersen_array_hash[Array hash] of the inputs to the constructor. diff --git a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc index 0244425f26..90c6a3e6bb 100644 --- a/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc +++ b/components/Starknet/modules/architecture_and_concepts/pages/Smart_Contracts/system-calls-cairo1.adoc @@ -177,7 +177,7 @@ Deploys a new instance of a previously declared class. `_class_hash_`:: The class hash of the contract to be deployed. `_contract_address_salt_`:: The salt, an arbitrary value provided by the sender, used in the computation of the xref:Smart_Contracts/contract-address.adoc[contract's address]. `_calldata_`:: The constructor's calldata. An array of felts. -`_deploy_from_zero_`:: A flag used for the contract address computation. If not set, the caller address will be used as the new contract's deployer address, otherwise 0 is used. +`_deploy_from_zero_`:: A flag that determines whether the deployer’s address affects the computation of the contract address. When not set, or when set to `FALSE`, the caller address is used as the new contract's deployer address. When set to `TRUE`, 0 is used. [discrete] === Return values