Interacting with the contracts via the Move Studio IDE
Figure out how to get the flag
Take a look at the smart contract source code
The first step in figuring out how to get the flag is view the source code. The source code was provided was the event and can be viewed here. Navigate to Module.move in the source directory to find the module source code.
sources/module.move
module movectf::checkin {
use sui::event;
use sui::tx_context::{Self, TxContext};
struct Flag has copy, drop {
user: address,
flag: bool
}
public entry fun get_flag(ctx: &mut TxContext) {
event::emit(Flag {
user: tx_context::sender(ctx),
flag: true
})
}
}
In the source code of the deployed module called movectf::checkin, you can see that the get_flag() function. When looking in the body of the function, you can see that the Flag event is emitted when the function is called.
You can also see that the function has the entry function modifier. This modifier means that this function can be called via a script. Functions without this modifier can only be called by other Modules on the chain.
Note that the function has a parameter, ctx: &mut TxContext . The the TxContext holds information about the transactions used to interact with the module's function and is automatically given to the module during each interaction. In this function, the sender of the transaction (the address of the account that called the function) is being used in the Flag event emittance.
Get the flag
Connect and interact with the deployed contract
We will be using the Move Studio IDE to interact with the deployed contract. Visit the site here. You should already have a wallet to have gotten this far, but make sure you are using either the Sui or Martian wallet, as these are the wallets that Move Studio currently supports.
Navigate to the deploy page of the IDE by click the top left bottom of page.
Move Studio deploy page
Go ahead and skip the tutorial. Instead of deploying a new package, we are going to add the deployed challenge package. Get the address of the created challenge package from Sui explorer using the transaction id provided by the CTF page. Enter the address in the section labeled, Add existing package or object. Click add. You will be prompted to name the package you are manually adding. Name it movectf.
CTF challenge package
Now we have access to the deployed challenge package. Using the Package Details selector, you can view all of the package's structs and functions (both entry and non entry). Select the checkin::get_flag function.
get_flag interface
Now we have the get_flag function interface that we can use to execute a function call. Click execute and confirm the transaction with your wallet. Once the green, successful transaction shows up, click on the box and arrow icon to view the transaction on the Sui explorer. Here are can go to events and confirm that the flag event was emitted!
The explorer page showing the events emitted during the transaction. The Flag event is emitted. Note that the user attribute is listed which we could see in the module source code.
Submit transaction hash
The transaction hash associated with the transaction where the Flag event was emitted can now be submitted.
The confirmation of the flag event being emitted in the submitted transaction hash
You can now head over to step 5 to turn in the flag to complete the challenge! We also recommend you try this challenge again using step 4b as a guide instead of this page. 4b will teach you how to interact with the package via the Sui TypeScript SDK.