diff --git a/src/pages/core.mdx b/src/pages/core.mdx index 706b353f..f64537c7 100644 --- a/src/pages/core.mdx +++ b/src/pages/core.mdx @@ -6,18 +6,17 @@ import { Callout } from "nextra/components"; # Introduction -This chapter will give you an overview over CosmWasm from a contract developer perspective, its +This chapter will give you an overview of CosmWasm from a contract developer perspective, its capabilities, and guide you through initializing your first smart contract. We assume you have basic knowledge of Rust and Cargo (its standard build system) ## What is CosmWasm? -CosmWasm is a platform for writing smart contracts for Cosmos chains using Rust and WebAssembly. -Meaning CosmWasm is your one-stop shop for developing, testing, and running smart contracts on -enabled chains. +CosmWasm is a platform for writing smart contracts for Cosmos chains using Rust and WebAssembly. It +is your one-stop shop for developing, testing, and running smart contracts on enabled chains. -## What does CosmWasm provide? +## What does CosmWasm Core provide? For you, a contract developer, CosmWasm provides a set of high-quality primitives through our standard library. These primitives include: @@ -26,7 +25,7 @@ standard library. These primitives include: - cryptographic primitives (for example, secp256k1 verification) - interaction with the Cosmos SDK -## What does CosmWasm _not_ provide? +## What does CosmWasm Core _not_ provide? - Abstractions to simplify contract development (for this, check out [Sylvia](/sylvia)) - Storage abstractions (for this, check out [Storey](/storey)) diff --git a/src/pages/core/architecture/pinning.mdx b/src/pages/core/architecture/pinning.mdx index 7fd571c4..a1d7df38 100644 --- a/src/pages/core/architecture/pinning.mdx +++ b/src/pages/core/architecture/pinning.mdx @@ -6,6 +6,11 @@ import { Callout } from "nextra/components"; # Contract pinning + + This is done by chain maintainers and not by contract developers. It's not something you need to + worry about when writing contracts but can be a fun thing to know. + + Contract pinning is a feature of the CosmWasm virtual machine which ensures that a previously stored compiled contract code (module) is started from a dedicated in-memory cache. Starting a module from memory takes ~45µs compared to 1.5ms when loaded from disk (33x faster). diff --git a/src/pages/core/entrypoints.mdx b/src/pages/core/entrypoints.mdx index d986be9e..4d4ec736 100644 --- a/src/pages/core/entrypoints.mdx +++ b/src/pages/core/entrypoints.mdx @@ -8,8 +8,8 @@ import { Callout } from "nextra/components"; Entrypoints are where your contract can be called from the outside world. You can equate that to your `main` function in C, Rust, Java, etc. -However, there is one _small_ difference: In CosmWasm, you have multiple of these entrypoints, each -one different from the last. +However, there is one _small_ difference: In CosmWasm, you have multiple entrypoints, each one +different from the last. In this section we want to give you a quick overview over all the entrypoints and when they are called. @@ -69,7 +69,7 @@ your own types. ### Predefined types -#### `Deps`/`DepsMut` +#### [`Deps`]/[`DepsMut`] These structs provide you access to the: @@ -81,7 +81,7 @@ The big difference is that `DepsMut` gives you _mutable_ access to the storage. deliberate since you, for example, can't mutate the state in the `query` endpoint. Instead of relying on runtime errors, this is made _irrepresentable_ through Rust's type system. -#### `Env` +#### [`Env`] This struct provides you with some information of the current state of the environment your contract is executed in. @@ -89,7 +89,7 @@ is executed in. The information provided is, for example, the block height, chain ID, transaction info, etc. Basically anything you'd ever want to know about the current state of the execution environment! -#### `MessageInfo` +#### [`MessageInfo`] This struct isn't provided to every endpoint, only to a select few. @@ -114,7 +114,8 @@ struct CustomInstantiateMsg { This macro actually just expands into a bunch of `derive` attributes. - We provide this simply for your convenience, otherwise you'd have to keep track of all of these derives yourself. + We provide this simply for your convenience, otherwise you'd have to keep track of all of these derives + yourself if you want the full suite of conveniences `cosmwasm-std` has to offer.
Without `#[cw_serde]` @@ -136,3 +137,8 @@ struct CustomInstantiateMsg {
+ +[`Deps`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Deps.html +[`DepsMut`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.DepsMut.html +[`Env`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Env.html` +[`MessageInfo`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.MessageInfo.html diff --git a/src/pages/core/entrypoints/instantiate.mdx b/src/pages/core/entrypoints/instantiate.mdx index df8382c9..a494266b 100644 --- a/src/pages/core/entrypoints/instantiate.mdx +++ b/src/pages/core/entrypoints/instantiate.mdx @@ -17,11 +17,10 @@ You can imagine it as the constructor of your contract. Note that this function is called for *each instance* of your contract that you decide to create, not one time ever. - To equate it to OOP, your contract is a *class*, and this is the *constructor*, - and you can have *multiple instances* of the same class, and the constructor - is called once for every one of these instances. + Your contract is the *constructor*, and you can have *multiple instances* of the same contract. + Each time an instance is createDefineEnv, the constructor is called. - It is **not** a singleton. + Contracts are **not** singletons. diff --git a/src/pages/core/installation.mdx b/src/pages/core/installation.mdx index 42422315..a950e1ed 100644 --- a/src/pages/core/installation.mdx +++ b/src/pages/core/installation.mdx @@ -9,7 +9,7 @@ import { Callout } from "nextra/components"; ## Setting up the environment Before diving right into writing code, you need to install some tooling in order to compile your -contract. CosmWasm is luckily rather self-contained and therefore needs little external tooling to +contract. CosmWasm is rather self-contained and therefore needs little external tooling to compile. Our only external dependency is Rust, which you need to install for your platform.