Functions
Move functions are similar to Solidity functions, but default visibility and transaction entry points work differently.
Function categories
Section titled “Function categories”funis private by default.public entry funis the equivalent of a transaction-callable external method.#[view] public funis the equivalent of a read-only public method callable without a transaction.
Entry functions
Section titled “Entry functions”function addMessage(string memory messageText_) external { // ...}public entry fun add_message(sender: &signer, message: String) { // ...}public entrymakes the function transaction-callable.&signergives you the authenticated sender instead ofmsg.sender.- In current Move, you do not need an
acquiresannotation for this pattern.
View functions
Section titled “View functions”function getMessages() external view returns (Message[] memory) { // ...}#[view]public fun get_messages(): vector<Message> { // ...}Visibility difference that trips people up
Section titled “Visibility difference that trips people up”In Solidity you often start from public and restrict only when needed. In Move, start from private fun and expose only what the module truly needs to expose.