diff --git a/example_code/applications/english_auction/Cargo.toml b/example_code/applications/english_auction/Cargo.toml index f1f8a3c9..5ca64041 100644 --- a/example_code/applications/english_auction/Cargo.toml +++ b/example_code/applications/english_auction/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/applications/english_auction/Cargo.toml.bak b/example_code/applications/english_auction/Cargo.toml.bak index f1f8a3c9..5ca64041 100644 --- a/example_code/applications/english_auction/Cargo.toml.bak +++ b/example_code/applications/english_auction/Cargo.toml.bak @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/applications/english_auction/src/lib.rs b/example_code/applications/english_auction/src/lib.rs index 702d50d1..8be1398d 100644 --- a/example_code/applications/english_auction/src/lib.rs +++ b/example_code/applications/english_auction/src/lib.rs @@ -160,7 +160,7 @@ impl EnglishAuction { // Set the end time of the auction to 7 days from now. self.end_at.set(U256::from(block::timestamp() + 7 * Self::ONE_DAY)); // Log the start event. - evm::log(Start {}); + stylus_core::log(self.vm(),Start {}); Ok(()) }, // If the transfer fails, return an error. @@ -204,7 +204,7 @@ impl EnglishAuction { self.highest_bid.set(msg::value()); // Update the bid of the current bidder. - evm::log(Bid { + stylus_core::log(self.vm(),Bid { sender: msg::sender(), amount: msg::value(), }); @@ -221,7 +221,7 @@ impl EnglishAuction { let _ = transfer_eth(msg::sender(), bal); // Log the withdraw event. - evm::log(Withdraw { + stylus_core::log(self.vm(),Withdraw { bidder: msg::sender(), amount: bal, }); @@ -271,7 +271,7 @@ impl EnglishAuction { } // Log the end event. - evm::log(End { + stylus_core::log(self.vm(),End { winner: highest_bidder, amount: highest_bid, }); diff --git a/example_code/applications/erc20/Cargo.toml b/example_code/applications/erc20/Cargo.toml index 961d4eda..f4630de4 100644 --- a/example_code/applications/erc20/Cargo.toml +++ b/example_code/applications/erc20/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/applications/erc20/src/erc20.rs b/example_code/applications/erc20/src/erc20.rs index 9959a0ee..79cf284e 100644 --- a/example_code/applications/erc20/src/erc20.rs +++ b/example_code/applications/erc20/src/erc20.rs @@ -90,7 +90,7 @@ impl Erc20 { to_balance.set(new_to_balance); // Emitting the transfer event - evm::log(Transfer { from, to, value }); + stylus_core::log(self.vm(),Transfer { from, to, value }); Ok(()) } @@ -105,7 +105,7 @@ impl Erc20 { self.total_supply.set(self.total_supply.get() + value); // Emitting the transfer event - evm::log(Transfer { + stylus_core::log(self.vm(),Transfer { from: Address::ZERO, to: address, value, @@ -132,7 +132,7 @@ impl Erc20 { self.total_supply.set(self.total_supply.get() - value); // Emitting the transfer event - evm::log(Transfer { + stylus_core::log(self.vm(),Transfer { from: address, to: Address::ZERO, value, @@ -210,7 +210,7 @@ impl Erc20 { /// Approves the spenditure of `value` tokens of msg::sender() to `spender` pub fn approve(&mut self, spender: Address, value: U256) -> bool { self.allowances.setter(msg::sender()).insert(spender, value); - evm::log(Approval { + stylus_core::log(self.vm(),Approval { owner: msg::sender(), spender, value, diff --git a/example_code/applications/erc721/Cargo.toml b/example_code/applications/erc721/Cargo.toml index 0f23ae81..f7f725ce 100644 --- a/example_code/applications/erc721/Cargo.toml +++ b/example_code/applications/erc721/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/applications/erc721/src/erc721.rs b/example_code/applications/erc721/src/erc721.rs index 856df0ca..7b9ef63f 100644 --- a/example_code/applications/erc721/src/erc721.rs +++ b/example_code/applications/erc721/src/erc721.rs @@ -152,7 +152,7 @@ impl Erc721 { // cleaning app the approved mapping for this token self.token_approvals.delete(token_id); - evm::log(Transfer { from, to, token_id }); + stylus_core::log(self.vm(),Transfer { from, to, token_id }); Ok(()) } @@ -307,7 +307,7 @@ impl Erc721 { } self.token_approvals.insert(token_id, approved); - evm::log(Approval { + stylus_core::log(self.vm(),Approval { approved, owner, token_id, @@ -322,7 +322,7 @@ impl Erc721 { .setter(owner) .insert(operator, approved); - evm::log(ApprovalForAll { + stylus_core::log(self.vm(),ApprovalForAll { owner, operator, approved, diff --git a/example_code/applications/multi_call/Cargo.toml b/example_code/applications/multi_call/Cargo.toml index 7bf66324..b7ac3383 100644 --- a/example_code/applications/multi_call/Cargo.toml +++ b/example_code/applications/multi_call/Cargo.toml @@ -7,10 +7,10 @@ keywords = ["arbitrum", "ethereum", "stylus", "alloy"] description = "Stylus multi call example" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] @@ -33,4 +33,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/applications/multi_sig/Cargo.toml b/example_code/applications/multi_sig/Cargo.toml index 11217a45..35510491 100644 --- a/example_code/applications/multi_sig/Cargo.toml +++ b/example_code/applications/multi_sig/Cargo.toml @@ -4,10 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [features] @@ -21,4 +21,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/applications/multi_sig/src/lib.rs b/example_code/applications/multi_sig/src/lib.rs index 181a6b2d..1baba739 100644 --- a/example_code/applications/multi_sig/src/lib.rs +++ b/example_code/applications/multi_sig/src/lib.rs @@ -87,7 +87,7 @@ impl MultiSig { pub fn deposit(&mut self) { let sender = msg::sender(); let amount = msg::value(); - evm::log( + stylus_core::log(self.vm(), Deposit{ sender: sender, amount: amount, @@ -113,7 +113,7 @@ impl MultiSig { new_tx.num_confirmations.set(U256::from(0)); // Emit the `SubmitTransaction` event. - evm::log(SubmitTransaction { + stylus_core::log(self.vm(),SubmitTransaction { owner: msg::sender(), txIndex: tx_index, to: to, @@ -191,7 +191,7 @@ impl MultiSig { match call(Call::new_in(self).value(entry_value), entry_to, &entry_data) { // If the transaction is successful, emit the `ExecuteTransaction` event. Ok(_) => { - evm::log(ExecuteTransaction { + stylus_core::log(self.vm(),ExecuteTransaction { owner: msg::sender(), txIndex: U256::from(tx_index), }); @@ -239,7 +239,7 @@ impl MultiSig { confirmed_by_address.set(true); // Emit the `ConfirmTransaction` event. - evm::log(ConfirmTransaction { + stylus_core::log(self.vm(),ConfirmTransaction { owner: msg::sender(), txIndex: U256::from(tx_index), }); @@ -277,7 +277,7 @@ impl MultiSig { confirmed_by_address.set(false); // Emit the `RevokeConfirmation` event. - evm::log(RevokeConfirmation { + stylus_core::log(self.vm(),RevokeConfirmation { owner: msg::sender(), txIndex: U256::from(tx_index), }); diff --git a/example_code/applications/time_lock/Cargo.toml b/example_code/applications/time_lock/Cargo.toml index a2daaad7..919bf2d7 100644 --- a/example_code/applications/time_lock/Cargo.toml +++ b/example_code/applications/time_lock/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" alloy-primitives = "0.7.5" alloy-sol-types = "0.7.5" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" diff --git a/example_code/applications/time_lock/src/lib.rs b/example_code/applications/time_lock/src/lib.rs index 0167f47e..e55c8caf 100644 --- a/example_code/applications/time_lock/src/lib.rs +++ b/example_code/applications/time_lock/src/lib.rs @@ -161,7 +161,7 @@ impl TimeLock { let mut queue_id = self.queued.setter(tx_id); queue_id.set(true); // Log the Queue event - evm::log(Queue { + stylus_core::log(self.vm(),Queue { txId: tx_id.into(), target, value: value, @@ -227,7 +227,7 @@ impl TimeLock { match call(Call::new_in(self).value(value), target, &calldata) { // Log the transaction execution if successful Ok(_) => { - evm::log(Execute { + stylus_core::log(self.vm(),Execute { txId: tx_id.into(), target, value: value, @@ -269,7 +269,7 @@ impl TimeLock { queue_id.set(false); // Log the transaction cancellation - evm::log(Cancel { + stylus_core::log(self.vm(),Cancel { txId: tx_id.into(), }); diff --git a/example_code/applications/vending_machine/Cargo.toml b/example_code/applications/vending_machine/Cargo.toml index 06083ea1..eb3328f4 100644 --- a/example_code/applications/vending_machine/Cargo.toml +++ b/example_code/applications/vending_machine/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/abi_decode/Cargo.toml b/example_code/basic_examples/abi_decode/Cargo.toml index 0585243e..5a957a99 100644 --- a/example_code/basic_examples/abi_decode/Cargo.toml +++ b/example_code/basic_examples/abi_decode/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] @@ -28,4 +28,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/basic_examples/abi_encode/Cargo.toml b/example_code/basic_examples/abi_encode/Cargo.toml index 760c9aab..79051597 100644 --- a/example_code/basic_examples/abi_encode/Cargo.toml +++ b/example_code/basic_examples/abi_encode/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10" @@ -29,4 +29,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/basic_examples/arrays/Cargo.toml b/example_code/basic_examples/arrays/Cargo.toml index cdd4a9a2..add6d7f6 100644 --- a/example_code/basic_examples/arrays/Cargo.toml +++ b/example_code/basic_examples/arrays/Cargo.toml @@ -5,10 +5,10 @@ edition = "2021" description = "Stylus arrays example" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" dotenv = "0.15.0" diff --git a/example_code/basic_examples/call/Cargo.toml b/example_code/basic_examples/call/Cargo.toml index 792b0352..67319acf 100644 --- a/example_code/basic_examples/call/Cargo.toml +++ b/example_code/basic_examples/call/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" stylus-sdk = { version = "0.6.0", features = ["reentrant"] } hex = "0.4.3" diff --git a/example_code/basic_examples/constants/Cargo.toml b/example_code/basic_examples/constants/Cargo.toml index b12f5ebb..d8d89f7b 100644 --- a/example_code/basic_examples/constants/Cargo.toml +++ b/example_code/basic_examples/constants/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/delegate_call/Cargo.toml b/example_code/basic_examples/delegate_call/Cargo.toml index 8256b64f..446ab505 100644 --- a/example_code/basic_examples/delegate_call/Cargo.toml +++ b/example_code/basic_examples/delegate_call/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10" @@ -29,4 +29,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/basic_examples/encode_and_hashing/Cargo.toml b/example_code/basic_examples/encode_and_hashing/Cargo.toml index e3666552..c0b04221 100644 --- a/example_code/basic_examples/encode_and_hashing/Cargo.toml +++ b/example_code/basic_examples/encode_and_hashing/Cargo.toml @@ -4,10 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" @@ -23,4 +23,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/basic_examples/errors/Cargo.toml b/example_code/basic_examples/errors/Cargo.toml index 21a6e091..f67d2b4a 100644 --- a/example_code/basic_examples/errors/Cargo.toml +++ b/example_code/basic_examples/errors/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -stylus-sdk = "0.6.0" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/events/src/lib.rs b/example_code/basic_examples/events/src/lib.rs index 53734fab..79bb7f30 100644 --- a/example_code/basic_examples/events/src/lib.rs +++ b/example_code/basic_examples/events/src/lib.rs @@ -22,15 +22,18 @@ pub struct Events {} #[public] impl Events { - fn user_main(_input: Vec) -> ArbResult { + fn user_main(&self, _input: Vec) -> ArbResult { // emits a 'Log' event, defined above in the sol! macro - evm::log(Log { - sender: Address::from([0x11; 20]), - message: "Hello world!".to_string(), - }); + stylus_core::log( + self.vm(), + Log { + sender: Address::from([0x11; 20]), + message: "Hello world!".to_string(), + }, + ); // no data, but event will still log to the chain - evm::log(AnotherLog {}); + stylus_core::log(self.vm(), AnotherLog {}); // set up local variables let user = Address::from([0x22; 20]); diff --git a/example_code/basic_examples/first_app/Cargo.toml b/example_code/basic_examples/first_app/Cargo.toml index 48ae3681..3eb580a8 100644 --- a/example_code/basic_examples/first_app/Cargo.toml +++ b/example_code/basic_examples/first_app/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -stylus-sdk = "0.6.0" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/function/Cargo.toml b/example_code/basic_examples/function/Cargo.toml index 14be1a12..84b683c8 100644 --- a/example_code/basic_examples/function/Cargo.toml +++ b/example_code/basic_examples/function/Cargo.toml @@ -4,10 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" @@ -23,4 +23,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/basic_examples/hello_world/Cargo.toml b/example_code/basic_examples/hello_world/Cargo.toml index f98d2cb3..d699e70d 100644 --- a/example_code/basic_examples/hello_world/Cargo.toml +++ b/example_code/basic_examples/hello_world/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10" @@ -29,4 +29,4 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" \ No newline at end of file +opt-level = "s" diff --git a/example_code/basic_examples/mapping/Cargo.toml b/example_code/basic_examples/mapping/Cargo.toml index 475c8f06..d03997a1 100644 --- a/example_code/basic_examples/mapping/Cargo.toml +++ b/example_code/basic_examples/mapping/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -stylus-sdk = "0.6.0" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] @@ -19,4 +19,3 @@ export-abi = ["stylus-sdk/export-abi"] [lib] crate-type = ["lib", "cdylib"] - diff --git a/example_code/basic_examples/primitive_data_types/Cargo.toml b/example_code/basic_examples/primitive_data_types/Cargo.toml index f7e72532..bdb5596b 100644 --- a/example_code/basic_examples/primitive_data_types/Cargo.toml +++ b/example_code/basic_examples/primitive_data_types/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/sending_ether/Cargo.toml b/example_code/basic_examples/sending_ether/Cargo.toml index c81fa652..e5728f09 100644 --- a/example_code/basic_examples/sending_ether/Cargo.toml +++ b/example_code/basic_examples/sending_ether/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/storage_data_types/Cargo.toml b/example_code/basic_examples/storage_data_types/Cargo.toml index 0e622aa5..63ad5b02 100644 --- a/example_code/basic_examples/storage_data_types/Cargo.toml +++ b/example_code/basic_examples/storage_data_types/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/variables/Cargo.toml b/example_code/basic_examples/variables/Cargo.toml index 0e30e1b0..9e25097e 100644 --- a/example_code/basic_examples/variables/Cargo.toml +++ b/example_code/basic_examples/variables/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/example_code/basic_examples/verify_signature/Cargo.toml b/example_code/basic_examples/verify_signature/Cargo.toml index d168a910..1bcd3908 100644 --- a/example_code/basic_examples/verify_signature/Cargo.toml +++ b/example_code/basic_examples/verify_signature/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" diff --git a/src/app/applications/english_auction/page.mdx b/src/app/applications/english_auction/page.mdx index 96df08a5..1a5e66d3 100644 --- a/src/app/applications/english_auction/page.mdx +++ b/src/app/applications/english_auction/page.mdx @@ -1,6 +1,6 @@ export const metadata = { - title: 'English Auction • Stylus by Example', - description: 'An example implementation of the English Auction in Rust using Arbitrum Stylus.', + title: 'English Auction • Stylus by Example', + description: 'An example implementation of the English Auction in Rust using Arbitrum Stylus.', }; {/* Begin Content */} @@ -236,7 +236,7 @@ impl EnglishAuction { // Set the end time of the auction to 7 days from now. self.end_at.set(U256::from(block::timestamp() + 7 * Self::ONE_DAY)); // Log the start event. - evm::log(Start {}); + stylus_core::log(self.vm(),Start {}); Ok(()) }, // If the transfer fails, return an error. @@ -280,7 +280,7 @@ impl EnglishAuction { self.highest_bid.set(msg::value()); // Update the bid of the current bidder. - evm::log(Bid { + stylus_core::log(self.vm(),Bid { sender: msg::sender(), amount: msg::value(), }); @@ -297,7 +297,7 @@ impl EnglishAuction { let _ = transfer_eth(msg::sender(), bal); // Log the withdraw event. - evm::log(Withdraw { + stylus_core::log(self.vm(),Withdraw { bidder: msg::sender(), amount: bal, }); @@ -347,7 +347,7 @@ impl EnglishAuction { } // Log the end event. - evm::log(End { + stylus_core::log(self.vm(),End { winner: highest_bidder, amount: highest_bid, }); @@ -367,10 +367,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/applications/erc20/page.mdx b/src/app/applications/erc20/page.mdx index 86964692..48c907cd 100644 --- a/src/app/applications/erc20/page.mdx +++ b/src/app/applications/erc20/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'ERC-20 • Stylus by Example', - description: - 'An example implementation of the ERC-20 token standard in Rust using Arbitrum Stylus.', + title: 'ERC-20 • Stylus by Example', + description: + 'An example implementation of the ERC-20 token standard in Rust using Arbitrum Stylus.', }; {/* Begin Content */} @@ -132,7 +132,7 @@ impl Erc20 { to_balance.set(new_to_balance); // Emitting the transfer event - evm::log(Transfer { from, to, value }); + stylus_core::log(self.vm(),Transfer { from, to, value }); Ok(()) } @@ -147,7 +147,7 @@ impl Erc20 { self.total_supply.set(self.total_supply.get() + value); // Emitting the transfer event - evm::log(Transfer { + stylus_core::log(self.vm(),Transfer { from: Address::ZERO, to: address, value, @@ -174,7 +174,7 @@ impl Erc20 { self.total_supply.set(self.total_supply.get() - value); // Emitting the transfer event - evm::log(Transfer { + stylus_core::log(self.vm(),Transfer { from: address, to: Address::ZERO, value, @@ -252,7 +252,7 @@ impl Erc20 { /// Approves the spenditure of `value` tokens of msg::sender() to `spender` pub fn approve(&mut self, spender: Address, value: U256) -> bool { self.allowances.setter(msg::sender()).insert(spender, value); - evm::log(Approval { + stylus_core::log(self.vm(),Approval { owner: msg::sender(), spender, value, @@ -339,10 +339,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/applications/erc721/page.mdx b/src/app/applications/erc721/page.mdx index 2a0c1406..076e81a2 100644 --- a/src/app/applications/erc721/page.mdx +++ b/src/app/applications/erc721/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'ERC-721 • Stylus by Example', - description: - 'An example implementation of the ERC-721 token standard in Rust using Arbitrum Stylus.', + title: 'ERC-721 • Stylus by Example', + description: + 'An example implementation of the ERC-721 token standard in Rust using Arbitrum Stylus.', }; {/* Begin Content */} @@ -189,7 +189,7 @@ impl Erc721 { // cleaning app the approved mapping for this token self.token_approvals.delete(token_id); - evm::log(Transfer { from, to, token_id }); + stylus_core::log(self.vm(),Transfer { from, to, token_id }); Ok(()) } @@ -344,7 +344,7 @@ impl Erc721 { } self.token_approvals.insert(token_id, approved); - evm::log(Approval { + stylus_core::log(self.vm(),Approval { approved, owner, token_id, @@ -359,7 +359,7 @@ impl Erc721 { .setter(owner) .insert(operator, approved); - evm::log(ApprovalForAll { + stylus_core::log(self.vm(),ApprovalForAll { owner, operator, approved, @@ -475,10 +475,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/applications/multi_sig/page.mdx b/src/app/applications/multi_sig/page.mdx index 2a188a01..ae2745e5 100644 --- a/src/app/applications/multi_sig/page.mdx +++ b/src/app/applications/multi_sig/page.mdx @@ -1,6 +1,6 @@ export const metadata = { - title: 'MultiSig • Stylus by Example', - description: 'An example implementation of the MultiSig wallet in Rust using Arbitrum Stylus.', + title: 'MultiSig • Stylus by Example', + description: 'An example implementation of the MultiSig wallet in Rust using Arbitrum Stylus.', }; {/* Begin Content */} @@ -157,7 +157,7 @@ impl MultiSig { pub fn deposit(&mut self) { let sender = msg::sender(); let amount = msg::value(); - evm::log( + stylus_core::log(self.vm(), Deposit{ sender: sender, amount: amount, @@ -183,7 +183,7 @@ impl MultiSig { new_tx.num_confirmations.set(U256::from(0)); // Emit the `SubmitTransaction` event. - evm::log(SubmitTransaction { + stylus_core::log(self.vm(),SubmitTransaction { owner: msg::sender(), txIndex: tx_index, to: to, @@ -261,7 +261,7 @@ impl MultiSig { match call(Call::new_in(self).value(entry_value), entry_to, &entry_data) { // If the transaction is successful, emit the `ExecuteTransaction` event. Ok(_) => { - evm::log(ExecuteTransaction { + stylus_core::log(self.vm(),ExecuteTransaction { owner: msg::sender(), txIndex: U256::from(tx_index), }); @@ -309,7 +309,7 @@ impl MultiSig { confirmed_by_address.set(true); // Emit the `ConfirmTransaction` event. - evm::log(ConfirmTransaction { + stylus_core::log(self.vm(),ConfirmTransaction { owner: msg::sender(), txIndex: U256::from(tx_index), }); @@ -347,7 +347,7 @@ impl MultiSig { confirmed_by_address.set(false); // Emit the `RevokeConfirmation` event. - evm::log(RevokeConfirmation { + stylus_core::log(self.vm(),RevokeConfirmation { owner: msg::sender(), txIndex: U256::from(tx_index), }); @@ -378,10 +378,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [features] diff --git a/src/app/applications/time_lock/page.mdx b/src/app/applications/time_lock/page.mdx index f04f075f..bbe294a8 100644 --- a/src/app/applications/time_lock/page.mdx +++ b/src/app/applications/time_lock/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Time Lock • Stylus by Example", - description: - "An example implementation of the Timelock wallet in Rust using Arbitrum Stylus.", + title: "Time Lock • Stylus by Example", + description: + "An example implementation of the Timelock wallet in Rust using Arbitrum Stylus.", }; {/* Begin Content */} @@ -237,7 +237,7 @@ impl TimeLock { let mut queue_id = self.queued.setter(tx_id); queue_id.set(true); // Log the Queue event - evm::log(Queue { + stylus_core::log(self.vm(),Queue { txId: tx_id.into(), target, value: value, @@ -303,7 +303,7 @@ impl TimeLock { match call(Call::new_in(self).value(value), target, &calldata) { // Log the transaction execution if successful Ok(_) => { - evm::log(Execute { + stylus_core::log(self.vm(),Execute { txId: tx_id.into(), target, value: value, @@ -345,7 +345,7 @@ impl TimeLock { queue_id.set(false); // Log the transaction cancellation - evm::log(Cancel { + stylus_core::log(self.vm(),Cancel { txId: tx_id.into(), }); @@ -366,10 +366,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" diff --git a/src/app/applications/vending_machine/page.mdx b/src/app/applications/vending_machine/page.mdx index 7ecdaf1e..9cad0ea9 100644 --- a/src/app/applications/vending_machine/page.mdx +++ b/src/app/applications/vending_machine/page.mdx @@ -1,6 +1,6 @@ export const metadata = { - title: 'Vending Machine • Stylus by Example', - description: 'An example implementation of the Vending Machine in Rust using Arbitrum Stylus.', + title: 'Vending Machine • Stylus by Example', + description: 'An example implementation of the Vending Machine in Rust using Arbitrum Stylus.', }; {/* Begin Content */} @@ -115,10 +115,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/abi_decode/page.mdx b/src/app/basic_examples/abi_decode/page.mdx index 765407ab..ecc7383e 100644 --- a/src/app/basic_examples/abi_decode/page.mdx +++ b/src/app/basic_examples/abi_decode/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "ABI Encode • Stylus by Example", - description: - "A simple solidity ABI encode and decode example", + title: "ABI Encode • Stylus by Example", + description: + "A simple solidity ABI encode and decode example", }; {/* Begin Content */} @@ -113,8 +113,8 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" stylus-sdk = "0.5.1" diff --git a/src/app/basic_examples/abi_encode/page.mdx b/src/app/basic_examples/abi_encode/page.mdx index cab3dfae..3b74ebef 100644 --- a/src/app/basic_examples/abi_encode/page.mdx +++ b/src/app/basic_examples/abi_encode/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "ABI Decode • Stylus by Example", - description: - "A simple solidity ABI encode and decode example", + title: "ABI Decode • Stylus by Example", + description: + "A simple solidity ABI encode and decode example", }; {/* Begin Content */} @@ -184,10 +184,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10" diff --git a/src/app/basic_examples/arrays/page.mdx b/src/app/basic_examples/arrays/page.mdx index daaac830..769ef4dc 100644 --- a/src/app/basic_examples/arrays/page.mdx +++ b/src/app/basic_examples/arrays/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Arrays • Stylus by Example", - description: - "A simple arrays example in stylus", + title: "Arrays • Stylus by Example", + description: + "A simple arrays example in stylus", }; {/* Begin Content */} @@ -253,10 +253,10 @@ edition = "2021" description = "Stylus arrays example" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" dotenv = "0.15.0" diff --git a/src/app/basic_examples/bytes_in_bytes_out/page.mdx b/src/app/basic_examples/bytes_in_bytes_out/page.mdx index 13dd3ba7..86dd3b81 100644 --- a/src/app/basic_examples/bytes_in_bytes_out/page.mdx +++ b/src/app/basic_examples/bytes_in_bytes_out/page.mdx @@ -35,7 +35,7 @@ version = "0.1.7" edition = "2021" [dependencies] -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" [features] export-abi = ["stylus-sdk/export-abi"] diff --git a/src/app/basic_examples/constants/page.mdx b/src/app/basic_examples/constants/page.mdx index aeb575d7..18130ff6 100644 --- a/src/app/basic_examples/constants/page.mdx +++ b/src/app/basic_examples/constants/page.mdx @@ -1,6 +1,6 @@ export const metadata = { - title: 'Constants • Stylus by Example', - description: "How to declare constants in your Rust smart contracts using Arbitrum's Stylus SDK", + title: 'Constants • Stylus by Example', + description: "How to declare constants in your Rust smart contracts using Arbitrum's Stylus SDK", }; {/* Begin Content */} @@ -16,7 +16,7 @@ Since their value is hardcoded, they can save on gas cost as their value does no ## Learn More - [Rust docs - Constant items](https://doc.rust-lang.org/reference/items/constant-items.html) -- [Solidity docs - Constant variables](https://docs.soliditylang.org/en/v0.8.19/contracts.html#constant) +- [Solidity docs - Constant variables](https://docs.soliditylang.org/en/stable/contracts.html#constant) ### src/lib.rs @@ -71,10 +71,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/delegate_call/page.mdx b/src/app/basic_examples/delegate_call/page.mdx index 258144c2..98b95b9f 100644 --- a/src/app/basic_examples/delegate_call/page.mdx +++ b/src/app/basic_examples/delegate_call/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Call • Stylus by Example", - description: - "Explanation on how to use delegate call on Rust Stylus smart contracts", + title: "Call • Stylus by Example", + description: + "Explanation on how to use delegate call on Rust Stylus smart contracts", }; {/* Begin Content */} @@ -169,10 +169,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10" diff --git a/src/app/basic_examples/errors/page.mdx b/src/app/basic_examples/errors/page.mdx index 6d2cc9d4..94516685 100644 --- a/src/app/basic_examples/errors/page.mdx +++ b/src/app/basic_examples/errors/page.mdx @@ -1,6 +1,6 @@ export const metadata = { - title: 'Errors • Stylus by Example', - description: 'How to define and use Errors on Stylus Rust smart contracts', + title: 'Errors • Stylus by Example', + description: 'How to define and use Errors on Stylus Rust smart contracts', }; {/* Begin Content */} @@ -169,9 +169,9 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -stylus-sdk = "0.6.0" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/events/page.mdx b/src/app/basic_examples/events/page.mdx index 9acd1adb..226f5918 100644 --- a/src/app/basic_examples/events/page.mdx +++ b/src/app/basic_examples/events/page.mdx @@ -11,17 +11,19 @@ Events allow for data to be logged publicly to the blockchain. Log entries provi ## Learn More -- [Solidity docs: Events](https://docs.soliditylang.org/en/v0.8.19/abi-spec.html#events) -- [`stylus_sdk::evm::log`](https://docs.rs/stylus-sdk/latest/stylus_sdk/evm/fn.log.html) -- [`alloy_sol_types::SolEvent`](https://docs.rs/alloy-sol-types/0.3.1/alloy_sol_types/trait.SolEvent.html) +- [Solidity docs: Events](https://docs.soliditylang.org/en/stable/abi-spec.html#events) +- [`stylus_sdk::stylus_core::log`](https://docs.rs/stylus-core/0.9.0/stylus_core/fn.log.html) +- [`alloy_sol_types::SolEvent`](https://docs.rs/alloy-sol-types/latest/alloy_sol_types/trait.SolEvent.html) ## Log -Using the `evm::log` function in the Stylus SDK is the preferred way to log events. It ensures that an event will be logged in a Solidity ABI-compatible format. The `log` function takes any type that implements Alloy `SolEvent` trait. It's not recommended to attempt to implement this trait on your own. Instead, make use of the provided `sol!` macro to declare your Events and their schema using Solidity-style syntax to declare the parameter types. Alloy will create ABI-compatible Rust types which you can instantiate and pass to the `evm::log` function. +Using the `stylus_core::log` function in the Stylus SDK is the preferred way to log events. It ensures that an event will be logged in a Solidity ABI-compatible format. The `log` function takes any type that implements Alloy `SolEvent` trait. It's not recommended to attempt to implement this trait on your own. Instead, make use of the provided `sol!` macro to declare your Events and their schema using Solidity-style syntax to declare the parameter types. Alloy will create ABI-compatible Rust types which you can instantiate and pass to the `stylus_core::log` function. ### Log Usage ```rust +use stylus_sdk::stylus_core; + // sol! macro event declaration // Up to 3 parameters can be indexed. // Indexed parameters helps you filter the logs efficiently @@ -36,15 +38,15 @@ pub struct Events {} #[public] impl Events { -fn user_main(_input: Vec) -> ArbResult { +fn user_main(_input: Vec, &self) -> ArbResult { // emits a 'Log' event, defined above in the sol! macro - evm::log(Log { + stylus_core::log(self.vm(), Log { sender: Address::from([0x11; 20]), message: "Hello world!".to_string(), }); // no data, but 'AnotherLog' event will still emit to the chain - evm::log(AnotherLog {}); + stylus_core::log(AnotherLog {}); Ok(vec![]) } @@ -53,9 +55,9 @@ fn user_main(_input: Vec) -> ArbResult { ## Raw Log -The `evm::raw_log` affordance offers the ability to send anonymous events that do not necessarily conform to the Solidity ABI. Instead, up to four raw 32-byte indexed topics are published along with any arbitrary bytes appended as data. +The `self.vm().raw_log` affordance offers the ability to send anonymous events that do not necessarily conform to the Solidity ABI. Instead, up to **four raw 32-byte indexed topics** are published along with any arbitrary bytes appended as data. -**NOTE**: It's still possible to achieve Solidity ABI compatibility using this construct. To do so you'll have to manually compute the ABI signature for the event, [following the equation set in the Solidity docs](https://docs.soliditylang.org/en/v0.8.19/abi-spec.html#events). The result of that should be assigned to `TOPIC_0`, the first topic in the slice passed to `raw_log`. +**NOTE**: It's still possible to achieve Solidity ABI compatibility using this construct. To do so you'll have to manually compute the ABI signature for the event, [following the equation set in the Solidity docs](https://docs.soliditylang.org/en/stable/abi-spec.html#events). The result of that should be assigned to `TOPIC_0`, the first topic in the slice passed to `raw_log`. ### Raw Log Usage @@ -74,7 +76,7 @@ let mut data: Vec = vec![]; data.extend_from_slice(balance.to_be_bytes::<32>().to_vec().as_slice()); // unwrap() here 'consumes' the Result -evm::raw_log(topics.as_slice(), data.as_ref()).unwrap(); +self.vm().raw_log(topics.as_slice(), data.as_ref()).unwrap(); ``` ## Result @@ -137,7 +139,7 @@ use alloc::vec::Vec; use alloc::{string::ToString, vec}; use stylus_sdk::alloy_primitives::U256; -use stylus_sdk::{alloy_primitives::Address, alloy_sol_types::sol, evm, prelude::*, ArbResult}; +use stylus_sdk::{alloy_primitives::Address, alloy_sol_types::sol, stylus_core, prelude::*, ArbResult}; // sol! macro event declaration // Up to 3 parameters can be indexed. @@ -153,15 +155,15 @@ pub struct Events {} #[public] impl Events { -fn user_main(_input: Vec) -> ArbResult { +fn user_main(&self, _input: Vec) -> ArbResult { // emits a 'Log' event, defined above in the sol! macro - evm::log(Log { + stylus_core::log(self.vm(), Log { sender: Address::from([0x11; 20]), message: "Hello world!".to_string(), }); // no data, but event will still log to the chain - evm::log(AnotherLog {}); + stylus_core::log(self.vm(), AnotherLog {}); // set up local variables let user = Address::from([0x22; 20]); @@ -177,7 +179,7 @@ fn user_main(_input: Vec) -> ArbResult { data.extend_from_slice(balance.to_be_bytes::<32>().to_vec().as_slice()); // unwrap() here 'consumes' the Result - evm::raw_log(topics.as_slice(), data.as_ref()).unwrap(); + self.vm().raw_log(topics.as_slice(), data.as_ref()).unwrap(); Ok(Vec::new()) } @@ -188,26 +190,36 @@ fn user_main(_input: Vec) -> ArbResult { ```toml [package] -name = "stylus_events_example" -version = "0.1.7" +name = "stylus_event_example" +version = "0.1.11" edition = "2021" license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] +description = "Stylus event example" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" -hex = "0.4.3" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" +hex = { version = "0.4", default-features = false } [dev-dependencies] +alloy-primitives = { version = "=0.8.20", features = ["sha3-keccak"] } tokio = { version = "1.12.0", features = ["full"] } ethers = "2.0" eyre = "0.6.8" +stylus-sdk = { version = "0.9.0", features = ["stylus-test"] } +dotenv = "0.15.0" [features] +default = ["mini-alloc"] export-abi = ["stylus-sdk/export-abi"] +debug = ["stylus-sdk/debug"] +mini-alloc = ["stylus-sdk/mini-alloc"] + +[[bin]] +name = "stylus_event_example" +path = "src/main.rs" [lib] crate-type = ["lib", "cdylib"] @@ -217,5 +229,8 @@ codegen-units = 1 strip = true lto = true panic = "abort" -opt-level = "s" + +# If you need to reduce the binary size, it is advisable to try other +# optimization levels, such as "s" and "z" +opt-level = 3 ``` diff --git a/src/app/basic_examples/export_interface/page.mdx b/src/app/basic_examples/export_interface/page.mdx index f9d79557..cee9fda0 100644 --- a/src/app/basic_examples/export_interface/page.mdx +++ b/src/app/basic_examples/export_interface/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'Export contract interface • Stylus by Example', - description: - "How to export the Solidity ABI interface of your Rust contract.", + title: 'Export contract interface • Stylus by Example', + description: + "How to export the Solidity ABI interface of your Rust contract.", }; {/* Begin Content */} @@ -55,7 +55,7 @@ And the relevant parts of the `Cargo.toml` file, notice that it has the `export- ```toml ... [dependencies] -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" ... [features] diff --git a/src/app/basic_examples/first_app/page.mdx b/src/app/basic_examples/first_app/page.mdx index 046593bb..13b83f35 100644 --- a/src/app/basic_examples/first_app/page.mdx +++ b/src/app/basic_examples/first_app/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'First App • Stylus by Example', - description: - 'This example shows how to build a simple Arbitrum Stylus Rust contract that defines a count value in storage.', + title: 'First App • Stylus by Example', + description: + 'This example shows how to build a simple Arbitrum Stylus Rust contract that defines a count value in storage.', }; {/* Begin Content */} @@ -72,7 +72,7 @@ impl Counter { #[cfg(feature = "export-abi")] fn main() { - stylus_counter::print_abi("MIT-OR-APACHE-2.0", "pragma solidity ^0.8.23;"); + stylus_counter::print_from_args(); } ``` @@ -85,9 +85,9 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -stylus-sdk = "0.6.0" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/function/page.mdx b/src/app/basic_examples/function/page.mdx index c26fa4ca..aa586cb2 100644 --- a/src/app/basic_examples/function/page.mdx +++ b/src/app/basic_examples/function/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'Function • Stylus by Example', - description: - 'How to define and use internal and external functions in Stylus, and how to return multiple values from functions.', + title: 'Function • Stylus by Example', + description: + 'How to define and use internal and external functions in Stylus, and how to return multiple values from functions.', }; {/* Begin Content */} @@ -208,10 +208,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" diff --git a/src/app/basic_examples/hashing/page.mdx b/src/app/basic_examples/hashing/page.mdx index b9a9dccd..39a9598f 100644 --- a/src/app/basic_examples/hashing/page.mdx +++ b/src/app/basic_examples/hashing/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Hasing with keccak256 • Stylus by Example", - description: - "A simple solidity ABI encode and decode example", + title: "Hasing with keccak256 • Stylus by Example", + description: + "A simple solidity ABI encode and decode example", }; {/* Begin Content */} @@ -185,10 +185,10 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" diff --git a/src/app/basic_examples/hello_world/page.mdx b/src/app/basic_examples/hello_world/page.mdx index abe134f3..1dff9009 100644 --- a/src/app/basic_examples/hello_world/page.mdx +++ b/src/app/basic_examples/hello_world/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'Hello World • Stylus by Example', - description: - 'This example shows how to use the `console!` macro from the Arbitrum Stylus Rust SDK to print output to the terminal for debugging.', + title: 'Hello World • Stylus by Example', + description: + 'This example shows how to use the `console!` macro from the Arbitrum Stylus Rust SDK to print output to the terminal for debugging.', }; {/* Begin Content */} @@ -65,8 +65,8 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" stylus-sdk = { version = "0.6.0", features = ["debug"] } hex = "0.4.3" diff --git a/src/app/basic_examples/mapping/page.mdx b/src/app/basic_examples/mapping/page.mdx index 70c95812..aac01489 100644 --- a/src/app/basic_examples/mapping/page.mdx +++ b/src/app/basic_examples/mapping/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Mapping • Stylus by Example", - description: - "How to declare and use mapping using Arbitrum's Stylus SDK", + title: "Mapping • Stylus by Example", + description: + "How to declare and use mapping using Arbitrum's Stylus SDK", }; {/* Begin Content */} @@ -100,9 +100,9 @@ version = "0.1.7" edition = "2021" [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" -stylus-sdk = "0.6.0" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/primitive_data_types/page.mdx b/src/app/basic_examples/primitive_data_types/page.mdx index 14bbf7ef..a8a5d877 100644 --- a/src/app/basic_examples/primitive_data_types/page.mdx +++ b/src/app/basic_examples/primitive_data_types/page.mdx @@ -28,7 +28,7 @@ More in-depth documentation about the available methods and types in the Alloy l - [`Uint`](https://docs.rs/ruint/1.10.1/ruint/struct.Uint.html) - [Stylus Rust SDK](https://docs.rs/stylus-sdk/latest/stylus_sdk/index.html) - [`Bytes`](https://docs.rs/stylus-sdk/latest/stylus_sdk/abi/struct.Bytes.html) -- [Solidity docs (v0.8.19)](https://docs.soliditylang.org/en/v0.8.19/types.html) +- [Solidity docs (stable)](https://docs.soliditylang.org/en/stable/types.html) ## Integers @@ -268,10 +268,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/sending_ether/page.mdx b/src/app/basic_examples/sending_ether/page.mdx index 2d47cf77..e84764c2 100644 --- a/src/app/basic_examples/sending_ether/page.mdx +++ b/src/app/basic_examples/sending_ether/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Sending Ether • Stylus by Example", - description: - "How to send Ether in your Rust smart contracts using Arbitrum's Stylus SDK", + title: "Sending Ether • Stylus by Example", + description: + "How to send Ether in your Rust smart contracts using Arbitrum's Stylus SDK", }; {/* Begin Content */} @@ -122,10 +122,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/storage_data_types/page.mdx b/src/app/basic_examples/storage_data_types/page.mdx index f2aad56e..4b5d328e 100644 --- a/src/app/basic_examples/storage_data_types/page.mdx +++ b/src/app/basic_examples/storage_data_types/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Storage Data Types • Stylus by Example", - description: - 'Defines the basic state variables used in Arbitrum Stylus Rust smart contracts and how they can be used to store and retrieve state from the VM.', + title: "Storage Data Types • Stylus by Example", + description: + 'Defines the basic state variables used in Arbitrum Stylus Rust smart contracts and how they can be used to store and retrieve state from the VM.', }; {/* Begin Content */} @@ -317,10 +317,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [features] diff --git a/src/app/basic_examples/variables/page.mdx b/src/app/basic_examples/variables/page.mdx index a6eff08d..3750bba1 100644 --- a/src/app/basic_examples/variables/page.mdx +++ b/src/app/basic_examples/variables/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'Variables • Stylus by Example', - description: - 'An explanation of the types of variables available as part of the Arbitrum Stylus Rust SDK and how it differs from Solidity.', + title: 'Variables • Stylus by Example', + description: + 'An explanation of the types of variables available as part of the Arbitrum Stylus Rust SDK and how it differs from Solidity.', }; {/* Begin Content */} @@ -14,15 +14,15 @@ In Rust, **local variables** are just ordinary variables you assign with `let` o Unlike Solidity, Rust was not built inherently with the blockchain in mind. It is a general purpose programming language. We therefore define specific _storage_ types to explicitly denote values intended to be stored permanently as part of the contract's state. **State variables** cost the same to store as their Solidity equivalents. -**Global variables** in Solidity, such as `msg.sender` and `block.timestamp`, are available as function calls pulled in from the `stylus_sdk` with their Rust equivalents being `msg::sender()` and `block::timestamp()`, respectively. These variables provide information about the blockchain or the active transaction. +**Global variables** in Solidity, such as `msg.sender` and `block.timestamp`, are available as function calls pulled in from the `stylus_core` in the `stylus_sdk` with their Rust equivalents being `self.vm().msg_sender()` and `self.vm().block_timestamp()`, respectively. These variables provide information about the blockchain or the active transaction. ## Learn more - [Rust Docs - Variables and Mutability](https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html) - [Stylus SDK Rust Docs - Storage](https://docs.rs/stylus-sdk/latest/stylus_sdk/storage/index.html) - [Stylus SDK Guide - Storage](https://docs.arbitrum.io/stylus/reference/rust-sdk-guide#storage) -- [Solidity docs - state variables](https://docs.soliditylang.org/en/v0.8.19/structure-of-a-contract.html#state-variables) -- [Solidity docs - global variables](https://docs.soliditylang.org/en/v0.8.19/cheatsheet.html#global-variables) +- [Solidity docs - state variables](https://docs.soliditylang.org/en/stable/structure-of-a-contract.html#state-variables) +- [Solidity docs - global variables](https://docs.soliditylang.org/en/stable/cheatsheet.html#global-variables) ### src/lib.rs @@ -34,7 +34,7 @@ extern crate alloc; use stylus_sdk::alloy_primitives::{U16, U256}; use stylus_sdk::prelude::*; use stylus_sdk::storage::{StorageAddress, StorageBool, StorageU256}; -use stylus_sdk::{block, console, msg}; +use stylus_sdk::{block, console}; #[storage] #[entrypoint] @@ -57,8 +57,9 @@ impl Contract { self.initialized.set(true); // We set the contract owner to the caller, - // which we get from the global msg module - self.owner.set(msg::sender()); + // which we get from the inbuilt Stylus contracts + let new_owner = self.vm().msg_sender(); + self.owner.set(new_owner); self.max_supply.set(U256::from(10_000)); Ok(()) @@ -72,8 +73,8 @@ impl Contract { let _j = U16::from(123); // Here are some global variables - let _timestamp = block::timestamp(); - let _amount = msg::value(); + let _timestamp = self.vm().block_timestamp(); + let _amount = self.vm().msg_value(); console!("Local variables: {_i}, {_j}"); console!("Global variables: {_timestamp}, {_amount}"); @@ -95,10 +96,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" [dev-dependencies] diff --git a/src/app/basic_examples/verify_signature/page.mdx b/src/app/basic_examples/verify_signature/page.mdx index 56ed6549..562d0659 100644 --- a/src/app/basic_examples/verify_signature/page.mdx +++ b/src/app/basic_examples/verify_signature/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "Verifying Signature • Stylus by Example", - description: - "An explanation of how to verify a signature signed off chain.", + title: "Verifying Signature • Stylus by Example", + description: + "An explanation of how to verify a signature signed off chain.", }; {/* Begin Content */} @@ -171,10 +171,10 @@ license = "MIT OR Apache-2.0" keywords = ["arbitrum", "ethereum", "stylus", "alloy"] [dependencies] -alloy-primitives = "=0.7.6" -alloy-sol-types = "=0.7.6" +alloy-primitives = "=0.8.20" +alloy-sol-types = "=0.8.20" mini-alloc = "0.4.2" -stylus-sdk = "0.6.0" +stylus-sdk = "0.9.0" hex = "0.4.3" sha3 = "0.10.8" diff --git a/src/app/basic_examples/vm_affordances/page.mdx b/src/app/basic_examples/vm_affordances/page.mdx index 1385bbd3..5994358b 100644 --- a/src/app/basic_examples/vm_affordances/page.mdx +++ b/src/app/basic_examples/vm_affordances/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: "VM affordances • Stylus by Example", - description: - "How to access VM affordances using the Arbitrum Stylus Rust SDK.", + title: "VM affordances • Stylus by Example", + description: + "How to access VM affordances using the Arbitrum Stylus Rust SDK.", }; {/* Begin Content */} @@ -93,7 +93,7 @@ use stylus_sdk::{evm}; let gas_left = evm::gas_left(); let ink_left = evm::ink_left(); -evm::log(...); +stylus_core::log(self.vm(),...); evm::pay_for_memory_grow(); evm::raw_log(...); ``` @@ -106,9 +106,9 @@ sol! { event Approval(address indexed owner, address indexed spender, uint256 value); } -fn foo() { +fn foo(&self) { ... - evm::log(Transfer { + stylus_core::log(self.vm(),Transfer { from: Address::ZERO, to: address, value, diff --git a/src/app/getting_started/using_the_cli/page.mdx b/src/app/getting_started/using_the_cli/page.mdx index df4f9075..6fd18564 100644 --- a/src/app/getting_started/using_the_cli/page.mdx +++ b/src/app/getting_started/using_the_cli/page.mdx @@ -1,7 +1,7 @@ export const metadata = { - title: 'Using the CLI • Stylus by Example', - description: - "How to use cargo stylus and Foundry's cast CLI tool to effectively deploy and query your Arbitrum Stylus Rust smart contract", + title: 'Using the CLI • Stylus by Example', + description: + "How to use cargo stylus and Foundry's cast CLI tool to effectively deploy and query your Arbitrum Stylus Rust smart contract", }; {/* Begin Content */} @@ -180,7 +180,7 @@ Let's break down the above `call`. We are passing two flags to it. `--rpc-url` c Technically, we do not need to include a private key to `call` a contract, since there is no need for any gas to `call` read-only functions. However, it tends to be more convenient to leave it in there for simple switching between `call` and `send`. It's usually quicker to press the up key on your terminal to recall your last command and then edit it by navigating to the word or words you need to change. -After the private key, we include the contract address, which on my machine was `0x525c2aba45f66987217323e8a05ea400c65d06dc` (but will likely differ on yours). We are using the local variable `$CONTRACT` sourced from the `.env` file to reference this. So we are letting `cast` know we wish to call our newly deployed contract. We now need to tell `cast` how to interpret the API function that we're invoking. We do that with the function's Solidity-style signature. The `"number()(uint256)"` argument says that we wish to call the `number` external function, it takes no arguments and it returns a 256-bit integer as denoted in the second pair of parentheses. The `uint256` syntax comes from the types listed in the [Solidity docs](https://docs.soliditylang.org/en/v0.8.19/types.html). +After the private key, we include the contract address, which on my machine was `0x525c2aba45f66987217323e8a05ea400c65d06dc` (but will likely differ on yours). We are using the local variable `$CONTRACT` sourced from the `.env` file to reference this. So we are letting `cast` know we wish to call our newly deployed contract. We now need to tell `cast` how to interpret the API function that we're invoking. We do that with the function's Solidity-style signature. The `"number()(uint256)"` argument says that we wish to call the `number` external function, it takes no arguments and it returns a 256-bit integer as denoted in the second pair of parentheses. The `uint256` syntax comes from the types listed in the [Solidity docs](https://docs.soliditylang.org/en/stable/types.html). The result was `0`, which is what we expect a new counter to be initialized to. Let's try incrementing it! This time, we'll invoke the `send` command.