diff --git a/apps/nextra/components/landing/sections/MoveSection.tsx b/apps/nextra/components/landing/sections/MoveSection.tsx index 1dbcc740e..b4fc40c49 100644 --- a/apps/nextra/components/landing/sections/MoveSection.tsx +++ b/apps/nextra/components/landing/sections/MoveSection.tsx @@ -33,7 +33,7 @@ export function MoveSection() { objects: { label: t.objectsExampleLabel, description: t.objectsExampleDescription, - href: `/${locale}/build/smart-contracts/objects`, + href: `/${locale}/build/smart-contracts/move-objects`, codeSnippet: objectsCodeSnippet, }, fungibleAssets: { @@ -64,7 +64,7 @@ export function MoveSection() { className=" flex flex-col lg:flex-row lg:gap-12 justify-between items-center w-full max-w-[1200px] xl:max-w-[1280px] lg:px-12 - border-t border-t-border-divider lg:border-none max-lg:pt-8 + border-t border-t-border-divider lg:border-none max-lg:pt-8 " >
diff --git a/apps/nextra/next.config.mjs b/apps/nextra/next.config.mjs index 66f08a0b7..0c91b17a9 100644 --- a/apps/nextra/next.config.mjs +++ b/apps/nextra/next.config.mjs @@ -274,22 +274,22 @@ export default withBundleAnalyzer( }, { source: "/move/move-on-aptos/objects", - destination: "/en/build/smart-contracts/objects", + destination: "/en/build/smart-contracts/move-objects", permanent: true, }, { source: "/move/move-on-aptos/objects/creating-objects", - destination: "/en/build/smart-contracts/objects/creating-objects", + destination: "/en/build/smart-contracts/object/creating-objects", permanent: true, }, { source: "/move/move-on-aptos/objects/configuring-objects", - destination: "/en/build/smart-contracts/objects/configuring-objects", + destination: "/en/build/smart-contracts/object/creating-objects", permanent: true, }, { source: "/move/move-on-aptos/objects/using-objects", - destination: "/en/build/smart-contracts/objects/using-objects", + destination: "/en/build/smart-contracts/object/using-objects", permanent: true, }, { @@ -349,7 +349,7 @@ export default withBundleAnalyzer( }, { source: "/standards/aptos-object", - destination: "/en/build/smart-contracts/aptos-standards/aptos-object", + destination: "/en/build/smart-contracts/move-objects", permanent: true, }, { @@ -1051,29 +1051,29 @@ export default withBundleAnalyzer( }, { source: "/en/build/smart-contracts/aptos-standards/aptos-object", - destination: "/en/build/smart-contracts/objects", + destination: "/en/build/smart-contracts/move-objects", permanent: true, }, { source: "/en/build/smart-contracts/aptos-standards/objects", - destination: "/en/build/smart-contracts/objects", + destination: "/en/build/smart-contracts/move-objects", permanent: true, }, { source: "/en/build/smart-contracts/aptos-standards/objects/creating-objects", - destination: "/en/build/smart-contracts/objects/creating-objects", + destination: "/en/build/smart-contracts/object/creating-objects", permanent: true, }, { source: "/en/build/smart-contracts/aptos-standards/objects/configuring-objects", - destination: "/en/build/smart-contracts/objects/creating-objects", + destination: "/en/build/smart-contracts/object/creating-objects", permanent: true, }, { source: "/en/build/smart-contracts/objects/creating-objects", - destination: "/en/build/smart-contracts/objects/using-objects", + destination: "/en/build/smart-contracts/object/creating-objects", permanent: true, }, { @@ -1479,7 +1479,7 @@ export default withBundleAnalyzer( }, { source: "/en/build/smart-contracts/objects/configuring-objects", - destination: "/en/build/smart-contracts/objects", + destination: "/en/build/smart-contracts/object/creating-objects", permanent: true, }, { @@ -1746,6 +1746,21 @@ export default withBundleAnalyzer( destination: "/en/build/smart-contracts/book/move-2", permanent: true, }, + { + source: "/en/build/smart-contracts/objects/:page", + destination: "/en/build/smart-contracts/object/:page", + permanent: true, + }, + { + source: "/en/build/smart-contracts/objects", + destination: "/en/build/smart-contracts/move-objects", + permanent: true, + }, + { + source: "/en/build/smart-contracts/object", + destination: "/en/build/smart-contracts/move-objects", + permanent: true, + }, ], }), ); diff --git a/apps/nextra/pages/en/build/get-started/solana-cheatsheet.mdx b/apps/nextra/pages/en/build/get-started/solana-cheatsheet.mdx index 166c494f7..c8fa44054 100644 --- a/apps/nextra/pages/en/build/get-started/solana-cheatsheet.mdx +++ b/apps/nextra/pages/en/build/get-started/solana-cheatsheet.mdx @@ -11,7 +11,7 @@ To learn more about the differences and similarities see [Aptos Learn](https://l | **Smart Contracts** | Rust, SVM | Move, MoveVM | | **Transaction Fees** | Low | Low | | **Parallelization** | Pessimistic parallelism, need to declare all write accounts | Optimistic parallelism, chain infers write accounts for you | -| **Contract Account Support** | PDA Account | [Object](../smart-contracts/objects.mdx) or [resource account](../smart-contracts/resource-accounts.mdx)(encourage to use object instead) | +| **Contract Account Support** | PDA Account | [Object](../smart-contracts/move-objects.mdx) or [resource account](../smart-contracts/resource-accounts.mdx)(encourage to use object instead) | | **Data Storage** | Data stored in account owned by programs | Data stored as resource under user account or object | | **Storage Level** | Program level | Global when stored under object | | **Storage Mindset** | User data stored distributedly under account | User data stored distributedly under object | @@ -21,4 +21,4 @@ To learn more about the differences and similarities see [Aptos Learn](https://l | **Dispatch Type** | Static dispatch | Static dispatch | | **FT Standards** | Token program | [Coin](../smart-contracts/aptos-coin.mdx) (legacy) and [Fungible Asset Standard](../smart-contracts/fungible-asset.mdx) | | **NFT Standards** | Token program | [Digital Asset Standard](../smart-contracts/digital-asset.mdx) | -| **Blockchain Interaction** | Solana web3.js library | [Aptos Typescript SDK](../sdks/ts-sdk.mdx) | \ No newline at end of file +| **Blockchain Interaction** | Solana web3.js library | [Aptos Typescript SDK](../sdks/ts-sdk.mdx) | diff --git a/apps/nextra/pages/en/build/guides/your-first-nft.mdx b/apps/nextra/pages/en/build/guides/your-first-nft.mdx index ca5634f45..a1dedc713 100644 --- a/apps/nextra/pages/en/build/guides/your-first-nft.mdx +++ b/apps/nextra/pages/en/build/guides/your-first-nft.mdx @@ -529,7 +529,7 @@ async def mint_token( ### Step 4.6: Reading token and collection metadata -Both the collection and token assets are [Objects](../smart-contracts/objects.mdx) on-chain with unique addresses. Their metadata is stored at the object address. The SDKs provide convenience wrappers around querying this data: +Both the collection and token assets are [Objects](../smart-contracts/move-objects.mdx) on-chain with unique addresses. Their metadata is stored at the object address. The SDKs provide convenience wrappers around querying this data: diff --git a/apps/nextra/pages/en/build/smart-contracts.mdx b/apps/nextra/pages/en/build/smart-contracts.mdx index 2cff9563a..d3234eee4 100644 --- a/apps/nextra/pages/en/build/smart-contracts.mdx +++ b/apps/nextra/pages/en/build/smart-contracts.mdx @@ -13,7 +13,7 @@ export async function getStaticProps() { # Smart Contracts on Aptos -Aptos contracts are written using Move, a next generation language for secure, sandboxed, and formally verified programming which is used for multiple chains. +Aptos contracts are written using Move, a next generation language for secure, sandboxed, and formally verified programming which is used for multiple chains. Move allows developers to write programs that flexibly manage and transfer assets while providing security and protections against attacks on those assets. ## 📖 Learn Move @@ -31,7 +31,7 @@ Move allows developers to write programs that flexibly manage and transfer asset Create Package Get started by learning how to create a Move package - + Objects Learn how to use the Object standard on Aptos to create composable and flexible primitives on chain @@ -56,8 +56,8 @@ Move allows developers to write programs that flexibly manage and transfer asset Here is a `hello_blockchain` example of move - ## ⚒️ Developer Resources diff --git a/apps/nextra/pages/en/build/smart-contracts/_meta.tsx b/apps/nextra/pages/en/build/smart-contracts/_meta.tsx index 80538aa6c..47314fe19 100644 --- a/apps/nextra/pages/en/build/smart-contracts/_meta.tsx +++ b/apps/nextra/pages/en/build/smart-contracts/_meta.tsx @@ -23,7 +23,7 @@ export default { type: "separator", title: "Aptos Standards", }, - objects: { + object: { title: "Object", }, "digital-asset": { @@ -49,8 +49,7 @@ export default { table: { title: "Table", }, - "aptos-objects": { - href: "/en/build/smart-contracts/objects", + "move-objects": { title: "Objects", }, "resource-accounts": { diff --git a/apps/nextra/pages/en/build/smart-contracts/aptos-standards.mdx b/apps/nextra/pages/en/build/smart-contracts/aptos-standards.mdx index cdceb9854..6b5da9ea3 100644 --- a/apps/nextra/pages/en/build/smart-contracts/aptos-standards.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/aptos-standards.mdx @@ -11,7 +11,7 @@ on Aptos provided by hippospace. ## Move Standards -### [Aptos Object](objects.mdx) +### [Aptos Object](move-objects.mdx) The [Object model](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-framework/sources/object.move) allows Move to represent a complex type as a set of resources stored within a diff --git a/apps/nextra/pages/en/build/smart-contracts/deployment.mdx b/apps/nextra/pages/en/build/smart-contracts/deployment.mdx index 0868998df..2f99b5629 100644 --- a/apps/nextra/pages/en/build/smart-contracts/deployment.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/deployment.mdx @@ -4,7 +4,7 @@ title: "Object Code Deployment" # Object Code Deployment -This document goes through how you can deploy code to [Objects](objects.mdx). This is the recommended way to deploy code to the blockchain, as this reduces deployment complexity, +This document goes through how you can deploy code to [Objects](move-objects.mdx). This is the recommended way to deploy code to the blockchain, as this reduces deployment complexity, and safely manages access control policies for the code owner. Note that in this context, code refers to [packages](book/packages.mdx). Deploying code to objects will guarantee the following: diff --git a/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx b/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx index 6071f940b..a623fad40 100644 --- a/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx @@ -13,11 +13,11 @@ This standard replaces the legacy [Aptos Token Standard](aptos-token.mdx). The m | **Improvement** | **Description** | |-----------------|-----------------| -| **Token Extension** | Tokens can be easily extended since they are implemented using Move [Objects](objects.mdx). | +| **Token Extension** | Tokens can be easily extended since they are implemented using Move [Objects](move-objects.mdx). | | **Direct NFT Transfer** | You can now directly transfer NFTs without the recipient “opting-in” on-chain. | | **NFT Composability** | NFTs can own other NFTs for easy composability. | -If you want a simple way to mint NFTs without the ability to customize or extend their functionality, you can use the `aptos_token` module which implements the DA standard (see the section on how to use it below). +If you want a simple way to mint NFTs without the ability to customize or extend their functionality, you can use the `aptos_token` module which implements the DA standard (see the section on how to use it below). Note that all Digital Asset modules are deployed at the reserved address `0x4`. @@ -64,7 +64,7 @@ use std::option::{Self, Option}; public entry fun create_collection(creator: &signer) { let max_supply = 1000; let royalty = option::none(); - + // Maximum supply cannot be changed after collection creation collection::create_fixed_collection( creator, @@ -102,7 +102,7 @@ A `Collection`'s maximum supply cannot be changed after creation. ### Customizing a `Collection` -Since each `Collection` is a [Move Object](objects.mdx), you can customize it by generating permissions called `Ref`s. Each `Ref` allows you to modify an aspect of the Object later on. Beyond the normal [Object Refs](objects/creating-objects.mdx), `Collection`s can also get a `MutatorRef` by calling `get_mutator_ref` like so: +Since each `Collection` is a [Move Object](move-objects.mdx), you can customize it by generating permissions called `Ref`s. Each `Ref` allows you to modify an aspect of the Object later on. Beyond the normal [Object Refs](object/creating-objects.mdx), `Collection`s can also get a `MutatorRef` by calling `get_mutator_ref` like so: ```move filename="example.move" use std::option::{Self, Option}; @@ -160,12 +160,12 @@ public entry fun create_collection(creator: &signer) { | **Royalty** | An optional [`Royalty`](https://aptos.dev/reference/move/?branch=mainnet&page=aptos-token-objects/doc/royalty.md#0x4_royalty_Royalty) struct indicating what % of the sale price goes to the creator of the `Collection`. This can be changed with a `MutatorRef` generated by the [Royalty module](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/royalty.move) (an extension for the DA standard. See example usage in [`aptos_token.move`](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/aptos_token.move)). Usually royalty is set on collections, but setting it on `Token`s allows the individual `Token` to have a custom royalty amount. | | **URI length** | An optional string that is smaller than 512 characters which links to relevant content for the `Collection` (modifiable with a `MutatorRef`). | -### Creating Tokens +### Creating Tokens There are a few ways to create a `Token`: 1. Named tokens. These use the name of the `Token` to generate a named Object. This makes it easy to find the address for the token if you know the token and `Collection` name, but named Objects are not deletable. Trying to delete the a named token will only delete the data, not the Object itself. - + ```move filename="example.move" use aptos_token_objects::token; use std::option::{Self, Option}; @@ -182,15 +182,15 @@ public entry fun mint_token(creator: &signer) { ); } ``` - + You can derive the address for named tokens by: 1. Concatenating the creator address, collection name and token name. 2. Doing a sha256 hash of that new string. - + 2. “Unnamed” tokens. These create unnamed *Objects* (which **are** deletable) but still have a `Token` name. Because the Object address is not deterministic, you must use an Indexer to find the address for them. - + ```move filename="example.move" use aptos_token_objects::token; use std::option::{Self, Option}; @@ -206,13 +206,13 @@ public entry fun mint_token(creator: &signer) { "https://mycollection.com/my-named-token.jpeg", ); } -``` +``` ### Finding Unnamed Token Addresses via Indexer You can find the addresses of your recently created “unnamed” `Token`s by using the [Aptos Indexer](../indexer/aptos-hosted.mdx) with queries like the following: -1. Looking up the collection id by using your account address and the name of the `Collection`. +1. Looking up the collection id by using your account address and the name of the `Collection`. - + In general, using unnamed tokens give you the most flexibility because the Object can be deleted later, but named tokens simplify looking up addresses. @@ -256,7 +256,7 @@ In general, using unnamed tokens give you the most flexibility because the Objec #### Transfer Tokens Transferring a `Token` can be done by calling [`object::transfer`](https://aptos.dev/reference/move/?branch=mainnet&page=aptos-framework/doc/object.md#0x1_object_transfer). - + ```move filename="example.move" public entry fun transfer(owner: &signer, object: object::Object, to: address) ``` @@ -264,7 +264,7 @@ public entry fun transfer(owner: &signer, object: object::Object, to: #### Burning Tokens Burning / deleting a `Token` requires storing a `BurnRef` with `token::generate_burn_ref`, then calling `token::burn`. - + ```move filename="example.move" use std::option::{Self, Option}; @@ -292,7 +292,7 @@ public entry fun burn_token(token: Object) { token::burn(burn_ref); } ``` - + If any custom resources were moved onto the Token, those must be removed / deleted first before`token::burn` can delete the Token. For named tokens which cannot be deleted, `token::burn` will For named Tokens `token::burn` will remove all Token content instead. @@ -300,7 +300,7 @@ If any custom resources were moved onto the Token, those must be removed / delet #### Modifying Tokens After Creation Mutating a `Token`’s `URI` or `description` requires a `MutatorRef` (which must be generated when creating the `Token`, then stored for later). - + ```move filename="example.move" use std::option::{Self, Option}; @@ -320,7 +320,7 @@ public entry fun mint_token(creator: &signer) { // Store the mutator ref somewhere safe } ``` - + Changing the royalty requires generating a *separate* `MutatorRef` from the [Royalty module](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/royalty.move). @@ -345,9 +345,9 @@ The main drawback of using the `aptos_token` module is that the Tokens are not e ### Minting with `aptos_token` -Minting a `Token` using `aptos_token` requires the same parameters as any token that implements the DA standard. In addition though, the `aptos_token` module allows you to specificy a property map of key/value pairs for any other properties your specific NFT may require. +Minting a `Token` using `aptos_token` requires the same parameters as any token that implements the DA standard. In addition though, the `aptos_token` module allows you to specificy a property map of key/value pairs for any other properties your specific NFT may require. -You can mint your `Token` by calling `aptos_token::mint` like so: +You can mint your `Token` by calling `aptos_token::mint` like so: ```move filename="example.move" public entry fun mint( @@ -362,7 +362,7 @@ public entry fun mint( ) acquires AptosCollection, AptosToken ``` -#### Soulbound Tokens +#### Soulbound Tokens To mint a soul bound `Token`, you can call [`aptos_token::mint_soul_bound`](https://aptos.dev/reference/move/?branch=mainnet&page=aptos-token-objects/doc/aptos_token.md#0x4_aptos_token_mint_soul_bound) instead: @@ -389,4 +389,4 @@ In the near future, a new module `TokenMinter` will be released to replace `apto - [Digital Asset Examples](https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples/token_objects) - [Digital Asset Marketplace Example](https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples/marketplace) - [Source code](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/token.move) -- [`aptos_token` source code](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/aptos_token.move) \ No newline at end of file +- [`aptos_token` source code](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/aptos_token.move) diff --git a/apps/nextra/pages/en/build/smart-contracts/fungible-asset.mdx b/apps/nextra/pages/en/build/smart-contracts/fungible-asset.mdx index 17a1ab910..3d9d82909 100644 --- a/apps/nextra/pages/en/build/smart-contracts/fungible-asset.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/fungible-asset.mdx @@ -8,11 +8,11 @@ import { ThemedImage } from "@components/index"; # Aptos Fungible Asset (FA) Standard -The Aptos Fungible Asset Standard (also known as “Fungible Asset” or “FA”) provides a standard, type-safe way to define fungible assets in the Move ecosystem. It is a modern replacement for the `coin` module that allows for seamless minting, transfer, and customization of fungible assets for any use case. +The Aptos Fungible Asset Standard (also known as “Fungible Asset” or “FA”) provides a standard, type-safe way to define fungible assets in the Move ecosystem. It is a modern replacement for the `coin` module that allows for seamless minting, transfer, and customization of fungible assets for any use case. -This standard is important because it allows fungible assets on Aptos (such as Currencies and Real World Assets (RWAs)) to represent and transfer ownership in a consistent way dApps can recognize. This standard also allows for more extensive customization than the `coin` module did by leveraging [Move Objects](objects.mdx) to represent fungible asset data. +This standard is important because it allows fungible assets on Aptos (such as Currencies and Real World Assets (RWAs)) to represent and transfer ownership in a consistent way dApps can recognize. This standard also allows for more extensive customization than the `coin` module did by leveraging [Move Objects](move-objects.mdx) to represent fungible asset data. -The FA standard provides all the functionality you need to create, mint, transfer, and burn fungible assets (as well as automatically allowing recipients of the fungible asset to store and manage any fungible assets they receive). +The FA standard provides all the functionality you need to create, mint, transfer, and burn fungible assets (as well as automatically allowing recipients of the fungible asset to store and manage any fungible assets they receive). It does so by using two Move Objects: @@ -29,7 +29,7 @@ sources={{ }} /> -[This implementation](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-framework/sources/fungible_asset.move) is an improvement on the `coin` Standard because Move Objects are more customizable and extensible via smart contract. See the advanced guides on writing [Move Objects](objects.mdx) for more details. +[This implementation](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-framework/sources/fungible_asset.move) is an improvement on the `coin` Standard because Move Objects are more customizable and extensible via smart contract. See the advanced guides on writing [Move Objects](move-objects.mdx) for more details. The FA standard also automatically handles tracking how much of a fungible asset an account owns, as opposed to requiring the recipient to register a `CoinStore` resource separate from the transfer. ## Creating a new Fungible Asset (FA) @@ -40,11 +40,11 @@ At a high level, this is done by: 2. Generating `Ref`s to enable any desired permissions. 3. Minting Fungible Assets and transferring them to any account you want to. -To start with, the Fungible Asset standard is implemented using Move Objects. Objects by default are transferable, can own multiple resources, and can be customized via smart contract. For full details on Objects and how they work, please read [this guide](objects.mdx). +To start with, the Fungible Asset standard is implemented using Move Objects. Objects by default are transferable, can own multiple resources, and can be customized via smart contract. For full details on Objects and how they work, please read [this guide](move-objects.mdx). To create an FA, first you need to create a **non-deletable Object** since destroying the metadata for a Fungible Asset while there are active balances would not make sense. You can do that by either calling `object::create_named_object(caller_address, NAME)` or `object::create_sticky_object(caller_address)` to create the Object on-chain. -When you call these functions, they will return a `ConstructorRef`. `Ref`s allow Objects to be customized immediately after they are created. You can use the `ConstructorRef` to generate other permissions that may be needed based on your use case. +When you call these functions, they will return a `ConstructorRef`. `Ref`s allow Objects to be customized immediately after they are created. You can use the `ConstructorRef` to generate other permissions that may be needed based on your use case. Note that the `ConstructorRef` cannot be stored and is destroyed by the end of the transaction used to create this Object, so any `Ref`s must be generated during Object creation. @@ -52,12 +52,12 @@ Note that the `ConstructorRef` cannot be stored and is destroyed by the end of t One use for the `ConstructorRef` is to generate the FA `Metadata` Object. The standard provides a generator function called `primary_fungible_store::create_primary_store_enabled_fungible_asset` which will allow your fungible asset to be transferred to any account. This method makes it so the primary `FungibleStore` for recipients is automatically created or re-used so you don’t need to create or index the store directly. -This is what `create_primary_store_enabled_fungible_asset` looks like: +This is what `create_primary_store_enabled_fungible_asset` looks like: ```move filename="example.move" public fun create_primary_store_enabled_fungible_asset( constructor_ref: &ConstructorRef, - // This ensures total supply does not surpass this limit - however, + // This ensures total supply does not surpass this limit - however, // Setting this will prevent any parallel execution of mint and burn. maximum_supply: Option, // The fields below here are purely metadata and have no impact on-chain. @@ -73,7 +73,7 @@ public fun create_primary_store_enabled_fungible_asset( Alternatively, you can use `add_fungibility` which uses the same parameters, but requires recipients to keep track of their `FungibleStore` addresses to keep track of how many units of your FA they have. -Once you have created the Metadata, you can also use the `ConstructorRef` to generate additional `Ref`s. In addition to the usual [Object Refs](objects/creating-objects.mdx), FAs define three additional permissions you can generate: +Once you have created the Metadata, you can also use the `ConstructorRef` to generate additional `Ref`s. In addition to the usual [Object Refs](object/creating-objects.mdx), FAs define three additional permissions you can generate: 1. `MintRef` offers the capability to mint new FA units. 2. `TransferRef` offers the capability to freeze accounts from transferring this FA, or to bypass an existing freeze. (This can be important when trying to be compliant with some regulations). @@ -94,7 +94,7 @@ module my_addr::fungible_asset_example { use std::signer; use std::string::utf8; use std::option; - + const ASSET_SYMBOL: vector = b"FA"; // Make sure the `signer` you pass in is an address you own. @@ -102,7 +102,7 @@ module my_addr::fungible_asset_example { entry fun init_module(admin: &signer) { // Creates a non-deletable object with a named address based on our ASSET_SYMBOL let constructor_ref = &object::create_named_object(admin, ASSET_SYMBOL); - + // Create the FA's Metadata with your name, symbol, icon, etc. primary_fungible_store::create_primary_store_enabled_fungible_asset( constructor_ref, @@ -113,7 +113,7 @@ module my_addr::fungible_asset_example { utf8(b"http://example.com/favicon.ico"), /* icon */ utf8(b"http://example.com"), /* project */ ); - + // Generate the MintRef for this object // Used by fungible_asset::mint() and fungible_asset::mint_to() let mint_ref = fungible_asset::generate_mint_ref(constructor_ref); @@ -126,7 +126,7 @@ module my_addr::fungible_asset_example { // Generate the BurnRef for this object // Used by fungible_asset::burn() and fungible_asset::burn_from() let burn_ref = fungible_asset::generate_burn_ref(constructor_ref); - + // Add any other logic required for your use case. // ... } @@ -134,7 +134,7 @@ module my_addr::fungible_asset_example { ``` -For a full example of how to create your own Fungible Asset module, please see [fa_coin.move](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/move-examples/fungible_asset/fa_coin/sources/FACoin.move). +For a full example of how to create your own Fungible Asset module, please see [fa_coin.move](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/move-examples/fungible_asset/fa_coin/sources/FACoin.move). Alternatively, you can explore the collection of [FA example code here](https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples/fungible_asset). @@ -207,27 +207,27 @@ public primary_fungible_store::fun is_frozen(account: address, metadata: FAs have three events emitted from the above basic functions: 1. `Deposit`: Emitted when FAs are deposited into a store. - + ```move filename="deposit_event" struct Deposit has drop, store { store: address, amount: u64, } ``` - + 2. `Withdraw`: Emitted when FAs are withdrawn from a store. - + ```move filename="withdraw_event" struct Withdraw has drop, store { store: address, amount: u64, } ``` - + 3. `Frozen`: Emitted when the frozen status of a fungible store is updated. - + ```move filename="frozen_event" -struct Frozen has drop, store { +struct Frozen has drop, store { store: address, frozen: bool, } @@ -313,11 +313,11 @@ module my_addr::my_fungible_asset_example { fun create_fungible_asset(module_signer: &signer, /* ... */) { // Make the deposit override function info let deposit_override = dispatchable_fungible_asset::new_function_info( - module_signer, - string::utf8(b"example"), + module_signer, + string::utf8(b"example"), string::utf8("deposit") ); - + // Create the fungible asset let constructor_ref = object::create_sticky_object( /* ... */); @@ -360,7 +360,7 @@ You can look up a primary store via the following function: public fun primary_store(owner: address, metadata: Object): Object ``` -And if you want to create a primary store manually you can use this function: +And if you want to create a primary store manually you can use this function: ```move filename="create_primary_store" public fun create_primary_store(owner_addr: address, metadata: Object): Object @@ -372,11 +372,11 @@ To create a secondary store, you must: 1. Create an Object to get its `ConstructorRef`. 2. Call: - + ```move filename="create_store" public fun create_store(constructor_ref: &ConstructorRef, metadata: Object): Object ``` - + This will create a secondary store owned by the newly created Object. Sometimes an object can be reused as a store. For example, a metadata object can also be a store to hold some FA of its own type or a liquidity pool object can be a store of the issued liquidity pool's coin. @@ -410,7 +410,7 @@ public fun paired_coin(metadata: Object): Option ### Off-chain Migration -There are two changes needed for off-chain services: +There are two changes needed for off-chain services: 1. Balances should reflect that a user may have **both** a `coin` balance and a paired FA balance. 2. Event listeners should listen for both `coin` and FA events. diff --git a/apps/nextra/pages/en/build/smart-contracts/objects.mdx b/apps/nextra/pages/en/build/smart-contracts/move-objects.mdx similarity index 94% rename from apps/nextra/pages/en/build/smart-contracts/objects.mdx rename to apps/nextra/pages/en/build/smart-contracts/move-objects.mdx index 846df2b0c..b2e72574b 100644 --- a/apps/nextra/pages/en/build/smart-contracts/objects.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/move-objects.mdx @@ -52,8 +52,8 @@ For example, you could use an Object to represent a soulbound NFT by making it o ## Learn how to -- [Create and configure a new Object.](objects/creating-objects.mdx) -- [Use Objects you created.](objects/using-objects.mdx) +- [Create and configure a new Object.](object/creating-objects.mdx) +- [Use Objects you created.](object/using-objects.mdx) ## Examples with Object contracts diff --git a/apps/nextra/pages/en/build/smart-contracts/move-security-guidelines.mdx b/apps/nextra/pages/en/build/smart-contracts/move-security-guidelines.mdx index 08b70b0e4..fa03ce22b 100644 --- a/apps/nextra/pages/en/build/smart-contracts/move-security-guidelines.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/move-security-guidelines.mdx @@ -437,7 +437,7 @@ Bad operations could unexpectedly alter the correct execution of the smart contr ### ConstructorRef leak -When creating objects ensure to never expose the object’s `ConstructorRef` as it allows adding resources to an object. A `ConstructorRef` can also be used to generate other capabilities (or "Refs") that are used to alter or transfer the ownership the object. [Read more](objects/creating-objects.mdx) about Objects capabilities. +When creating objects ensure to never expose the object’s `ConstructorRef` as it allows adding resources to an object. A `ConstructorRef` can also be used to generate other capabilities (or "Refs") that are used to alter or transfer the ownership the object. [Read more](object/creating-objects.mdx) about Objects capabilities. #### Example Vulnerable code @@ -490,7 +490,7 @@ However, objects should be isolated to different account, otherwise modification For example, transferring one resource implies the transfer of all group members, since the transfer function operates on `ObjectCore`, which is essentially a general tag for all resources at the account. -[Read more](objects.mdx) about Aptos Objects. +[Read more](move-objects.mdx) about Aptos Objects. #### Example Insecure Code @@ -827,4 +827,4 @@ There are different ways to secure the code: 2. Allow only admin addresses to invoke the randomness API. 3. Ensure entry functions work regardless of random outcomes. This can be handled by committing the random result, then using the random result to provide the action in a different transaction. Avoid immediate actions based on randomness for consistent gas use. -> We will be providing more functionality in the future, to allow for more complex code to be able to be safe against undergasing attacks. \ No newline at end of file +> We will be providing more functionality in the future, to allow for more complex code to be able to be safe against undergasing attacks. diff --git a/apps/nextra/pages/en/build/smart-contracts/objects/_meta.tsx b/apps/nextra/pages/en/build/smart-contracts/object/_meta.tsx similarity index 100% rename from apps/nextra/pages/en/build/smart-contracts/objects/_meta.tsx rename to apps/nextra/pages/en/build/smart-contracts/object/_meta.tsx diff --git a/apps/nextra/pages/en/build/smart-contracts/objects/creating-objects.mdx b/apps/nextra/pages/en/build/smart-contracts/object/creating-objects.mdx similarity index 99% rename from apps/nextra/pages/en/build/smart-contracts/objects/creating-objects.mdx rename to apps/nextra/pages/en/build/smart-contracts/object/creating-objects.mdx index 892a82eb4..d4fa6c547 100644 --- a/apps/nextra/pages/en/build/smart-contracts/objects/creating-objects.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/object/creating-objects.mdx @@ -1,8 +1,8 @@ --- title: "Creating objects" --- -import { Callout } from 'nextra/components' +import { Callout } from 'nextra/components' # Creating and Configuring Objects @@ -16,7 +16,7 @@ Creating an Object involves two steps: transaction you create it. Later on it is impossible to change those settings. -### Creating an Object +## Creating an Object There are three types of Object you can create: @@ -71,7 +71,7 @@ module my_addr::object_playground { } ``` -# Customizing Object Features +## Customizing Object Features Once you create your object, you will receive a `ConstructorRef` you can use to generate additional `Ref`s. `Ref`s can be used in future to enable / disable / execute certain Object functions such as transferring resources, transferring the object itself, or deleting the Object. @@ -363,7 +363,7 @@ module my_addr::object_playground { } ``` -## **Allowing Deletion of an Object (`DeleteRef`)** +## Allowing Deletion of an Object (`DeleteRef`) For Objects created with the default method (allowing deletion) you can generate a `DeleteRef` which can be used later. This can help remove clutter as well as receive a storage refund. @@ -432,7 +432,7 @@ module my_addr::object_playground { An object can be made immutable by making the contract associated immutable, and removing any ability to extend or mutate the object. By default, contracts are not immutable, and objects can be extended with an `ExtendRef`, and resources can be mutated if the contract allows for it. -# Further Reading +## Further Reading You can find documentation for all possible `Refs` by looking at the Move reference docs for `0x1::object` [here](https://aptos.dev/reference/move?branch=mainnet&page=aptos-framework/doc/object.md). diff --git a/apps/nextra/pages/en/build/smart-contracts/objects/using-objects.mdx b/apps/nextra/pages/en/build/smart-contracts/object/using-objects.mdx similarity index 100% rename from apps/nextra/pages/en/build/smart-contracts/objects/using-objects.mdx rename to apps/nextra/pages/en/build/smart-contracts/object/using-objects.mdx diff --git a/apps/nextra/pages/en/build/smart-contracts/tokens.mdx b/apps/nextra/pages/en/build/smart-contracts/tokens.mdx index fbb8ed706..9a7ee281d 100644 --- a/apps/nextra/pages/en/build/smart-contracts/tokens.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/tokens.mdx @@ -9,7 +9,7 @@ canonical Non-fungible Token on Aptos. Aptos leverages composability to extend the digital asset standard with features like fungibility via the [Fungible Asset standard](fungible-asset.mdx). The concept of composability comes from the underlying data model for these constructs: -the [Move object](objects.mdx) data model. +the [Move object](move-objects.mdx) data model. The rest of this document discusses how the Aptos token standards compare to the standards on Ethereum and Solana. @@ -52,7 +52,7 @@ and data. Unlike Ethereum, the associated data of a smart contract is distributed across the space of all accounts in [resources](../../network/blockchain/resources.mdx) within [accounts](../../network/blockchain/accounts.mdx) -or [objects](objects.mdx). For example, a collection and an +or [objects](move-objects.mdx). For example, a collection and an NFT within that collection are stored in distinct objects at different addresses with the smart contract defining them at another address. A smart contract developer could also store data associated with the NFT and collection at the diff --git a/apps/nextra/pages/en/network/blockchain/accounts.mdx b/apps/nextra/pages/en/network/blockchain/accounts.mdx index 89534ea1b..ed293d098 100755 --- a/apps/nextra/pages/en/network/blockchain/accounts.mdx +++ b/apps/nextra/pages/en/network/blockchain/accounts.mdx @@ -22,7 +22,7 @@ There are three types of accounts on Aptos: - _Standard account_ - This is a typical account corresponding to an address with a corresponding pair of public/private keys. - [_Resource account_](../../build/smart-contracts/resource-accounts.mdx) - An autonomous account without a corresponding private key used by developers to store resources or publish modules on-chain. -- [_Object_](../../build/smart-contracts/objects.mdx) - A complex set of resources stored within a single address representing a single entity. +- [_Object_](../../build/smart-contracts/move-objects.mdx) - A complex set of resources stored within a single address representing a single entity. Account addresses are 32-bytes. They are usually shown as 64 hex characters, with each hex character a nibble.