Archives: Docs

Docs

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 »

Cross-Contract Calls

Login with NEARYour contract can interact with other deployed contracts, querying information and executing functions on them. Since NEAR is a sharded blockchain, its cross-contract calls behave differently than calls do in other chains. In NEAR. cross-contract calls are asynchronous and independent. info Cross-Contract Calls are **Independent** You will need two independent functions: one to …

Cross-Contract Calls 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 »

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 »

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 »

Scroll to Top