-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Documentation | ||
|
||
It's important to take the time to document your code. It will helps developers and users to understand the contract and its functionalities. | ||
|
||
In Cairo, you can add comments with `//`. | ||
|
||
### Contract Interface: | ||
|
||
In smart contracts, you will often have a trait that defines the contract's interface (with `#[starknet::interface]`). | ||
This is the perfect place to include detailed documentation explaining the purpose and functionality of the contract entry points. You can follow this template: | ||
|
||
```rust | ||
#[starknet::interface] | ||
trait IContract<TContractState> { | ||
/// High-level description of the function | ||
/// | ||
/// # Arguments | ||
/// * `arg_1` - Description of the argument | ||
/// * `arg_n` - ... | ||
/// | ||
/// # Returns | ||
/// High-level description of the return value | ||
fn do_something(ref self: TContractState, arg_1: T_arg_1) -> T_return; | ||
} | ||
``` | ||
|
||
Keep in mind that this should not describe the implementation details of the function, but rather the high-level purpose and functionality of the contract from the perspective of a user. | ||
|
||
### Implementation Details: | ||
|
||
When writing the logic of the contract, you can add comments to describe the technical implementation details of the functions. | ||
|
||
> Avoid over-commenting: Comments should provide additional value and clarity. |