Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Explain deployer_address #1234

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_`:: 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then why is it always ZERO in the libs I looked at?
When are we using FALSE to use the caller address?

Copy link
Collaborator Author

@stoobie stoobie Apr 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here


[discrete]
=== Return values
Expand Down
Loading