Building on Aptos: A Guide for Ethereum Developers
Ethereum to Aptos Cheat Sheet
Account Models
Data Storage Models
Contract-Level Storage and Account-Centric Storage
Solidity to Move
Typescript SDK
Aptos Developer Docs
Function Visibility
Solidity
Functions can have the following visibility modifiers:
- public: Accessible externally and internally.
- private: Restricted to usage within the contract where it's defined.
- internal: Limited to use within the contract where it's defined or the contract that inherits it.
- external: Accessible only externally.
contract FunctionsVisibility { function publicFunction() public {/* ... */} function _privateFunction() private { /* ... */ } function _internalFunction() internal { /* ... */ } function _externalFunction() external { /* ... */ }}
Move
Doesn't have equivalents to Solidity's external and private visibility modifiers. However, you can define functions that are accessible only by certain modules, known as "friends".
- public entry: Accessible internally, by other modules, and externally as Solidity's public.
- public: Can be accessed internally and by other modules, but not externally.
- public(friend): Accessible internally and by friend modules.
- No modifier: Can be invoked only internally, akin to Solidity's internal.
address module_address { module example { friend module_address::example_friend; public entry fun public_entry_function() { /* ... */ } public fun public_fun() { /* ... */ } public(friend) fun public_friend_fun() { /* ... */ } fun internal_fun() { /* ... */ } } module example_friend { fun calls_public_friend_fun() { module_address::example::public_friend_fun(); // Success } } module example_not_friend { fun calls_public_friend_fun() { module_address::example::public_friend_fun(); // Compile error: 'public_friend_fun' can only be called from // a 'friend' of module 'module_address::example' } }}