53 lines
1.4 KiB
Rust
Raw Normal View History

2025-07-17 10:10:39 -03:00
use core::account::Account;
2025-07-17 11:34:56 -03:00
use risc0_zkvm::{default_executor, ExecutorEnv};
2025-07-11 19:21:06 -03:00
2025-07-16 17:33:58 -03:00
use nssa;
2025-07-16 17:25:03 -03:00
2025-07-17 11:07:18 -03:00
use nssa::program::TransferMultipleProgram;
2025-07-16 16:45:07 -03:00
2025-07-11 19:44:43 -03:00
/// A public execution.
/// This would be executed by the runtime after checking that
/// the initiating transaction includes the sender's signature.
2025-07-16 17:25:03 -03:00
pub fn main() {
2025-07-11 19:44:43 -03:00
// Account fetched from the chain state with 150 in its balance.
let sender = {
let mut account = Account::new([5; 8], [98; 8]);
account.balance = 150;
account
};
// Account fetched from the chain state with 900 in its balance.
2025-07-17 11:07:18 -03:00
let receiver_1 = {
2025-07-11 19:44:43 -03:00
let mut account = Account::new([6; 8], [99; 8]);
account.balance = 900;
account
};
2025-07-11 19:21:06 -03:00
2025-07-17 11:07:18 -03:00
let receiver_2 = {
let mut account = Account::new([6; 8], [99; 8]);
account.balance = 500;
account
};
let balance_to_move = vec![10, 20];
2025-07-11 19:21:06 -03:00
2025-07-17 11:34:56 -03:00
let inputs_outputs = nssa::execute::<TransferMultipleProgram>(
&[sender, receiver_1, receiver_2],
2025-07-17 16:05:24 -03:00
balance_to_move,
2025-07-17 11:34:56 -03:00
)
.unwrap();
println!(
"sender_before: {:?}, sender_after: {:?}",
2025-07-17 11:07:18 -03:00
inputs_outputs[0], inputs_outputs[3]
);
println!(
"receiver_1_before: {:?}, receiver_1_after: {:?}",
inputs_outputs[1], inputs_outputs[4],
);
println!(
2025-07-17 11:07:18 -03:00
"receiver_2_before: {:?}, receiver_2_after: {:?}",
inputs_outputs[2], inputs_outputs[5],
);
2025-07-11 19:21:06 -03:00
}