Complex Cross Contract Call
This example presents 3 instances of complex cross-contract calls. Particularly, it shows:
- How to batch multiple function calls to a same contract.
- How to call multiple contracts in parallel, each returning a different type.
- Different ways of handling the responses in the callback.
Simple Cross-Contract Calls
Check the tutorial on how to use simple cross-contract calls
Obtaining the Cross Contract Call Example
You have two options to start the Donation Example:
- You can use the app through
Github Codespaces
, which will open a web-based interactive environment. - Clone the repository locally and use it from your computer.
Codespaces | Clone locally |
---|---|
🌐 https://github.com/near-examples/cross-contract-calls |
Structure of the Example
The smart contract is available in two flavors: Rust and JavaScript
- 🌐 JavaScript
- 🦀 Rust
┌── sandbox-ts # sandbox testing
│ ├── external-contracts
│ │ ├── counter.wasm
│ │ ├── guest-book.wasm
│ │ └── hello-near.wasm
│ └── main.ava.ts
├── src # contract's code
│ ├── internal
│ │ ├── batch_actions.ts
│ │ ├── constants.ts
│ │ ├── multiple_contracts.ts
│ │ ├── similar_contracts.ts
│ │ └── utils.ts
│ └── contract.ts
├── package.json
├── README.md
└── tsconfig.json
┌── tests # sandbox testing
│ ├── external-contracts
│ │ ├── counter.wasm
│ │ ├── guest-book.wasm
│ │ └── hello-near.wasm
│ └── main.ava.ts
├── src # contract's code
│ ├── batch_actions.rs
│ ├── lib.rs
│ ├── multiple_contracts.rs
│ └── similar_contracts.rs
├── Cargo.toml # package manager
├── README.md
└── rust-toolchain.toml
Smart Contract
Batch Actions
You can aggregate multiple actions directed towards one same contract into a batched transaction. Methods called this way are executed sequentially, with the added benefit that, if one fails then they all get reverted.
- 🌐 Javascript
- 🦀 Rust
- contract.ts
- batch_actions.ts
Loading...
Loading...
Loading...