These contracts form a basic example for performing cross-contract calls using the classic Rust counter example.
- Deploy the modified
counter
found in the contract folder and specifyTEAM_MANAGER_CONTRACT_ID
. - Deploy second contract found in the
team-manager
folder. - The team manager contract consists of two teams - team A and team B. When you incremement the counter, the team with the least amount of players will get assigned a member.
- When you decremement the counter, the team with the most amount of players will have a member removed.
- If there is a tie, team A will be prioritized.
- When you reset the counter, both teams will be reset to zero.
Original Rust counter documentation:
Install dependencies:
yarn
If you don't have Rust
installed, complete the following 3 steps:
- Install Rustup by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
(Taken from official installation guide)
- Configure your current shell by running:
source $HOME/.cargo/env
- Add wasm target to your toolchain by running:
rustup target add wasm32-unknown-unknown
Next, make sure you have near-cli
by running:
near --version
If you need to install near-cli
:
npm install near-cli -g
Clone the repository.
git clone https://github.com/near-examples/cross-contract-rust-counter.git
When in the root folder, you can build both contracts which will create the wasms to out/counter.wasm
and out/team-manager.wasm
yarn build
When in the root folder, you can run unit tests for both contracts using the following command.
yarn test:cargo
After building, you can deploy the contracts to a dev account using the following commands:
near dev-deploy --wasmFile out/counter.wasm
And
near dev-deploy --wasmFile out/team-manager.wasm
To deploy to an existing account, login with near-cli
by following the instructions after this command:
near login
You can then deploy to the logged in account via the following:
near deploy --accountId YOUR_ACCOUNT_ID --wasmFile out/counter.wasm
And
near deploy --accountId YOUR_ACCOUNT_ID --wasmFile out/team-manager.wasm
cd contract
cargo doc --no-deps --open