Docs Category: 2.smart-contracts

Yield and Resume

Login with NEARNEAR smart contracts can yield execution, until an external service resumes them. In practice, the contract yields a cross-contract call to itself, until an external service executes a function and the contract decides to resume. This is a powerful feature that allows contracts to wait for external events, such as a response from …

Yield and Resume Read More »

SDK Types

Login with NEARLets discuss which types smart contracts use to input and output data, as well as how such data is stored and handled in the contract’s code. ### Native Types Smart contracts can receive, store and return data using JS native types: – `string` – `number` – `boolean` – `Array` – `Map` – `Object` …

SDK Types Read More »

Notes on Serialization

Login with NEARSmart contracts need to be able to communicate complex data in a simple way, while also reading and storing such data into their states efficiently. To achieve such simple communication and efficient storage, smart contracts morph the data from their complex representation into simpler ones. This process of translating complex objects into simpler …

Notes on Serialization Read More »

State

Login with NEARSmart contracts store data in their account’s state, which is public on the chain. The storage starts empty until a contract is deployed and the state is initialized. It is important to know that the account’s code and account’s storage are independent. Updating the code does not erase the state. ### Defining the …

State Read More »

Reproducible Builds

Login with NEARReproducible builds let different people build the same program and get the exact same outputs as one another. It helps users trust that deployed contracts are built correctly and correspond to the source code. To verify your contract user can build it themselves and check that the binaries are identical. Problem If you …

Reproducible Builds Read More »

Serialization Protocols

Login with NEARSerialization formats within the SDK define how data structures are translated into bytes which are needed for passing data into methods of the smart contract or storing data in state. For the case of method parameters, JSON (default) and Borsh are supported with the SDK and for storing data on-chain Borsh is used. …

Serialization Protocols Read More »

External Interface

Login with NEARSmart contracts expose functions so users can interact with them. There are different types of functions including read-only, private and payable. ### Contract’s Interface All **public** functions in the contract are part of its **interface**. They can be called by anyone, and are the only way to interact with the contract. Exposing trait …

External Interface Read More »

Reducing Contract Size

Login with NEARReducing a contract’s size This page is made for developers familiar with lower-level concepts who wish to reduce their contract size significantly, perhaps at the expense of code readability. Some common scenarios where this approach may be helpful: contracts intended to be tied to one’s account management contracts deployed using a factory future …

Reducing Contract Size 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 »

Scroll to Top