Skip to content

Commit

Permalink
fix: Explain deployer_address (#1234)
Browse files Browse the repository at this point in the history
* Explain `deployer_address`

* Explain `deployer_address`
  • Loading branch information
stoobie authored Apr 30, 2024
1 parent 78e19de commit 8dde8fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

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="26",role=stripes-odd]
`prefix`:: The ASCII encoding of the constant string `STARKNET_CONTRACT_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, 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.

The address is computed as follows:

Expand All @@ -31,3 +36,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]
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Deploys a new instance of a previously declared class.
`_class_hash_: ClassHash`:: The class hash of the contract to be deployed.
`_contract_address_salt_: felt252`:: 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_: Span<felt252>`:: The constructor's calldata. An array of felts.
`_deploy_from_zero_: bool`:: 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_: bool`:: 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
Expand Down

0 comments on commit 8dde8fe

Please sign in to comment.