This repo is a collection of examples using cross-contract calls on the NEAR platform
The folder structure of this repo is organized around a series of lessons about making cross contract calls.
The first few lessons are designed to build a clear mental model of how cross contract calls work and how to apply them.
00.orientation # explore basic concepts and examples
01.using-single-calls # explore several patterns starting with a single cross contract call
02.using-multiple-calls # explore patterns focused on coordinating multiple cross contract calls
03.using-callbacks # expore cross contract calls with callbacks
Later lessons build on the basics with more releastic (and naturally more complicated) examples.
10.linkdrop # a more complete example of using cross contract calls in a real world use case
Each of these contracts is designed to be self-contained and so may be extracted into your own projects and used as a starting point. If you do decide to use this code, please pay close attention to all top level files including:
-
NodeJS artifacts
package.json
: JavaScript project dependencies and several useful scripts
-
AssemblyScript artifacts
asconfig.json
: AssemblyScript project configuration including workspace configurationas-pect.config.js
: as-pect unit testing dependencycontracts/tsconfig.json
: load TypeScript typescontracts/as_types.ts
: AssemblyScript types header filecontracts/as-pect.d.ts
: as-pect unit testing types header file
-
Rust artifacts
Cargo.toml
: Rust project dependencies and configuration
- clone this repo locally
yarn
(ornpm install
)- yarn test:00 (or
npm run test:00
) - explore the contents of
/contracts/00.orientation
See below for more convenience scripts ...
Run unit tests
yarn test:unit # asp --verbose --nologo -f unit.spec
Run unit tests for individual examples
yarn test:u:00 # run units tests for example 00
Run simulation tests
These tests can be run from within VSCode (or any Rust-compatible IDE) or from the command line
NOTE: Rust is required
yarn test:simulate # yarn build:release && cargo test -- --nocapture
Test all
yarn test # yarn test:unit && test:simulate