Skip to content

Commit

Permalink
feat: add pages for describing cairo builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolou86 committed Mar 28, 2024
1 parent 02bee62 commit b473943
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*** xref:Smart_Contracts/contract-syntax.adoc[Migrating a contract from Cairo v1 to Cairo v2]
*** xref:Smart_Contracts/cairo-and-sierra.adoc[Cairo and Sierra]
*** xref:Smart_Contracts/system-calls-cairo1.adoc[System calls]
*** xref:Smart_Contracts/builtins.adoc[Builtins]
*** xref:Smart_Contracts/serialization_of_Cairo_types.adoc[Serialization of Cairo types]
*** xref:Smart_Contracts/system-calls-cairo1.adoc[System calls]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
= Cairo Builtins

== Conceptual

Cairo builtins form the fundamental functions powering Cairo smart contract language. They enable you, as a developer, to perform various operations efficiently within the Cairo virtual machine. Understanding Cairo builtins is crucial for you to write efficient and secure smart contracts.

Cairo builtins are predefined functions provided by the Cairo runtime environment. They perform specific tasks such as arithmetic operations, bitwise manipulations, memory access, and more. These builtins are optimized for performance and are essential for you to develop complex smart contracts.

== Procedural

=== Using Cairo Builtins in Smart Contracts

==== Overview of Cairo Builtins

Cairo builtins play a vital role in Cairo smart contract development, providing you with powerful tools to implement complex logic efficiently. When writing Cairo code, invoke these builtins to perform various operations, ranging from simple arithmetic calculations to advanced memory manipulations.

To invoke a builtin in Cairo, simply use its name followed by the required arguments, similar to calling a function in other programming languages.

==== List of Cairo Builtins

[cols="1,2"]
|===
| Builtin Name | Description
| add | Performs addition operation
| sub | Performs subtraction operation
| ... | ...
|===

==== Example Usage

Here are some examples of high-level Cairo code snippets demonstrating the usage of different builtins:

[source, cairo]
----
a := add(b, c) // Addition
d := sub(e, f) // Subtraction
----

In the above code, use `add` and `sub` builtins to perform addition and subtraction operations, respectively. Invoke each builtin with specific arguments, and store the result in the corresponding variables.

=== Cairo Builtins Reference

The following table provides a reference for Cairo builtins:

[cols="1,2"]
|===
| Builtin Name | Description
| add | Performs addition operation
| sub | Performs subtraction operation
| ... | ...
|===

0 comments on commit b473943

Please sign in to comment.