Skip to content

Commit

Permalink
Merge branch 'stylus' into add-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan authored Sep 1, 2023
2 parents 60f3c05 + f94e99f commit 95a1e21
Show file tree
Hide file tree
Showing 13 changed files with 1,232 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .clabot
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"contributors": "https://api.github.com/repos/OffchainLabs/clabot-config/contents/nitro-contributors.json",
"message": "We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please sign the linked documents below to get yourself added. https://na3.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=b15c81cc-b5ea-42a6-9107-3992526f2898&env=na3&acct=6e152afc-6284-44af-a4c1-d8ef291db402&v=2",
"label": "s"
}
24 changes: 21 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["stylus-sdk", "stylus-proc"]
resolver = "2"

[workspace.package]
version = "0.1.0"
version = "0.1.2"
edition = "2021"
authors = ["Offchain Labs"]
license = "MIT OR Apache-2.0"
Expand Down
69 changes: 62 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,67 @@
<br />
<p align="center">
<a href="https://arbitrum.io/">
<img src="https://thereisatoken.com/media/stylus-logo.svg" alt="Logo" width="100%" height="80">
<img src="https://arbitrum.io/assets/stylus/stylus_with_paint_bg.png" alt="Logo" width="100%">
</a>

<h3 align="center">The Stylus SDK</h3>

<p align="center">
<a href="https://developer.arbitrum.io/"><strong>Rust programs on Arbitrum »</strong></a>
<a href="https://developer.arbitrum.io/"><strong>Rust contracts on Arbitrum »</strong></a>
<br />
</p>
</p>

## Overview
TODO...

## Feature highlight
TODO...
The Stylus SDK enables smart contract developers to write programs for **Arbitrum chains** written in the [Rust](https://www.rust-lang.org/tools/install) programming language. Stylus programs are compiled to [WebAssembly](https://webassembly.org/) and can then be deployed on-chain to execute alongside Solidity smart contracts. Stylus programs are not only orders of magnitude cheaper and faster but also enable what was thought to be previously impossible for WebAssembly: **EVM-interoperability**.

## Roadmap
TODO...
For information about deploying Rust smart contracts, see the [Cargo Stylus CLI Tool](CargoStylus). For more information about Stylus, see [Stylus: A Gentle Introduction](https://docs.arbitrum.io/stylus/stylus-gentle-introduction). For a simpler intro to Stylus Rust development, see the [Quick Start guide](https://docs.arbitrum.io/stylus/stylus-quickstart).

Comprehensive documentation on the Rust SDK can be found [here](https://docs.arbitrum.io/stylus/rust-sdk-guide).

## Feature highlights

The SDK makes it easy to develop Ethereum ABI-equivalent Stylus contracts in Rust. It provides a full suite of types and shortcuts that abstract away the details of Ethereum's storage layout, making it easy to _just write Rust_. For an in depth exploration of the features, please see comprehensive [Feature Overview][overview].

Some of the features available in the SDK include:

- **Generic**, storage-backed Rust types for programming **Ethereum-equivalent** smart contracts
- Simple macros for writing Solidity structs and **entrypoints** that get converted to SDK-types internally
- Powerful **primitive types** backed by the feature-rich [alloy-rs/crate](https://github.com/alloy-rs/core)

Rust programs implemented with the Stylus SDK can **call and be called** by Solidity smart contracts through Ethereum ABIs and also share the same storage layout.

```rust
use stylus_sdk::{alloy_primitives::U256, prelude::*};

// Generate Solidity-equivalent, Rust structs backed by storage.
sol_storage! {
#[entrypoint]
pub struct Counter {
uint256 number;
}
}

#[external]
impl Counter {
// Gets the number value from storage.
pub fn number(&self) -> Result<U256, Vec<u8>> {
Ok(self.number.get())
}
// Sets a number in storage to a user-specified value.
pub fn set_number(&mut self, new_number: U256) -> Result<(), Vec<u8>> {
self.number.set(new_number);
Ok(())
}
}
```

Additionally, the Stylus SDK supports `#[no_std]` for contracts that wish to opt out of the standard library. In fact, the entire SDK is available from `#[no_std]`, so no special feature flag is required. This can be helpful for reducing binary size, and may be preferable in pure-compute use cases like cryptography.

Most users will want to use the standard library, which is available since the Stylus VM supports `rustc`'s `wasm32-unknown-unknown` target triple. In the future we may add `wasm32-wasi` too, along with floating point and SIMD, which the Stylus VM does not yet support.

[overview]: https://docs.arbitrum.io/stylus/reference/rust-sdk-guide

## Don't know Rust?

Expand All @@ -30,6 +72,7 @@ The Stylus VM supports more than just Rust. In fact, any programming language th
| [Rust SDK][Rust] | Everything! | Apache 2.0 or MIT |
| [C/C++ SDK][C] | Cryptography and algorithms | Apache 2.0 or MIT |
| [Bf SDK][Bf] | Educational | Apache 2.0 or MIT |
| [Cargo Stylus][CargoStylus] | Deploying Stylus programs | Apache 2.0 or MIT |

Want to write your own? [Join us in the `#stylus` channel on discord][discord]!

Expand All @@ -39,6 +82,18 @@ Want to write your own? [Join us in the `#stylus` channel on discord][discord]!

[discord]: https://discord.com/invite/5KE54JwyTs

## Developing Stylus Programs

The Stylus SDK is just one of the building blocks in creating and deploying WebAssembly programs to Arbitrum chains. To create a new Stylus project from a hello-world example and deploy it onchain, check out some of our tools below:

| Repo | Use cases | License |
|:-----------------|:----------------------------|:------------------|
| [Stylus Hello World][HelloWorld] | Rust Stylus starter template | Apache 2.0 or MIT |
| [Cargo Stylus CLI][CargoStylus] | Deploying Stylus programs | Apache 2.0 or MIT |

[HelloWorld]: https://github.com/OffchainLabs/stylus-hello-world
[CargoStylus]: https://github.com/OffchainLabs/cargo-stylus

## License

&copy; 2022-2023 Offchain Labs, Inc.
Expand Down
7 changes: 7 additions & 0 deletions examples/erc20/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build]
target = "wasm32-unknown-unknown"

[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-arg=-zstack-size=32768",
]
Loading

0 comments on commit 95a1e21

Please sign in to comment.