Move Script

A script in the Move language acts as an executable entrypoint, akin to the main function in traditional programming languages. It primarily invokes functions from a published module to modify global storage and must consist of a single function that does not return any value. Unlike modules, scripts are transient and not stored globally.

A common use case for a script is to execute two functions simultaneously, ensuring their operations are atomic.



// script_feed_gotchi.move
script {
// Running this script will feed user's gotchi twice in one transaction
// Increasing gotchi's energy point by 2.
fun feed_gotchi(user: &signer) {
let energy_points = 1;
aptogotchi::main::feed(user, energy_points);
aptogotchi::main::feed(user, energy_points);
}
}