specs/spec/9.html

13 lines
24 KiB
HTML
Raw Normal View History

2021-11-22 18:48:50 +00:00
<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <title>9/ETHEREUM-USAGE - Status Specification</title> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="/assets/css/just-the-docs-default.css"> <script type="text/javascript" src="/assets/js/vendor/lunr.min.js"></script> <script type="text/javascript" src="/assets/js/just-the-docs.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Begin Jekyll SEO tag v2.7.1 --> <title>9/ETHEREUM-USAGE | Status Specification</title> <meta name="generator" content="Jekyll v4.2.1" /> <meta property="og:title" content="9/ETHEREUM-USAGE" /> <meta property="og:locale" content="en_US" /> <link rel="canonical" href="https://specs.status.im/spec/9" /> <meta property="og:url" content="https://specs.status.im/spec/9" /> <meta property="og:site_name" content="Status Specification" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="9/ETHEREUM-USAGE" /> <script type="application/ld+json"> {"@type":"WebPage","url":"https://specs.status.im/spec/9","headline":"9/ETHEREUM-USAGE","@context":"https://schema.org"}</script> <!-- End Jekyll SEO tag --> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-link" viewBox="0 0 24 24"> <title>Link</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path> </svg> </symbol> <symbol id="svg-search" viewBox="0 0 24 24"> <title>Search</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> </svg> </symbol> <symbol id="svg-menu" viewBox="0 0 24 24"> <title>Menu</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"> <line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line> </svg> </symbol> <symbol id="svg-arrow-right" viewBox="0 0 24 24"> <title>Expand</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"> <polyline points="9 18 15 12 9 6"></polyline> </svg> </symbol> <symbol id="svg-doc" viewBox="0 0 24 24"> <title>Document</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> </svg> </symbol> </svg> <div class="side-bar"> <div class="site-header"> <a href="https://specs.status.im/" class="site-title lh-tight"> Status Specification </a> <a href="#" id="menu-button" class="site-button"> <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-menu"></use></svg> </a> </div> <nav role="navigation" aria-label="Main" id="site-nav" class="site-nav"> <ul class="nav-list"><li class="nav-list-item active"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="https://specs.status.im/spec/" class="nav-list-link">Stable specs</a><ul class="nav-list "><li class="nav-list-item "><a href="https://specs.status.im/spec/1" class="nav-list-lin
2021-11-16 14:54:10 +00:00
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L499</p> <h4 id="pendingnonceat"> <a href="#pendingnonceat" class="anchor-heading" aria-labelledby="pendingnonceat"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> PendingNonceAt </h4> <p><code class="language-plaintext highlighter-rouge">PendingNonceAt</code> returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L440</p> <h4 id="suggestgasprice"> <a href="#suggestgasprice" class="anchor-heading" aria-labelledby="suggestgasprice"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> SuggestGasPrice </h4> <p><code class="language-plaintext highlighter-rouge">SuggestGasPrice</code> retrieves the currently suggested gas price to allow a timely execution of a transaction.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L487</p> <h4 id="sendtransaction"> <a href="#sendtransaction" class="anchor-heading" aria-labelledby="sendtransaction"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> SendTransaction </h4> <p><code class="language-plaintext highlighter-rouge">SendTransaction</code> injects a signed transaction into the pending pool for execution.</p> <p>If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L512</p> <h3 id="fetching-balance"> <a href="#fetching-balance" class="anchor-heading" aria-labelledby="fetching-balance"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Fetching balance </h3> <p>A Status node fetches the current and historical [ECR20] (https://eips.ethereum.org/EIPS/eip-20) and ETH balance for the user wallet address. Collectibles following the <a href="https://eips.ethereum.org/EIPS/eip-721">ECR-721</a> are also fetched if enabled.</p> <p>A Status node supports by default the following <a href="https://github.com/status-im/status-react/blob/develop/src/status_im/ethereum/tokens.cljs">tokens</a>. Custom tokens can be added by specifying the <code class="language-plaintext highlighter-rouge">address</code>, <code class="language-plaintext highlighter-rouge">symbol</code> and <code class="language-plaintext highlighter-rouge">decimals</code>.</p> <h4 id="blockbyhash"> <a href="#blockbyhash" class="anchor-heading" aria-labelledby="blockbyhash"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> BlockByHash </h4> <p><code class="language-plaintext highlighter-rouge">BlockByHash</code> returns the given full block.</p> <p>It is used by status to fetch a given block which will then be inspected for transfers to the user address, both tokens and ETH.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L78</p> <h4 id="blockbynumber"> <a href="#blockbynumber" class="anchor-heading" aria-labelledby="blockbynumber"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> BlockByNumber </h4> <p><code class="language-plaintext highlighter-rouge">BlockByNumber</code> returns a block from the current canonical chain. If number is nil, the latest known block is returned.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L82</p> <h4 id="filterlogs"> <a href="#filterlogs" class="anchor-heading" aria-labelledby="filterlogs"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> FilterLogs </h4> <p><code class="language-plaintext highlighter-rouge">FilterLogs</code> executes a filter query.</p> <p>Status uses this function to filter out logs, using the hash of the block and the address of interest, both inbound and outbound.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L377</p> <h4 id="nonceat"> <a href="#nonceat" class="anchor-heading" aria-labelledby="nonceat"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> NonceAt </h4> <p><code class="language-plaintext highlighter-rouge">NonceAt</code> returns the account nonce of the given account.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L366</p> <h4 id="transactionbyhash"> <a href="#transactionbyhash" class="anchor-heading" aria-labelledby="transactionbyhash"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> TransactionByHash </h4> <p><code class="language-plaintext highlighter-rouge">TransactionByHash</code> returns the transaction with the given hash, used to inspect those transactions made/received by the user.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L202</p> <h4 id="headerbynumber"> <a href="#headerbynumber" class="anchor-heading" aria-labelledby="headerbynumber"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> HeaderByNumber </h4> <p><code class="language-plaintext highlighter-rouge">HeaderByNumber</code> returns a block header from the current canonical chain.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L172</p> <h4 id="transactionreceipt"> <a href="#transactionreceipt" class="anchor-heading" aria-labelledby="transactionreceipt"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> TransactionReceipt </h4> <p><code class="language-plaintext highlighter-rouge">TransactionReceipt</code> returns the receipt of a transaction by transaction hash. It is used in status to check if a token transfer was made to the user address.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
</code></pre></div></div> <p>https://github.com/ethereum/go-ethereum/blob/26d271dfbba1367326dec38068f9df828d462c61/ethclient/ethclient.go#L270</p> <h2 id="ens"> <a href="#ens" class="anchor-heading" aria-labelledby="ens"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> ENS </h2> <p>All the interactions with <code class="language-plaintext highlighter-rouge">ENS</code> are made through the <a href="https://github.com/ensdomains/ens">ENS contract</a></p> <p>For the <code class="language-plaintext highlighter-rouge">stateofus.eth</code> username, one can be registered through these <a href="https://github.com/status-im/ens-usernames">contracts</a></p> <h3 id="registering-releasing-and-updating"> <a href="#registering-releasing-and-updating" class="anchor-heading" aria-labelledby="registering-releasing-and-updating"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Registering, releasing and updating </h3> <ul> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L113">Registering a username</a></li> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L131">Releasing a username</a></li> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L174">Updating a username</a></li> </ul> <h3 id="slashing"> <a href="#slashing" class="anchor-heading" aria-labelledby="slashing"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Slashing </h3> <p>Usernames MUST be in a specific format, otherwise they MAY be slashed:</p> <ul> <li>They MUST only contain alphanumeric characters</li> <li>They MUST NOT be in the form <code class="language-plaintext highlighter-rouge">0x[0-9a-f]{5}.*</code> and have more than 12 characters</li> <li>They MUST NOT be in the <a href="https://github.com/status-im/ens-usernames/blob/47c4c6c2058be0d80b7d678e611e166659414a3b/config/ens-usernames/reservedNames.js">reserved list</a></li> <li> <p>They MUST NOT be too short, this is dynamically set in the contract and can be checked against the <a href="https://github.com/status-im/ens-usernames/blob/master/contracts/registry/UsernameRegistrar.sol#L26">contract</a></p> </li> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L237">Slash a reserved username</a></li> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L261">Slash an invalid username</a></li> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L215">Slash a username too similar to an address</a></li> <li><a href="https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/contracts/registry/UsernameRegistrar.sol#L200">Slash a username that is too short</a></li> </ul> <p>ENS names are propagated through <code class="language-plaintext highlighter-rouge">ChatMessage</code> and <code class="language-plaintext highlighter-rouge">ContactUpdate</code> <a href="./6-payloads.md">payload</a>. A client SHOULD verify ens names against the public key of the sender on receiving the message against the <a href="https://github.com/ensdomains/ens">ENS contract</a></p> <h2 id="copyright"> <a href="#copyright" class="anchor-heading" aria-labelledby="copyright"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Copyright </h2> <p>Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>.</p> </div> </div> <div class="search-overlay"></div> </div> </body> </html>