Skip to content

Commit b4ad718

Browse files
authored
Merge pull request #3406 from OffchainLabs/update-stylus-admonitions-fences
Apply formatting conventions to Stylus docs
2 parents fcd3d35 + 4d61f6e commit b4ad718

5 files changed

Lines changed: 61 additions & 33 deletions

File tree

docs/stylus/advanced/hostio-exports.mdx

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ Hostio functions are the foundational layer that powers all Stylus smart contrac
1919
- Understanding gas costs and execution flow
2020
- Debugging and troubleshooting contract behavior
2121

22-
:::info
22+
<VanillaAdmonition type="info">
23+
2324
Most developers should use the high-level SDK wrappers instead of calling hostio functions directly. The SDK provides safe, ergonomic interfaces that handle memory management and error checking automatically.
24-
:::
25+
26+
</VanillaAdmonition>
2527

2628
## How hostio works
2729

@@ -103,9 +105,11 @@ Gets the code hash of an account. Equivalent to EVM's `EXTCODEHASH` opcode.
103105
pub fn account_codehash(address: *const u8, dest: *mut u8);
104106
```
105107

106-
:::note
108+
<VanillaAdmonition type="note">
109+
107110
Empty accounts return the keccak256 hash of empty bytes: `c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`
108-
:::
111+
112+
</VanillaAdmonition>
109113

110114
### Storage operations
111115

@@ -132,9 +136,11 @@ Writes a 32-byte value to the storage cache. Equivalent to EVM's `SSTORE` opcode
132136
pub fn storage_cache_bytes32(key: *const u8, value: *const u8);
133137
```
134138

135-
:::warning
139+
<VanillaAdmonition type="warning">
140+
136141
Values are cached and must be persisted using `storage_flush_cache` before they're permanently written to storage.
137-
:::
142+
143+
</VanillaAdmonition>
138144

139145
#### `storage_flush_cache`
140146

@@ -200,9 +206,11 @@ Gets a bounded estimate of the L1 block number when the transaction was sequence
200206
pub fn block_number() -> u64;
201207
```
202208

203-
:::info
209+
<VanillaAdmonition type="info">
210+
204211
See [Arbitrum block numbers and time](/arbitrum-essentials/arbitrum-vs-ethereum/block-numbers-and-time) for more information on how block numbers work on Arbitrum chains.
205-
:::
212+
213+
</VanillaAdmonition>
206214

207215
#### `block_timestamp`
208216

@@ -228,9 +236,11 @@ pub fn msg_sender(sender: *mut u8);
228236

229237
- `sender`: Pointer to write the 20-byte address
230238

231-
:::note
239+
<VanillaAdmonition type="note">
240+
232241
For L1-to-L2 retryable ticket transactions, addresses are aliased. See [address aliasing documentation](/how-arbitrum-works/deep-dives/l1-to-l2-messaging#address-aliasing).
233-
:::
242+
243+
</VanillaAdmonition>
234244

235245
#### `msg_value`
236246

@@ -334,9 +344,11 @@ pub fn delegate_call_contract(
334344
) -> u8;
335345
```
336346

337-
:::warning
347+
<VanillaAdmonition type="warning">
348+
338349
Delegate calls execute code in the context of the current contract. Be extremely careful when delegate calling to untrusted contracts, as they have full access to your storage.
339-
:::
350+
351+
</VanillaAdmonition>
340352

341353
#### `static_call_contract`
342354

@@ -427,9 +439,11 @@ pub fn emit_log(data: *const u8, len: usize, topics: usize);
427439
- `len`: Total length of data, including topics
428440
- `topics`: Number of topics (0-4)
429441

430-
:::warning
442+
<VanillaAdmonition type="warning">
443+
431444
Requesting more than 4 topics will cause a revert.
432-
:::
445+
446+
</VanillaAdmonition>
433447

434448
**Higher-level usage:**
435449

@@ -466,9 +480,11 @@ Gets the amount of ink remaining—a Stylus-specific metering unit.
466480
pub fn evm_ink_left() -> u64;
467481
```
468482

469-
:::info
483+
<VanillaAdmonition type="info">
484+
470485
Ink is Stylus's compute pricing unit. See [Ink and Gas](https://docs.arbitrum.io/stylus/concepts/gas-metering) for conversion between ink and gas.
471-
:::
486+
487+
</VanillaAdmonition>
472488

473489
#### `pay_for_memory_grow`
474490

@@ -478,9 +494,11 @@ Pays for WASM memory growth. Automatically called when allocating new pages.
478494
pub fn pay_for_memory_grow(pages: u16);
479495
```
480496

481-
:::note
497+
<VanillaAdmonition type="note">
498+
482499
The `entrypoint!` macro handles importing this hostio. Manual calls will unproductively consume gas.
483-
:::
500+
501+
</VanillaAdmonition>
484502

485503
### Cryptography
486504

@@ -520,9 +538,11 @@ Reads the program calldata. Equivalent to EVM's `CALLDATACOPY` opcode.
520538
pub fn read_args(dest: *mut u8);
521539
```
522540

523-
:::note
541+
<VanillaAdmonition type="note">
542+
524543
This reads all of the calldata of the call.
525-
:::
544+
545+
</VanillaAdmonition>
526546

527547
#### `read_return_data`
528548

docs/stylus/cli-tools/debugging-tx.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ The `replay` command allows you to debug transaction execution interactively:
196196
cargo stylus replay --tx=$TX_HASH --endpoint=$RPC_URL --use-native-tracer
197197
```
198198

199-
:::note
199+
<VanillaAdmonition type="note">
200+
200201
The `--use-native-tracer` flag uses `stylusTracer` instead of `jsTracer`, which is required for tracing Stylus transactions on most RPC providers. See [RPC endpoint compatibility](#rpc-endpoint-compatibility) for details.
201-
:::
202+
203+
</VanillaAdmonition>
202204

203205
The debugger loads and sets a breakpoint at the `user_entrypoint` function:
204206

docs/stylus/how-tos/caching-contracts.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ uint192 minBid = cacheManager.getMinBid(contractAddress);
5050

5151
Here, the [`contractAddress`] is the address of the Stylus contract you want to cache.
5252

53-
```bash
53+
```shell
5454
cargo stylus cache suggest-bid [contractAddress]
5555
```
5656

@@ -70,7 +70,7 @@ cacheManager.placeBid{value: bidAmount}(contractAddress);
7070

7171
You can place a bid using the `cargo stylus cache bid` command:
7272

73-
```bash
73+
```shell
7474
cargo stylus cache bid <--private-key-path <PRIVATE_KEY_PATH>|--private-key <PRIVATE_KEY>|--keystore-path <KEYSTORE_PATH>> [contractAddress] [bidAmount]
7575
```
7676

@@ -83,7 +83,7 @@ If you specify a bid amount using `cargo stylus`, it will automatically validate
8383

8484
To check if a specific address is cached, you can use the `cargo stylus status` command:
8585

86-
```bash
86+
```shell
8787
cargo stylus cache status --address=[contractAddress]
8888
```
8989

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
:::info
1+
<VanillaAdmonition type="info">
22

33
Stylus doesn't support contract multi-inheritance yet.
44

5-
:::
5+
</VanillaAdmonition>

docs/stylus/reference/stylus-toml-reference.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ crate-type = ["lib", "cdylib"]
9494
- `lib` enables standard Rust imports and testing.
9595
- `cdylib` produces the WebAssembly binary that gets deployed onchain.
9696

97-
:::caution
97+
<VanillaAdmonition type="warning">
98+
9899
Removing `cdylib` from `crate-type` prevents the contract from compiling to WASM. Removing `lib` prevents running tests and exporting ABI.
99-
:::
100+
101+
</VanillaAdmonition>
100102

101103
### `[dependencies]`
102104

@@ -169,9 +171,11 @@ opt-level = 3
169171
| `panic` | `abort` | Use immediate abort on panic instead of unwinding (smaller binary). |
170172
| `opt-level` | `3` | Optimize for speed. Use `"s"` or `"z"` to optimize for binary size instead. See [Optimizing binaries](/stylus/how-tos/optimizing-binaries) for guidance. |
171173

172-
:::tip
174+
<VanillaAdmonition type="tip">
175+
173176
If your contract exceeds the 24KB compressed size limit, change `opt-level` to `"z"` for maximum size reduction. This typically produces smaller binaries at the cost of some runtime performance.
174-
:::
177+
178+
</VanillaAdmonition>
175179

176180
## `rust-toolchain.toml`
177181

@@ -188,9 +192,11 @@ targets = ["wasm32-unknown-unknown"]
188192
| `channel` | Rust compiler version. Used by block explorers for deterministic source verification. |
189193
| `targets` | Must include `wasm32-unknown-unknown` for Stylus contracts. Additional targets can be listed for local testing. |
190194

191-
:::caution
195+
<VanillaAdmonition type="warning">
196+
192197
Changing the Rust version may affect source code verification on block explorers like Arbiscan. Pin to a specific stable version rather than using `stable` or `nightly`.
193-
:::
198+
199+
</VanillaAdmonition>
194200

195201
## Complete examples
196202

0 commit comments

Comments
 (0)