Code Monkey home page Code Monkey logo

ink-docs's Introduction

ink-docs

This is the documentation portal for ink!. The latest version is always available at https://use.ink.

Run it locally via

yarn
yarn start

# For the Spanish page, will be available at http://localhost:8080/es/.
yarn start --locale es

We want to provide comprehensive documentation for anything you need to work with ink! here.

If you spot gaps in the information provided, or are uncertain about any specific area, please do log an issue or make a pull-request.

We really want to have good documentation here and allow people to be productive right from the start.

Development Notes

If you need to run ReCaptcha on your localhost you will need to add dev.use.ink to your /etc/hosts.

Linux

sudo bash -c 'echo "127.0.0.1 dev.use.ink" >> /etc/hosts'

OSX

sudo bash -c 'echo "::1 dev.use.ink" >> /etc/hosts'

Then visit http://dev.use.ink:8080/ (Don't forget the port number)

ink-docs's People

Contributors

0xf333 avatar a-mont avatar agryaznov avatar al3mart avatar alexd10s avatar ascjones avatar carinaluise avatar cmichi avatar dartdart26 avatar davidsemakula avatar dependabot[bot] avatar doubleotheven avatar hcastano avatar ipapandinas avatar jangorecki avatar jubnzv avatar muddlebee avatar pacoyang avatar pandres95 avatar pcorrado-np avatar peetzweg avatar peterwht avatar pgherveou avatar pmikolajczyk41 avatar robbepop avatar rzadp avatar saltict avatar semuelle avatar statictype avatar xermicus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ink-docs's Issues

Add section "Upgradeable Contracts"

We should add a section "Upgradeable Contracts" under "Basics".

ink! currently has those three approaches for upgradeable contracts: https://github.com/paritytech/ink/tree/master/examples/upgradeable-contracts.

We should have a page in our documentation on each, explaining the use cases and how to use them. The result of use-ink/ink#1247 should be incorporated here as well.

If you have ideas for illustrations to accompany these pages: feel free to approach our illustrator to create some in the ink! style.

Add section "Common Misconceptions"

We should add a section "Common Misconceptions" or "Common (Beginner?) Mistakes" with the things we see in real-world contracts. Such as:

  • A misconception that we often see is that developers think the smart contract is the actual interface for the user.
    That's why we often see mnemonic String types returned (in the worst case verbatim error messages instead of error codes).

  • We should explain why contract size is important.
    We sometimes get questions like "My 100K contract can't be deployed". This is usually due to some third party crate dependency with default features enabled. Oftentimes the size can be reduced by tuning the features of that dep or using the built-in ink! API instead (oftentimes it's crypto/hashing dependencies).

  • We should explain better why String should be avoided and especially what the alternatives are.
    We already have a section How do I use String in my contract? in our FAQ, but it goes in a bit of a different direction. Using String pulls in logic needed for e.g. UTF-8 handling, which one might not need, but it blows up the contract file size. Also, for String dynamic allocation is needed, increasing the file size of the contract as well and being expensive in terms of performance. A use-case I have now seen a couple times is to use String to generate some uuid, we should look into an alternative for doing that.

dylint-link required to be installed first before cargo-contract

Running the Setup process in the Linux (Ubuntu)
Current documentation for setup , directly bring request to install "cargo-contract"

encountered following error

The following warnings were emitted during compilation:

warning: Git command failed with status: exit status: 128
warning: Could not find .git/HEAD searching from /home/acceleration/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-contract-1.2.0 upwards!

error: failed to run custom build command for cargo-contract v1.2.0

Caused by:
process didn't exit successfully: /tmp/cargo-installXRjowk/release/build/cargo-contract-dce69dd49011874b/build-script-build (exit status: 1)
--- stdout
cargo:warning=Git command failed with status: exit status: 128
cargo:rustc-env=CARGO_CONTRACT_CLI_IMPL_VERSION=1.2.0-unknown-x86_64-linux-gnu
cargo:warning=Could not find .git/HEAD searching from /home/acceleration/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-contract-1.2.0 upwards!
Creating template zip: template_dir '/home/acceleration/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-contract-1.2.0/templates/new', destination archive '/tmp/cargo-installXRjowk/release/build/cargo-contract-31cbde62fc603f30/out/template.zip'
Done: /home/acceleration/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-contract-1.2.0/templates/new written to /tmp/cargo-installXRjowk/release/build/cargo-contract-31cbde62fc603f30/out/template.zip

--- stderr
Encountered error: dylint-link was not found!
Make sure it is installed and the binary is in your PATH environment.

You can install it by executing cargo install dylint-link.
warning: build failed, waiting for other jobs to finish...

End of Error

The solution is also found at the end of the error msg , is to install the dylink-link.

Require this to be added into the documentation

Would like to request for others to check if they encounter the same issue.

Search box is not working

Not sure this happens only for me or not.
But, even If I push the search box, it doesn't work. So, I cannot search information in the doc which is painful.

I'd appreciated if you would check. Thank you
Screen Shot 2022-09-12 at 12 21 43
On the top right button.

Improve Upgradeability Contract Examples

The current examples of upgradeability and call forwarding are confusing, incomplete, and
and some cases misleading.

We should update these examples to show correct behaviour, and to guide contract
developers into using correct patterns.

List of examples that we should aim to provide:

Concepts we want to illustrate:

  • Storage collisions and corruption
  • Safe delegate calls
  • Effects and implications of different ink::env::CallFlags
### Tasks
- [x] `delegate_call` example
- [x] ~~A EIP-1967 based proxy~~ Achieved by `set_code_hash()`

Describe new constructor default payable behaviour

Before use-ink/ink#1065 constructors in ink! were payable (that is, they accepted a value) by default. For reasons described in that PR this is no longer the default behaviour.

Now, constructors will need to opt into accepting a value through the use of the already existing #[ink(payable)] attribute.

Update all docs.rs links to stable release version

Right now we're in-between releases so links to the latest documentation are changing even during the course of a single PR (see #137). Instead of fixing them all in the PRs we should do one big check once ink! 4.0 is finally released.

[FARQ] Frequently Asked Rust Questions

We should add a section for frequently asked Rust questions, that don't specifically address an ink! issue, but still come up often.

Examples are:

  • I get an error that the Encode trait is missing, what should I do now?

[basics] Document storage and code rent

This issue can be tackled after paritytech/substrate#7533 has been implemented.

ToDo

  • Add a chapter describing the behavior of the contract pallets storage and code rent.
  • Describe how relevant information regarding how much storage the can be accessed from ink!
    • For example: How big is the size the contract's code/storage occupies on the chain? What is the cost? What are relevant constants and thresholds?

Event calendar

As ink! ecosystem is growing, we have witnessed increased interest and activity in hackathon and education spaces.
I think it would helpful for community to have a calendar with all upcoming educational courses and upcoming hackathons to be present in the calendar format on the website.

Improve search for content under different ink! version

Hey there, at the moment (at least for me), the search bar in the upper right returns results for both documented ink! versions (3 & 4). And it doesn't even highlight the version. I find it quite counter-intuitive (esp. for newbies) accidentally switching to an earlier version of the documentation without even noticing.

IMO, it should either highlight the version next to the results or (preferred) search should be only within the currently active version of the documentation.

Document Substrate's Nonce Behaviour

Substrate is unusual from other blockchains because an account nonce can be reset if, for
example, an account's balance drops below the existential deposit for the Substrate chain
it's on.

In other blockchain ecosystems this is not the case, so an account nonce is typically
used to provide replay protection. In Substrate this is done through the use of
transaction mortality.

Since smart contract developers will be coming from different ecosystems we should
document this behaviour for them, and have some possible mitigation.

Here are some resources to help get these docs started:

Add tutorial series for ink! 4

ink! 4 is one the upcoming stable releases with backward compatibility and LTS.

With growing community of developers and organised hackathons, tutorial series can provide a better onboarding experience in addition to the documentation.

The idea

  • Pre-recorded video tutorials
  • 30m length max per video
  • The format is "from zero to hero"
  • Building a dApp using ink! and relevant frontend tooling
  • Transcript and code snippets available on the tutorial page in addition to the video
  • A repo of the project with branches for corresponding tutorials

Maybe @sacha-l can help with the recording and @al3mart help with the Spanish translation of the transcript

Prettify Faucet form

Follow-up to #145.

Now

screenshot-use ink-2023 02 09-13_02_34 (1)

Should be

Get-Testnet-Tokens

Illustrator + SVG files here.

The font in there should be Montserrat, I think this file still contains the bare text annotated with a font, the svg (or png) on the website should have Montserrat (if svg then as path, and not as text).

Contracts-node v0.12 installation with cargo has compilation error on nightly 2022-07-20

In getting-started/setup:

https://github.com/paritytech/ink-docs/blob/9441b53e8bd0baae19b39ecf90f7f9dddeb25594/docs/getting-started/setup.md?plain=1#L65

Gives compilation errors when using nightly 2022-07-20:

$  cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --tag v0.12.0 --force --locked
    Updating git repository `https://github.com/paritytech/substrate-contracts-node.git`
  Installing contracts-node v0.12.0 (https://github.com/paritytech/substrate-contracts-node.git?tag=v0.12.0#7cd3c5e2)
    Updating crates.io index
   Compiling libc v0.2.121
   
... (some compiling later)

   Compiling pallet-transaction-payment-rpc v4.0.0-dev (https://github.com/paritytech/substrate#3cad018b)
The following warnings were emitted during compilation:

warning: Could not find `Cargo.lock` for `/Users/lucasvanmol/.cargo/git/checkouts/substrate-contracts-node-cf7c16677784d274/7cd3c5e/runtime/Cargo.toml`, while searching from `/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W/release/build/contracts-node-runtime-238b369d8fd463ef/out`. To fix this, point the `WASM_BUILD_WORKSPACE_HINT` env variable to the directory of the workspace being compiled.
warning: Could not find `Cargo.lock` for `/Users/lucasvanmol/.cargo/git/checkouts/substrate-contracts-node-cf7c16677784d274/7cd3c5e/runtime/Cargo.toml`, while searching from `/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W/release/build/contracts-node-runtime-238b369d8fd463ef/out`. To fix this, point the `WASM_BUILD_WORKSPACE_HINT` env variable to the directory of the workspace being compiled.

error: failed to run custom build command for `contracts-node-runtime v0.12.0 (/Users/lucasvanmol/.cargo/git/checkouts/substrate-contracts-node-cf7c16677784d274/7cd3c5e/runtime)`

Caused by:
  process didn't exit successfully: `/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W/release/build/contracts-node-runtime-da5507166d315b2d/build-script-build` (exit status: 1)
  --- stdout
  cargo:warning=Could not find `Cargo.lock` for `/Users/lucasvanmol/.cargo/git/checkouts/substrate-contracts-node-cf7c16677784d274/7cd3c5e/runtime/Cargo.toml`, while searching from `/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W/release/build/contracts-node-runtime-238b369d8fd463ef/out`. To fix this, point the `WASM_BUILD_WORKSPACE_HINT` env variable to the directory of the workspace being compiled.
  cargo:warning=Could not find `Cargo.lock` for `/Users/lucasvanmol/.cargo/git/checkouts/substrate-contracts-node-cf7c16677784d274/7cd3c5e/runtime/Cargo.toml`, while searching from `/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W/release/build/contracts-node-runtime-238b369d8fd463ef/out`. To fix this, point the `WASM_BUILD_WORKSPACE_HINT` env variable to the directory of the workspace being compiled.
  Information that should be included in a bug report.
  Executing build command: "rustup" "run" "nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W/release/wbuild/contracts-node-runtime/Cargo.toml" "--color=always" "--profile" "release"
  Using rustc version: rustc 1.64.0-nightly (d68e7ebc3 2022-07-20)


  --- stderr
      Updating crates.io index
      Updating git repository `https://github.com/paritytech/substrate`
     Compiling proc-macro2 v1.0.40

... (some compiling later)

     Compiling contracts-node-runtime v0.12.0 (/Users/lucasvanmol/.cargo/git/checkouts/substrate-contracts-node-cf7c16677784d274/7cd3c5e/runtime)
  error[E0437]: type `TransactionByteFee` is not a member of trait `pallet_transaction_payment::Config`

... (and some more compilation errors)

     error: could not compile `contracts-node-runtime` due to 7 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `contracts-node v0.12.0 (https://github.com/paritytech/substrate-contracts-node.git?tag=v0.12.0#7cd3c5e2)`, intermediate artifacts can be found at `/var/folders/8t/pz12r_6j2l3bvlmwvx5nl8k80000gn/T/cargo-installj40w4W`

Reccomend upgrade to --tag v0.17.0, which works as normal

Migration Guide from ink! 3.0 to 4.0

There are a few breaking changes between ink! 3.0 and 4.0. We should write a small guide
about what some of these changes are to make the transition easier for developers.

Non-exhaustive list of things to cover:

  • Removal of storage traits (SpreadLayout et.al)
  • New storage macros
  • CallBuilder/CreateBuilder changes
  • ABI changes (version, lang_error, etc.)
  • Results from Constructors

Add full-text search plugin

We want to have a full-text search in our docusaurus instance. The easiest way to set this up would be to use a third-party service, which regularly indexes registered pages. Since we ideally don't want to have any third-party components a local setup is preferable.

These are two local-search plugins which look promising:

There are probably more though.

We should decide on a plugin and include it into our setup.

Add section "How to verify a source code is behind a contract on-chain?"

We should document the results of use-ink/cargo-contract#696.

The documentation should contain the user perspective of (1) ink! contract developer (2) block explorer.

The info should be along the lines of what @HCastano posted in Element:

To verify the on-chain artifact you need two verification steps. First see if the given code matches the given contract bundle, and then check if the on-chain source matches the given contract bundle. That was you know that the given code matches what's on-chain

The contract you want to verify must have been previously built in a well-known environment, otherwise you may not be able to verify it's validity after the fact

So contain broader context around just executing the verify command.

Adapt docs to hidden `lazy` and `collections`

In use-ink/ink#1111 the collection and lazy module were hidden.

One effect is that the CI of ink-docs is currently broken due to a number of dead links detected:

https://github.com/paritytech/ink-docs/runs/5104398596?check_suite_focus=true (search for Status: 404).

The effect is that no changes committed to this repo will be published to GitHub pages currently (so the version tag in the substrate-contracts-version installation instructions is still the old one, even though I've pushed a commit which updates it).

The ink-docs still contain a lot of mentions of e.g. Lazy:

$ rg Lazy
docs/datastructures/spread-packed.md
32:    b: ink_storage::Lazy<i32>,
52:    b: ink_storage::Lazy<i32>,
69:    b: ink_storage::Lazy<i32>,
96:    b: ink_storage::Lazy<i32>,

docs/datastructures/opting-out.md
14:    b: ink_storage::Lazy<i32>,

docs/datastructures/overview.md
31:The `ink_storage::Lazy` type caches their entities and acts lazily on the storage.
60:In order to prevent this eager loading of storage contents we can make use of `ink_storage::Lazy` or other lazy data structures defined in that crate:
65:    a: ink_storage::Lazy<i32>,
66:    b: ink_storage::Lazy<i32>,
73:            true  => Lazy::set(&self.a, self.offset + new_value),
74:            false => Lazy::set(&self.b, self.offset + new_value),
80:Note that `offset` remained `i32` since it is always needed and could spare the minor overhead of the `ink_storage::Lazy` wrapper.

docs/faq/faq.md
208:### When to use `Lazy<T>` over just `T` for a contract field?
210:The `ink_storage::Lazy` type caches their entities and acts lazily on the storage.

docs/basics/cross-contract-calling.md
23:use ink_storage::Lazy;
30:    other_contract: Lazy<OtherContract>,

docs/basics/mutating-values.md
30:## Lazy Storage Values
32:There is [a `Lazy` type](https://paritytech.github.io/ink/ink_storage/struct.Lazy.html) that can be
34:examples do not require the use of `Lazy` values. Since there is
35:some overhead associated with `Lazy` values, they should only be used where required.
37:This is an example of using the `Lazy` type:
43:    my_number: ink_storage::Lazy<u32>,
50:            my_number: ink_storage::Lazy::<u32>::new(init_value),
56:        ink_storage::Lazy::<u32>::set(&mut self.my_number, new_value);
62:        let cur = ink_storage::Lazy::<u32>::get(my_number);
63:        ink_storage::Lazy::<u32>::set(my_number, cur + add_value);

For collections it will probably be similar.

Document dynamic memory allocator trade-offs

After use-ink/ink#831 is merged there will be two choices for dynamic memory allocators in ink!. The default is the new bump allocator while the other choice is wee_alloc (which used to be the old default).

The fundamental tradeoff here is .wasm size vs. efficient use of memory.

For someone concerned with running smart contracts on a parachain, size would be the most important consideration. However, if someone is running a standalone chain then memory efficiency might be more important.

The guide should explain:

  • The role of a dynamic memory allocator
  • The different allocators available
  • The trade-offs between the allocators
  • How to switch between allocators

Add FAQ on design choices metadata vs. binary

Follow-up to a chat in dm's:

…discussion on why we do not write the compiler name down in the WASM blob, why providing mappings between the metadata and the binary is not a problem we want to solve directly in the lang etc.. 😁 maybe this is something for the FAQ

IIRC you also wanted to add a point about "Why is the metadata not on-chain?".

Add migration guide from CosmWasm

Add a new section "Migration Guides" with a chapter CosmWasm.

The chapter should contain a short comparison of ink! and CosmWasm, as well as a guide on how to migrate a CosmWasm smart contract over to ink!.

Deprecated string Selector instructions shown in docs

This page (among others) shows deprecated instructions for specifying a Selector.

When trying to create a Selector with the following syntax selector = "0xDEADBEEF" on cargo contracts 0.15, the error received is: #[ink(selector = ..)] attributes with string inputs are deprecated. use an integer instead, e.g. #[ink(selector = 1)] or #[ink(selector = 0xC0DECAFE). The docs should probably make mention of the deprecation and offer an up-to-date suggestion.

Document how governance/`sudo` can overwrite a contract

The pallet-contracts contains functionality that enables sudo/governance to force-overwrite the contract code of a particular AccountId.

There will eventually be some mishap with a contract on some chain and we introduced a way to force-replace a contract with paritytech/substrate#11451.

We should add an FAQ point "How to ask sudo/governance to force-replace my contract?" that explains how to do this. Ideally with screenshots.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.