How to explore Aptos framework and find resources

Aptos is a Layer 1 blockchain that allows developers to create their smart-contracts in Move language.
Aptos is focused on delivering the safest and most production-ready Layer 1 blockchain in the world. The team is comprised of the original creators, researchers, designers, and builders of Diem, the blockchain that was first built at Meta.
The key components of Aptos are AptosBFT consensus and the new Move language which allows developers to build safe and scalable decentralized applications.

Every user of the Aptos blockchain has their own object storage located at the user address.
There are built in methods which allow access to this storage from the Move code.
/// check whether object is present in storage
fun exists(addr): bool;

/// return read-only reference to the object
fun borrow_global<T>(addr): &T;

/// return mutable reference to the object
fun borrow_global_mut<T>(addr): &mut T;

/// add object to the storage
fun move_to<T>(&signer, T);

/// remove object from the storage
fun move_from<T>(addr): T;

In that storage, smart-contracts store special structs called Resources. Those are marked with the has key ability after the name of the struct.
To place a resource on a user address, a developer should have the &signer argument in scope and call the move_to function. The &signer data type in the Move language represents the sender account of the current transaction, and is used mostly for resource store and access restrictions in modules. Developers can extract the address of the transaction sender using signer::address_of(&signer) function.
All functions that fetch resource objects from storage require an annotation on the function signature. For that, add acquires ResourceName after the return type.

1 Like

Nice piece :pray:

Nice write up