Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example smart contracts with comprehensive README. #1

Merged
merged 29 commits into from
Nov 7, 2022

Conversation

deuszx
Copy link
Collaborator

@deuszx deuszx commented Oct 28, 2022

This PR adds two simple smart contracts showcasing all the basic building blocks of writing smart contracts, including:

  • defining and emitting an event
  • unit testing
  • accepting token payments
  • cross-contract calls
  • transferring tokens
  • and more (described in the associated README).

The README.md itself contains short descriptions of all techniques used when writing the contracts. There's also a description about deploying it to Contracts UI.

What will follow will be a simple frontend that interacts with the deployed contracts showing how to publish transaction to a chain (signing it with polkadotjs app extension), how to await finalization, read the results, etc.

contracts/README.md Outdated Show resolved Hide resolved
contracts/README.md Outdated Show resolved Hide resolved
contracts/README.md Outdated Show resolved Hide resolved
contracts/README.md Show resolved Hide resolved
contracts/README.md Outdated Show resolved Hide resolved
contracts/bulletin_board/Cargo.toml Show resolved Hide resolved
contracts/bulletin_board/rustfmt.toml Outdated Show resolved Hide resolved
contracts/highlighted_posts/Cargo.toml Outdated Show resolved Hide resolved
contracts/bulletin_board/lib.rs Outdated Show resolved Hide resolved
contracts/bulletin_board/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@h4nsu h4nsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job! :D

contracts/README.md Outdated Show resolved Hide resolved
contracts/README.md Show resolved Hide resolved
contracts/README.md Outdated Show resolved Hide resolved
contracts/README.md Outdated Show resolved Hide resolved
contracts/README.md Show resolved Hide resolved
contracts/highlighted_posts/lib.rs Outdated Show resolved Hide resolved
contracts/highlighted_posts/lib.rs Outdated Show resolved Hide resolved
contracts/bulletin_board/lib.rs Show resolved Hide resolved
contracts/bulletin_board/lib.rs Outdated Show resolved Hide resolved
contracts/bulletin_board/lib.rs Outdated Show resolved Hide resolved
contracts/.gitignore Outdated Show resolved Hide resolved
contracts/README.md Outdated Show resolved Hide resolved
// simpler for the caller to handle an error - in contract to
// `panic!` that doesn't contain any additional
// information and is simply `CalleeTrapped`.
if transferred_amount < listing_cost {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the caller be reimbursed with transferred amount here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if my understanding is correct then yes -- returning Err is equivalent to panic! w.r.t. to contract's state reversal. I can add a test for that though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd expect that too, but whatever amount is sent with the tx uses the balances pallet (not contracts state from the pallet contracts). But it'd actually be a bug if it wasn't

deuszx and others added 4 commits November 7, 2022 16:11
Co-authored-by: Michal Handzlik <h4nsu@users.noreply.github.com>
Co-authored-by: Filip Bielejec <fbielejec@gmail.com>
@deuszx deuszx merged commit 79a0dcd into main Nov 7, 2022
@deuszx deuszx deleted the bulletinpillar branch November 7, 2022 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants