Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 159 additions & 159 deletions docs/smart-contracts/anatomy/actions.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/smart-contracts/anatomy/anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {ExplainCode, Block, File} from '@site/src/components/CodeExplainer/code-

Let's illustrate the basic anatomy of a simple "Hello World" contract. The code on this page comes from our [Hello NEAR repository](https://github.com/near-examples/hello-near-examples) on GitHub.

<ExplainCode languages="js,rust,python,go" >
<ExplainCode languages="rust,js,python,go" >

<Block highlights='{"js": "1", "rust": "1", "python": "1","go":"3-6"}' fname="hello-near">

Expand Down
5 changes: 5 additions & 0 deletions docs/smart-contracts/anatomy/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This page provides a collection of best practices for writing smart contracts on

Here we lay out some best practices for writing smart contracts on NEAR, such as:

- [Store Account IDs efficiently](#store-account-ids-efficiently)
- [Enable overflow checks](#enable-overflow-checks)
- [Use `require!` early](#use-require-early)
- [Use `log!`](#use-log)
Expand All @@ -25,6 +26,10 @@ Here we lay out some best practices for writing smart contracts on NEAR, such as

---

## Store Account IDs efficiently

You can save on smart contract storage if using NEAR Account IDs by encoding them using base32. Since they consist of `[a-z.-_]` characters with a maximum length of 64 characters, they can be encoded using 5 bits per character, with terminal `\0`. Going to a size of 65 * 5 = 325 bits from the original (64 + 4) * 8 = 544 bits. This is a 40% reduction in storage costs

## Enable overflow checks

It's usually helpful to panic on integer overflow. To enable it, add the following into your `Cargo.toml` file:
Expand Down
365 changes: 101 additions & 264 deletions docs/smart-contracts/anatomy/collections.md

Large diffs are not rendered by default.

Loading