@@ -50,7 +50,7 @@ In the previous section, we explained how to instantiate the Miden client. We ca
5050
5151Copy and paste the following code into your ` src/main.rs ` file:
5252
53- ``` rust,no_run
53+ ``` rust
5454use miden_lib :: account :: auth :: NoAuth ;
5555use rand :: RngCore ;
5656use std :: {fs, path :: Path , sync :: Arc };
@@ -179,9 +179,6 @@ export.get_count
179179
180180 exec.account::get_item
181181 # => [count]
182-
183- exec.sys::truncate_stack
184- # => []
185182end
186183
187184# => []
237234
238235To build the counter contract copy and paste the following code at the end of your ` src/main.rs ` file:
239236
240- ``` rust,no_run
237+ ``` rust
241238# use miden_lib :: account :: auth :: NoAuth ;
242239# use rand :: RngCore ;
243240# use std :: {fs, path :: Path , sync :: Arc };
@@ -332,13 +329,17 @@ let (counter_contract, counter_seed) = AccountBuilder::new(seed)
332329 . build ()
333330 . unwrap ();
334331
332+ println! (
333+ " counter_contract commitment: {:?}" ,
334+ counter_contract . commitment ()
335+ );
335336println! (
336337 " counter_contract id: {:?}" ,
337338 Address :: from (AccountIdAddress :: new (
338339 counter_contract . id (),
339340 AddressInterface :: Unspecified
340341 ))
341- .to_bech32(NetworkId::Devnet )
342+ . to_bech32 (NetworkId :: Testnet )
342343);
343344println! (" counter_contract storage: {:?}" , counter_contract . storage ());
344345
@@ -372,7 +373,7 @@ Now that we built the counter contract, lets create a transaction request to inc
372373
373374Paste the following code at the end of your ` src/main.rs ` file:
374375
375- ``` rust,no_run
376+ ``` rust
376377# use miden_lib :: account :: auth :: NoAuth ;
377378# use rand :: RngCore ;
378379# use std :: {fs, path :: Path , sync :: Arc };
@@ -477,7 +478,7 @@ Paste the following code at the end of your `src/main.rs` file:
477478# counter_contract . id (),
478479# AddressInterface :: Unspecified
479480# ))
480- # .to_bech32(NetworkId::Devnet )
481+ # . to_bech32 (NetworkId :: Testnet )
481482# );
482483# println! (" counter_contract storage: {:?}" , counter_contract . storage ());
483484#
@@ -501,16 +502,13 @@ let account_component_lib = create_library(
501502 & counter_code ,
502503)
503504. unwrap ();
504- println!("here");
505505
506506let tx_script = ScriptBuilder :: new (true )
507507 . with_dynamically_linked_library (& account_component_lib )
508508 . unwrap ()
509509 . compile_tx_script (script_code )
510510 . unwrap ();
511511
512- println!("here");
513-
514512// Build a transaction request with the custom script
515513let tx_increment_request = TransactionRequestBuilder :: new ()
516514 . custom_script (tx_script )
@@ -656,7 +654,7 @@ async fn main() -> Result<(), ClientError> {
656654 counter_contract . id (),
657655 AddressInterface :: Unspecified
658656 ))
659- . to_bech32 (NetworkId :: Devnet )
657+ . to_bech32 (NetworkId :: Testnet )
660658 );
661659 println! (" counter_contract storage: {:?}" , counter_contract . storage ());
662660
@@ -681,16 +679,13 @@ async fn main() -> Result<(), ClientError> {
681679 & counter_code ,
682680 )
683681 . unwrap ();
684- println! (" here" );
685682
686683 let tx_script = ScriptBuilder :: new (true )
687684 . with_dynamically_linked_library (& account_component_lib )
688685 . unwrap ()
689686 . compile_tx_script (script_code )
690687 . unwrap ();
691688
692- println! (" here" );
693-
694689 // Build a transaction request with the custom script
695690 let tx_increment_request = TransactionRequestBuilder :: new ()
696691 . custom_script (tx_script )
@@ -728,15 +723,16 @@ async fn main() -> Result<(), ClientError> {
728723The output of our program will look something like this:
729724
730725``` text
731- Latest block: 226717
726+ Latest block: 374255
732727
733728[STEP 1] Creating counter contract.
734- counter_contract commitment: RpoDigest([10854804595308759734, 11034759279878416408, 15662010127375823242, 9560626040625797366])
735- counter_contract id: "mtst1qpj0g3ke67tg5qqqqd2z4ffm9g8ezpf6"
736- counter_contract storage: AccountStorage { slots: [Value([0, 0, 0, 0])] }
729+ one or more warnings were emitted
730+ counter_contract commitment: Word([3964727668949550262, 4265714847747507878, 5784293172192015964, 16803438753763367241])
731+ counter_contract id: "mtst1qre73e6qcrfevqqngx8wewvveacqqjh8p2a"
732+ counter_contract storage: AccountStorage { slots: [Value(Word([0, 0, 0, 0]))] }
737733
738734[STEP 2] Call Counter Contract With Script
739- Stack state before step 2502 :
735+ Stack state before step 2610 :
740736├── 0: 1
741737├── 1: 0
742738├── 2: 0
@@ -758,8 +754,10 @@ Stack state before step 2502:
758754├── 18: 0
759755└── 19: 0
760756
761- View transaction on MidenScan: https://testnet.midenscan.com/tx/0x645b89ebf39c7baa2a4264854f793736b7370d65ecf5f1a23c0169fda6a6a395
762- counter contract storage: Ok(RpoDigest([0, 0, 0, 1]))
757+ └── (0 more items)
758+
759+ View transaction on MidenScan: https://testnet.midenscan.com/tx/0x9767940bbed7bd3a74c24dc43f1ea8fe90a876dc7925621c217f648c63c4ab7a
760+ counter contract storage: Ok(Word([0, 0, 0, 1]))
763761```
764762
765763The line in the output ` Stack state before step 2505 ` ouputs the stack state when we call "debug.stack" in the ` counter.masm ` file.
0 commit comments