Hello World
Using the console! macro from the stylus_sdk allows you to print output to the terminal for debugging purposes. To view the output, you'll need to run a local Stylus dev node as described in the Arbitrum docs and set the debug feature flag as shown in line 7 of the Cargo.toml file below.
The console! macro works similar to the built-in println! macro that comes with Rust.
Examples
note
This code has yet to be audited. Please use at your own risk.
// Out: Stylus says: 'hello there!'
console!("hello there!");
// Out: Stylus says: 'format some arguments'
console!("format {} arguments", "some");
let local_variable = "Stylus";
// Out: Stylus says: 'Stylus is awesome!'
console!("{local_variable} is awesome!");
// Out: Stylus says: 'When will you try out Stylus?'
console!("When will you try out {}?", local_variable);