Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Changes from meeting today #40

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"position": 3,
"label": "Tutorials / Examples"
"label": "Examples"
}
2 changes: 1 addition & 1 deletion docs/examples/liquidity-pool.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
title: Liquidity Pool
---

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/single-offer-sale.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 4
title: Single Offer Sale
---

Expand Down
16 changes: 0 additions & 16 deletions docs/getting-started/build-a-wasm-file.mdx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
sidebar_position: 3
title: First Project
title: Quick Start
---

Once you've [Setup] your development environment, you're ready to create your
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/_category_.json → docs/learn/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"position": 5,
"label": "Guides"
"label": "Learn"
}
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/standard-contracts/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"position": 3,
"label": "Standard Contracts"
}
14 changes: 14 additions & 0 deletions docs/standard-contracts/token-contract.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
sidebar_position: 1
title: Token Contract
---

The token contract is an implementation of [CAP-54 Smart Contract Standardized Asset].

[CAP-54 Smart Contract Standardized Asset]: https://stellar.org/protocol/cap-54

:::caution
The token contract is in early development, has not been audited, and is not
intended for use. Report issues
[here](https://github.com/stellar/soroban-token-contract).
:::
4 changes: 4 additions & 0 deletions docs/tutorials/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"position": 2,
"label": "Tutorials"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
---
sidebar_position: 7
title: Run a WASM File
sidebar_position: 6
title: Build and Run
---

## Build a Contract

To build a Soroban contract into a `.wasm` file, use the `cargo build` command.

```sh
cargo build --target wasm32-unknown-unknown --release
```

A `.wasm` file should be outputted in the `target` directory:

```
target/wasm32-unknown-unknown/release/[project-name].wasm
```

## Run a Contract

If you have [`soroban-cli`] installed, you can invoke contract functions in a
WASM file.

Expand Down
74 changes: 74 additions & 0 deletions docs/tutorials/create-a-project.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
sidebar_position: 1
title: Create a Project
---

Once you've [Setup] your development environment, you're ready to create your
first Soroban contract.

[Setup]: setup.mdx

Start by creating a new Rust library using the `cargo new` command.

```sh
cargo new --lib [project-name]
```

Open the `Cargo.toml`, it should look something like this:

```toml title="Cargo.toml"
[package]
name = "first-project"
version = "0.1.0"
edition = "2021"
```

## Add `soroban-sdk` Dependency

Add the following sections to the `Cargo.toml` that will import the `soroban-sdk`.

:::caution
The `soroban-sdk` is in early development. Report issues
[here](https://github.com/stellar/rs-soroban-sdk).
:::

```toml
[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["export"]
export = []
testutils = ["soroban-sdk/testutils"]

[dependencies]
soroban-sdk = { git = "https://github.com/stellar/rs-soroban-sdk", rev = "32b76650" }

[dev_dependencies]
first-project = { path = ".", features = ["testutils"] }

[profile.release]
opt-level = "z"
overflow-checks = true
debug = 0
strip = "symbols"
debug-assertions = false
panic = "abort"
codegen-units = 1
lto = true
```

The `features` list and `dev_dependencies` configure three variations that the
contract can be built with:
- By `default`, with `export` enabled, contract functions will be exported and
available to be invoked when the contract is deployed.
- Optionally without `export` enabled, contract functions will not be exported.
Types will be still exposed, which is useful when developing multiple contracts
together and this contract is to be imported into another but its functions are
not intended to be invoked.
- And `testutils` which will cause additional test utilities to be generated for
calling the contract in tests. The library itself is added as a `dev_dependencies`
so that whenever its tests are running the `testutils` feature is enabled.

The config for the `release` profile configures the Rust toolchain to produce
smaller contracts.