This is a simple bytes in, bytes out contract that shows a minimal entrypoint
function (denoted by the #[entrypoint]
proc macro). If your smart contract just has one primary function, like computing a cryptographic hash, this can be a great model because it strips out the SDK and acts like a pure function or Unix-style app.
1#![no_main]
2#![no_std]
3extern crate alloc;
4
5#[global_allocator]
6static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
7use alloc::vec::Vec;
8
9use stylus_sdk::stylus_proc::entrypoint;
10
11#[entrypoint]
12fn user_main(input: Vec<u8>) -> Result<Vec<u8>, Vec<u8>> {
13 Ok(input)
14}
1#![no_main]
2#![no_std]
3extern crate alloc;
4
5#[global_allocator]
6static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
7use alloc::vec::Vec;
8
9use stylus_sdk::stylus_proc::entrypoint;
10
11#[entrypoint]
12fn user_main(input: Vec<u8>) -> Result<Vec<u8>, Vec<u8>> {
13 Ok(input)
14}
1[package]
2name = "bytes_in_bytes_out"
3version = "0.1.0"
4edition = "2021"
5
6[dependencies]
7stylus-sdk = "0.4.2"
8wee_alloc = "0.4.5"
9
10[features]
11export-abi = ["stylus-sdk/export-abi"]
12
13[profile.release]
14codegen-units = 1
15strip = true
16lto = true
17panic = "abort"
18opt-level = "s"
19
20[workspace]
1[package]
2name = "bytes_in_bytes_out"
3version = "0.1.0"
4edition = "2021"
5
6[dependencies]
7stylus-sdk = "0.4.2"
8wee_alloc = "0.4.5"
9
10[features]
11export-abi = ["stylus-sdk/export-abi"]
12
13[profile.release]
14codegen-units = 1
15strip = true
16lto = true
17panic = "abort"
18opt-level = "s"
19
20[workspace]