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

Document Class Hashes #832

Merged
merged 24 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
331844d
fix: link (#545)
ericnordelo Jan 20, 2023
2e7758e
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 6, 2023
77cca2d
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 10, 2023
8a19908
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 18, 2023
2f3d020
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 24, 2023
a2f062e
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 25, 2023
1cbb5ed
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Nov 2, 2023
b4ee9c8
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Nov 10, 2023
fc522b6
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Nov 13, 2023
be442ab
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Nov 24, 2023
0415452
feat: add page
ericnordelo Nov 27, 2023
261cb7a
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Nov 27, 2023
bc12e61
feat: finish UI
ericnordelo Nov 27, 2023
257c6b2
Update docs/modules/ROOT/pages/api/erc721.adoc
ericnordelo Nov 29, 2023
e8b6bab
feat: apply review updates
ericnordelo Nov 29, 2023
e53088e
Merge branch 'feat/class-hashes-#555' of github.com:ericnordelo/cairo…
ericnordelo Nov 29, 2023
9327d7f
fix: remove trailing space
ericnordelo Nov 29, 2023
d01aca7
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Nov 29, 2023
1889cf7
feat: update CHANGELOG
ericnordelo Nov 29, 2023
5805d33
Update CHANGELOG.md
ericnordelo Dec 4, 2023
b82a84c
feat: apply review updates
ericnordelo Dec 4, 2023
57275f0
Merge branch 'feat/class-hashes-#555' of github.com:ericnordelo/cairo…
ericnordelo Dec 4, 2023
77a420e
feat: apply review updates
ericnordelo Dec 12, 2023
965214c
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
// * xref:udc.adoc[Universal Deployer Contract]
// * xref:utilities.adoc[Utilities]

* xref:/presets.adoc[Presets]

* xref:contracts::index.adoc[Contracts for Solidity]
8 changes: 8 additions & 0 deletions docs/modules/ROOT/pages/api/account.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ use openzeppelin::presets::Account;

Basic account contract leveraging xref:#AccountComponent[AccountComponent].

:class-hashes: xref:presets.adoc[Compiled class hash]
martriay marked this conversation as resolved.
Show resolved Hide resolved

[.contract-index]
.{class-hashes}
--
0x016c6081eb34ad1e0c5513234ed0c025b3c7f305902d291bad534cd6474c85bc
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved
--

[.contract-index]
.Constructor
--
Expand Down
11 changes: 9 additions & 2 deletions docs/modules/ROOT/pages/api/erc20.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,14 @@ use openzeppelin::presets::ERC20;

Basic ERC20 contract leveraging xref:#ERC20Component[ERC20Component] with a fixed-supply mechanism for token distribution.

:class-hashes: xref:presets.adoc[Compiled class hash]

[.contract-index]
.{class-hashes}
--
0x01d7085cee580ba542cdb5709bda80ebfe8bdede664261a3e6af92994d9a1de7
--

[.contract-index]
.Constructor
--
Expand All @@ -509,5 +517,4 @@ Basic ERC20 contract leveraging xref:#ERC20Component[ERC20Component] with a fixe
[[ERC20-constructor]]
==== `[.contract-item-name]#++constructor++#++(ref self: ContractState, name: felt252, symbol: felt252, fixed_supply: u256, recipient: ContractAddress)++` [.item-kind]#constructor#

Sets the `name` and `symbol`.
Mints `fixed_supply` tokens to `recipient`.
Sets the `name` and `symbol` and mints `fixed_supply` tokens to `recipient`.
60 changes: 56 additions & 4 deletions docs/modules/ROOT/pages/api/erc721.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ ERC721 component implementing <<IERC721,IERC721>> and <<IERC721Metadata,IERC721M

NOTE: Implementing xref:api/introspection.adoc#SRC5Component[SRC5Component] is a requirement for this component to be implemented.

[.contract-index]
.External functions
[.contract-index#ERC721Component-Embeddable-Impls]
.Embeddable Implementations
--
.IERC721Impl
* xref:#IERC721-balance_of[`++balance_of(self, account)++`]
Expand All @@ -209,8 +209,8 @@ NOTE: Implementing xref:api/introspection.adoc#SRC5Component[SRC5Component] is a
* xref:#IERC721Metadata-token_uri[`++token_uri(self, token_id)++`]
--

[.contract-index]
.camelCase support
[.contract-index#ERC721Component-Embeddable-Impls-camelCase]
.Embeddable implementations (camelCase)
--
.ER721CamelOnlyImpl
* xref:#ERC721-balanceOf[`++balanceOf(self, account)++`]
Expand Down Expand Up @@ -597,3 +597,55 @@ Interface for contracts that support receiving `safe_transfer_from` transfers.
==== `[.contract-item-name]#++on_erc721_received++#++(operator: ContractAddress, from: ContractAddress, token_id: u256, data Span<felt252>) -> felt252++` [.item-kind]#external#

Whenever an IERC721 `token_id` token is transferred to this non-account contract via <<IERC721-safe_transfer_from,IERC721::safe_transfer_from>> by `operator` from `from`, this function is called.

== Presets

[.contract]
[[ERC721]]
=== `++ERC721++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.8.0-beta.0/src/presets/erc721.cairo[{github-icon},role=heading-link]
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

```javascript
use openzeppelin::presets::ERC721;
```

Basic ERC721 contract leveraging xref:#ERC721Component[ERC721Component].

:class-hashes: xref:presets.adoc[Compiled class hash]

[.contract-index]
.{class-hashes}
--
0x04376782cbcd20a05f8e742e96150757383dab737ab3e791b8505ad856756907
--

[.contract-index]
.Constructor
--
* xref:#ERC721-constructor[`++constructor(self, name, symbol, recipient, token_ids, token_uris)++`]
--

[.contract-index]
.Embedded Implementations
--
.ERC721Component

* xref:#ERC721Component-Embeddable-Impls[`++ERC721Impl++`]
* xref:#ERC721Component-Embeddable-Impls[`++ERC721MetadataImpl++`]
* xref:#ERC721Component-Embeddable-Impls-camelCase[`++ERC721CamelOnly++`]
* xref:#ERC721Component-Embeddable-Impls-camelCase[`++ERC721MetadataCamelOnly++`]

.SRC5Component

* xref:api/introspection.adoc#SRC5Component-Embeddable-Impls[`++SRC5Impl++`]
--

[#ERC721-constructor-section]
==== Constructor

[.contract-item]
[[ERC721-constructor]]
==== `[.contract-item-name]#++constructor++#++(ref self: ContractState, name: felt252, symbol: felt252, recipient: ContractAddress, token_ids: Span<u256>, token_uris: Span<felt252>)++` [.item-kind]#constructor#

Sets the `name` and `symbol`.

Mints `token_ids` tokens with each corresponding URI from `token_uris` to `recipient`.
33 changes: 33 additions & 0 deletions docs/modules/ROOT/pages/presets.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:cairo-version: https://crates.io/crates/cairo-lang-compiler/2.3.1[cairo 2.3.1]
:scarb: https://docs.swmansion.com/scarb[scarb]

= Presets

List of "ready-to-deploy" presets available and their corresponding class hashes.

:account: xref:/api/account.adoc#Account[Account.cairo]
:erc20: xref:/api/erc20.adoc#ERC20[ERC20.cairo]
:erc721: xref:/api/erc721.adoc#ERC721[ERC721.cairo]
:cairo-and-sierra: https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/cairo-and-sierra/[Cairo and Sierra]

NOTE: Class hashes were computed using {cairo-version}.
martriay marked this conversation as resolved.
Show resolved Hide resolved

|===
| Name | Compiled Class Hash

| `{account}`
| `0x016c6081eb34ad1e0c5513234ed0c025b3c7f305902d291bad534cd6474c85bc`

| `{erc20}`
| `0x01d7085cee580ba542cdb5709bda80ebfe8bdede664261a3e6af92994d9a1de7`

| `{erc721}`
| `0x04376782cbcd20a05f8e742e96150757383dab737ab3e791b8505ad856756907`
|===

:starkli: https://book.starkli.rs/introduction[starkli]

To understand the compiled class hash term, check {cairo-and-sierra}.

TIP: {starkli} class-hash command can be used to compute the class hash from a compiled artifact. To obtain the artifact
using {scarb}, set the `casm = true` option under `\[[target.starknet-contract]]` in the `Scarb.toml` file.
martriay marked this conversation as resolved.
Show resolved Hide resolved