near / devrel

The space for DevRel
MIT License
9 stars 0 forks source link

Add cross contract example #303

Open ilblackdragon opened 3 years ago

ilblackdragon commented 3 years ago

Currently on examples.near.org there are only Counter example that says cross contract and is not really representing cross contract examples.

Having a good cross contract example is important as there are many caveats that are unclear to new near developers.

zavodil commented 3 years ago

I made a cross-contract counter example for my Rust lessons here https://github.com/zavodil/rust-counter-cross-contract We deploy 2 counters there and second counter can't be greater than the first one. Is this case is good enough to be an example?

BenKurrek commented 2 years ago

I took inspiration from Vadim's contract and created a simple example with a frontend. There is a team manager contract that includes team A and team B.

There is the original counter contract that has been modified to include a cross-contract call to the team manager contract.

When you increment the counter, the team with the least amount of players gets assigned a person (incremented). When you decrement the counter, the team with the most amount of players has a person removed (decremented). When you reset the counter, both teams are set to 0.

Link to the repo --> https://github.com/near-examples/cross-contract-rust-counter

thisisjoshford commented 2 years ago

Let's create a section in docs for cross-contract calls and create a walkthrough for this repo. Let's also add the cross contract example from near-sdk.io to this section as well @BenKurrek .

thisisjoshford commented 2 years ago

Hey @BenKurrek, I don't see a PR for the doc I suggested we create to close this issue. Am I missing it?

BenKurrek commented 2 years ago

@thisisjoshford It's on my to-do list - pretty swamped atm. Let's close this issue maybe and create a new one for adding a tutorial in dev-docs.