Commit 775992ea authored by Stefanie Doll's avatar Stefanie Doll Committed by Hero Bird

Add ./examples README & basic build instructions (#236)

* Added ./examples README

* Add build description to README's

* Update README.md
Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

* Update README.md
Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

* Update examples/README.md
Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

* Update examples/README.md
Co-Authored-By: default avatarHero Bird <robin.freyler@gmail.com>

* ABI -> Metadata

* ABI -> Metadata pt. 2

* Wording for --force

* Removed testing paragraph

* Update examples/README.md
Co-Authored-By: Shawn Tabrizi's avatarShawn Tabrizi <shawntabrizi@gmail.com>

* Update examples/README.md
Co-Authored-By: Shawn Tabrizi's avatarShawn Tabrizi <shawntabrizi@gmail.com>

* Update README.md
parent 9ba1d064
Pipeline #56937 failed with stages
in 8 minutes and 49 seconds
# ink! - Parity's ink to write smart contracts
| Linux | Codecov | Coveralls | LoC |
|:------------------:|:--------------------:|:----------------------:|:----------------:|
| [![linux][A1]][A2] | [![codecov][C1]][C2] | [![coveralls][D1]][D2] | [![loc][E1]][E2] |
[A1]: https://travis-ci.org/paritytech/ink.svg?branch=master
[A2]: https://travis-ci.org/paritytech/ink
[C1]: https://codecov.io/gh/paritytech/ink/branch/master/graph/badge.svg
[C2]: https://codecov.io/gh/paritytech/ink/branch/master
[D1]: https://coveralls.io/repos/github/paritytech/ink/badge.svg?branch=master
[D2]: https://coveralls.io/github/paritytech/ink?branch=master
[E1]: https://tokei.rs/b1/github/paritytech/ink?category=code
[E2]: https://github.com/Aaronepower/tokei#badges
[F1]: https://img.shields.io/badge/docs-core-blue.svg
[F2]: https://paritytech.github.io/ink/ink_core
[G1]: https://img.shields.io/badge/docs-model-blue.svg
[G2]: https://paritytech.github.io/ink/ink_model
[H1]: https://img.shields.io/badge/docs-abi-blue.svg
[H2]: https://paritytech.github.io/ink/ink_abi
| Linux | Codecov | Coveralls | LoC |
| :----------------: | :------------------: | :--------------------: | :--------------: |
| [![linux][a1]][a2] | [![codecov][c1]][c2] | [![coveralls][d1]][d2] | [![loc][e1]][e2] |
[a1]: https://travis-ci.org/paritytech/ink.svg?branch=master
[a2]: https://travis-ci.org/paritytech/ink
[c1]: https://codecov.io/gh/paritytech/ink/branch/master/graph/badge.svg
[c2]: https://codecov.io/gh/paritytech/ink/branch/master
[d1]: https://coveralls.io/repos/github/paritytech/ink/badge.svg?branch=master
[d2]: https://coveralls.io/github/paritytech/ink?branch=master
[e1]: https://tokei.rs/b1/github/paritytech/ink?category=code
[e2]: https://github.com/Aaronepower/tokei#badges
[f1]: https://img.shields.io/badge/docs-core-blue.svg
[f2]: https://paritytech.github.io/ink/ink_core
[g1]: https://img.shields.io/badge/docs-model-blue.svg
[g2]: https://paritytech.github.io/ink/ink_model
[h1]: https://img.shields.io/badge/docs-abi-blue.svg
[h2]: https://paritytech.github.io/ink/ink_abi
**IMPORTANT NOTE:** WORK IN PROGRESS! Do not expect this to be working.
......@@ -33,9 +27,9 @@ For more information please visit [the ink! tutorial](https://substrate.dev/subs
## Developer Documentation
| `ink_abi` | `ink_core` | `ink_model` |
|-----------|------------|-------------|
| [![][H1]][H2] | [![][F1]][F2] | [![][G1]][G2] |
| `ink_abi` | `ink_core` | `ink_model` |
| ------------- | ------------- | ------------- |
| [![][h1]][h2] | [![][f1]][f2] | [![][g1]][g2] |
### Scripts
......@@ -49,17 +43,32 @@ For building the example smart contracts found under `examples` you will need to
cargo install --git https://github.com/paritytech/ink cargo-contract --force
```
We use the `--force` to ensure you are updated to the most recent `cargo-contract` version.
Use the `--force` to ensure you are updated to the most recent `cargo-contract` version.
### Build example contract and generate the contracts metadata
Please visit [the documentation](https://substrate.dev/substrate-contracts-workshop/#/0/building-your-contract)
about building contracts and generating metadata.
To build a single example and generate the contracts Wasm file, navigate to the root of the example smart contract and run:
### Hello, World! - The Flipper
`cargo contract build`
To generate the contract metadata (a.k.a. the contract ABI), run the following command:
`cargo contract generate-metadata`
You should now have an optimized `<contract-name>.wasm` file and an `metadata.json` file in the `target` folder of the contract.
For further information, please have a look at our [smart contracts workshop](https://substrate.dev/substrate-contracts-workshop/).
## Hello, World! - The Flipper
The `Flipper` contract is a simple contract containing only a single `bool` value
that it can flip from `true` to `false` and vice versa and return the current state.
Below you can see the code using the `ink_lang2` frontend to ink!.
To create your own version of the flipper contract, you first need to initialize a new ink! project in your working directory.
`cargo contract new flipper`
Below you can see the code using the `ink_lang2` version of ink!.
```rust
use ink_core::storage;
......@@ -127,6 +136,8 @@ mod flipper {
}
```
Place this code in the ./lib.rs`file of your flipper contract and run`cargo contract build && cargo contract generate-metadata` to build your first ink! smart contract example.
## Contribution
Visit our [contribution guidelines](CONTRIBUTING.md) for more information.
......@@ -134,4 +145,3 @@ Visit our [contribution guidelines](CONTRIBUTING.md) for more information.
## License
The entire code within this repository is licensed under the [GPLv3](LICENSE). Please [contact us](https://www.parity.io/contact/) if you have questions about the licensing of our products.
of our products.
# ink! code examples
This folder contains a set of example contracts for ink!.
Have a look at the different examples to better understand how to use ink! to build your own Substrate smart contracts.
## Preparation
For building the example smart contracts found in this folder you will need to have `cargo-contract` installed.
```
cargo install --force --git https://github.com/paritytech/ink cargo-contract
```
We use the `--force` to update to the most recent `cargo-contract` version.
## Build example contract and generate the contracts metadata
To build a single example and generate the contracts Wasm file, navigate to the root of the smart contract and run the following command:
`cargo contract build`
To generate the contract metadata (a.k.a. the contract ABI), run the following command:
`cargo contract generate-metadata`
You should now have an optimized `<contract-name>.wasm` file and an `metadata.json` file in the `target` folder of your contract.
## License
The entire code within this repository is licensed under the [GPLv3](LICENSE). Please [contact us](https://www.parity.io/contact/) if you have questions about the licensing of our products.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment