Skip to content

Commit

Permalink
Adding or updating preview build for PR pr-1177
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Mar 28, 2024
1 parent fbb77d1 commit 3f901cb
Show file tree
Hide file tree
Showing 61 changed files with 668 additions and 271 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Starknet account interface :: Starknet documentation</title>
<title>Starknet&#8217;s account interface :: Starknet documentation</title>
<link rel="canonical" href="https://docs.starknet.io/documentation/architecture_and_concepts/Accounts/approach/">
<link rel="prev" href="../introduction/">
<link rel="next" href="../validate_and_execute/">
<link rel="next" href="../account_functions/">
<meta name="generator" content="Antora 3.1.1">


Expand Down Expand Up @@ -110,7 +110,7 @@
<li><a href="../../../">Starknet</a></li>
<li>Architecture</li>
<li>Accounts</li>
<li><a href="./">Starknet account interface</a></li>
<li><a href="./">Starknet&#8217;s account interface</a></li>
</ul>
</nav>
<div class="edit-this-page">
Expand Down Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item is-current-page" data-depth="3">
<a
class="nav-link"
href="./">Starknet account interface</a>
href="./">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../validate_and_execute/">Validate and execute</a>
href="../account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down Expand Up @@ -587,41 +587,30 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<div class="toc-menu"></div>
</aside>
<article class="doc">
<h1 class="page">Starknet account interface</h1>
<h1 class="page">Starknet&#8217;s account interface</h1>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>A Starknet account contract must include the following two functions:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>__validate__</code></p>
</li>
<li>
<p><code>__execute__</code></p>
</li>
</ul>
<p>Starknet&#8217;s account structure is inspired by Ethereum&#8217;s EIP-4337, where instead of EOAs, you use smart contract accounts with arbitrary verification logic.</p>
</div>
<div class="paragraph">
<p>These functions serve distinct purposes to ensure that only the account owner can initiate transactions and that fees can be charged for the resources they use.</p>
<p>While not mandatory at the protocol level, you can use a richer standard interface for accounts, defined in <a href="https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-6.md">Starknet Improvement Proposal #6 (SNIP-6)</a>. SNIP-6 was developed by community members at OpenZeppelin, in close collaboration with wallet teams and other Core Starknet developers.</p>
</div>
<div class="paragraph">
<p>Starknet&#8217;s account type is inspired by Ethereum&#8217;s EIP-4337, where instead of an account being an EOA, it is now a smart contract account with arbitrary verification logic.</p>
</div>
<div class="paragraph">
<p>Through the use of smart contracts, you are provided with complete flexibility within your account implementation.</p>
</div>
<div class="sect1">
<h2 id="account_functions"><a class="anchor" href="#account_functions"></a>Account functions</h2>
<div class="sectionbody">
<div class="paragraph">
<p>While not mandatory at the protocol level, a richer standard interface for accounts was developed by the community. This standard was developed by OpenZeppelin, in a close collaboration with wallet teams and other Core Starknet developers. You can see the traits as defined in <a href="https://github.com/ericnordelo/SNIPs/blob/feat/standard-account/SNIPS/snip-6.md">Starknet Improvement Proposal #6 (SNIP-6)</a>.</p>
<p>A valid account contract includes specific functions, depending on the type of the contract. For more information, see <a href="../account_functions/" class="xref page">Account interface function reference</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="replay_protection"><a class="anchor" href="#replay_protection"></a>Replay protection</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In Starknet, similar to Ethereum, every contract has a nonce, which is sequential. When a transaction is sent from an account, the transaction&#8217;s nonce must match the account&#8217;s nonce. The account&#8217;s nonce is incremented after the transaction is executed, whether or not the transaction is reverted.</p>
<p>In Starknet, similar to Ethereum, every contract has a nonce, including an account contract. This nonce is sequential. The nonce of a transaction sent from an account must match the nonce of that account. After the transaction is executed, whether or not it is reverted, the nonce is incremented by one.</p>
</div>
<div class="admonitionblock note">
<table>
Expand Down Expand Up @@ -652,18 +641,18 @@ <h2 id="replay_protection"><a class="anchor" href="#replay_protection"></a>Repla
<p>It guarantees transaction hash uniqueness, which is important for a good user experience.</p>
</li>
<li>
<p>It provides replay protection to the account. Because the signature refers to a particular nonce, a malicious party cannot replay the transaction.</p>
<p>It provides replay protection to the account: Because the signature is bound to a particular nonce, a malicious party cannot replay the transaction.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>While Starknet currently determines the sequential nonce structure at the protocol level, in the future, Starknet will consider a more flexible design, extending account abstraction to nonce management, also referred to as <em>nonce abstraction</em>.</p>
<p>Starknet currently determines the nonce structure at the protocol level to be sequential. In the future, Starknet will consider a more flexible design, extending account abstraction to nonce management, previously referred to as <em>nonce abstraction</em>.</p>
</div>
</div>
</div>
<nav class="pagination">
<span class="prev"><a href="../introduction/">What is an account?</a></span>
<span class="next"><a href="../validate_and_execute/">Validate and execute</a></span>
<span class="next"><a href="../account_functions/">Account interface function reference</a></span>
</nav>
</article>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Deploying a new account :: Starknet documentation</title>
<link rel="canonical" href="https://docs.starknet.io/documentation/architecture_and_concepts/Accounts/deploying_new_accounts/">
<link rel="prev" href="../validate_and_execute/">
<link rel="prev" href="../account_functions/">
<link rel="next" href="../universal-deployer/">
<meta name="generator" content="Antora 3.1.1">

Expand Down Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../approach/">Starknet account interface</a>
href="../approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../validate_and_execute/">Validate and execute</a>
href="../account_functions/">Account interface function reference</a>
</li>
<li class="nav-item is-current-page" data-depth="3">
<a
Expand Down Expand Up @@ -719,7 +719,7 @@ <h2 id="additional_resources"><a class="anchor" href="#additional_resources"></a
</div>
</div>
<nav class="pagination">
<span class="prev"><a href="../validate_and_execute/">Validate and execute</a></span>
<span class="prev"><a href="../account_functions/">Account interface function reference</a></span>
<span class="next"><a href="../universal-deployer/">Universal Deployer Contract</a></span>
</nav>
</article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../approach/">Starknet account interface</a>
href="../approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../validate_and_execute/">Validate and execute</a>
href="../account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down Expand Up @@ -692,7 +692,7 @@ <h2 id="examples"><a class="anchor" href="#examples"></a>Examples of customizing
</div>
<nav class="pagination">
<span class="prev"><a href="../../Network_Architecture/messaging-mechanism/">L1-L2 messaging</a></span>
<span class="next"><a href="../approach/">Starknet account interface</a></span>
<span class="next"><a href="../approach/">Starknet&#8217;s account interface</a></span>
</nav>
</article>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../approach/">Starknet account interface</a>
href="../approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../validate_and_execute/">Validate and execute</a>
href="../account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../approach/">Starknet account interface</a>
href="../approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../validate_and_execute/">Validate and execute</a>
href="../account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../Accounts/approach/">Starknet account interface</a>
href="../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../Accounts/validate_and_execute/">Validate and execute</a>
href="../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down Expand Up @@ -697,7 +697,7 @@ <h2 id="l1-l2-messages"><a class="anchor" href="#l1-l2-messages"></a>L1 → L2 m
<div class="olist loweralpha">
<ol class="loweralpha" type="a">
<li>
<p>The Starknet Core Contract hashes the message parameters and updates the L1→L2 message mapping to indicate that a message with this hash was indeed sent. In fact, the L1 contract records the fee that the sender paid. For more information, see <a href="#l1-l2_message_fees">L1 → L2 message fees</a>.</p>
<p>The Starknet Core Contract hashes the message parameters and updates the L1→L2 message mapping to indicate that a message with this hash was indeed sent. In fact, the L1 contract records the fee that the sender paid. For more information, see <a href="#l1-l2-message-fees">L1 → L2 message fees</a>.</p>
</li>
</ol>
</div>
Expand Down Expand Up @@ -778,7 +778,7 @@ <h3 id="l2-l1_message_cancellation"><a class="anchor" href="#l2-l1_message_cance
<p>The user starts by calling <a href="https://github.com/starkware-libs/cairo-lang/blob/4e233516f52477ad158bc81a86ec2760471c1b65/src/starkware/starknet/eth/StarknetMessaging.sol#L134"><code>startL1ToL2MessageCancellation</code></a> with the relevant message parameters in the Starknet Core Contract. Then, after a five days delay, the user can finalize the cancellation by calling <a href="https://github.com/starkware-libs/cairo-lang/blob/4e233516f52477ad158bc81a86ec2760471c1b65/src/starkware/starknet/eth/StarknetMessaging.sol#L147"><code>cancelL1ToL2Message</code></a>.</p>
</div>
<div class="paragraph">
<p>The reason for the delay is to protect the sequencer from a DOS attack in the form of repeatedly sending and canceling a message before it is included in L1, rendering the L2 block which contains the activation of the corresponding L1 handler invalid.</p>
<p>The reason for the delay is to protect the sequencer from a DoS attack in the form of repeatedly sending and canceling a message before it is included in L1, rendering the L2 block which contains the activation of the corresponding L1 handler invalid.</p>
</div>
<div class="paragraph">
<p>Note that this flow should only be used in edge cases such as bugs on the Layer 2 contract preventing message consumption.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ <h3 class="title"><a href="../../../">Starknet</a></h3>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/approach/">Starknet account interface</a>
href="../../Accounts/approach/">Starknet&#8217;s account interface</a>
</li>
<li class="nav-item" data-depth="3">
<a
class="nav-link"
href="../../Accounts/validate_and_execute/">Validate and execute</a>
href="../../Accounts/account_functions/">Account interface function reference</a>
</li>
<li class="nav-item" data-depth="3">
<a
Expand Down Expand Up @@ -603,19 +603,19 @@ <h2 id="transaction_flow"><a class="anchor" href="#transaction_flow"></a>Transac
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Transaction submission:</strong> A transaction is submitted to one of the gateways, functioning as the mempool and marks the transaction status as <code>RECEIVED</code>.</p>
<p><strong>Transaction submission:</strong> A transaction is submitted to one of the gateways, which functions as the mempool, and marks the transaction status as <code>RECEIVED</code>.</p>
</li>
<li>
<p><strong>Mempool validation:</strong>
The mempool performs a preliminary validation on the transaction. If the transaction is invalid, it does not proceed.</p>
The mempool performs a preliminary validation on the transaction, such as ensuring that the current account balance exceeds the value of <code>max_fee</code> (prior to v3 transactions) or assuring the transaction&#8217;s calldata length is within the legal limit. If the transaction is invalid, it does not proceed.</p>
<div class="paragraph">
<p>Mempool validation in this context is analogous to Ethereum&#8217;s signature checking, including running the account&#8217;s <code>__validate__</code> function on an <code>INVOKE</code> transaction, <code>__validate_declare__</code> on a <code>DECLARE</code> transaction, or <code>__validate_deploy__</code> on a <code>DEPLOY_ACCOUNT</code> transaction, ensuring that the current account balance exceeds the value of <code>max_fee</code> (prior to v3 transactions), and more.</p>
</div>
</li>
<li>
<p><strong>Sequencer validation:</strong> The sequencer performs preliminary validation on the transaction before executing it to ensure that the transaction is still valid. If the transaction is invalid, it does not proceed.</p>
<div class="paragraph">
<p>This validation stage repeats the same validation run during the Mempool validation.</p>
<p>This validation stage repeats the same validation run during the mempool validation.</p>
</div>
</li>
<li>
Expand Down
Loading

0 comments on commit 3f901cb

Please sign in to comment.