Docs Category: 2.smart-contracts

Environment

Login with NEAREvery method execution has an environment associated with information such as: Who called the method How much money is attached to the call How many computational resources are available The current timestamp Helper functions for Public Key derivation, for example Environment Variables | Variable Name | SDK Variable | Description | |————————|——————————-|————————————————————————————–| | …

Environment Read More »

Best Practices

Login with NEARBest practices Enable overflow checks It’s usually helpful to panic on integer overflow. To enable it, add the following into your Cargo.toml file: [profile.release] overflow-checks = true Use require! early Try to validate the input, context, state and access using require! before taking any actions. The earlier you panic, the more gas you …

Best Practices Read More »

Collections

Login with NEARWhen deciding on data structures it is important to understand their tradeoffs. Choosing the wrong structure can create a bottleneck as the application scales, and migrating the state to the new data structures will come at a cost. You can choose between two types of collections: Native collections (e.g. Array, Map, Set), provided …

Collections Read More »

Transfers & Actions

Login with NEARSmart contracts can perform specific Actions such as transferring NEAR, or calling other contracts. An important property of Actions is that they can be batched together when acting on the same contract. Batched actions act as a unit: they execute in the same receipt, and if any fails, then they all get reverted. …

Transfers & Actions Read More »

Basic Anatomy

Login with NEARLet’s illustrate the basic anatomy of a simple “Hello World” contract. The code on this page comes from our Hello NEAR repository on GitHub. ### Importing the SDK All contracts will import the **NEAR SDK**, enabling them to [access the execution environment](https://raw.githubusercontent.com/Techbridge3/docs/master/docs/2.build/2.smart-contracts/anatomy/./environment.md), [call other contracts](https://raw.githubusercontent.com/Techbridge3/docs/master/docs/2.build/2.smart-contracts/anatomy/./crosscontract.md), [transfer tokens](https://raw.githubusercontent.com/Techbridge3/docs/master/docs/2.build/2.smart-contracts/anatomy/./actions.md), and much more. You can also …

Basic Anatomy Read More »

What is a Smart Contract?

Login with NEARSmart contracts are pieces of executable code that live in a NEAR account. They can store data, perform transactions in the account’s name, and expose methods so other accounts can interact with them. Developers can choose between using Javascript or Rust to write smart contracts in NEAR. Indistinctly from the language chosen, the …

What is a Smart Contract? Read More »

Scroll to Top