Skip to content

Commit

Permalink
update "aptos-objects" to "object" and update references
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-p committed Oct 25, 2024
1 parent 3bea2e1 commit 2d5306f
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 72 deletions.
4 changes: 2 additions & 2 deletions apps/nextra/components/landing/sections/MoveSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
"
>
<div className="flex flex-col gap-8 md:gap-12 max-md:mb-8 max-lg:mb-12 px-8 lg:px-0">
Expand Down
29 changes: 17 additions & 12 deletions apps/nextra/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -1748,14 +1748,19 @@ export default withBundleAnalyzer(
},
{
source: "/en/build/smart-contracts/objects/:page",
destination: "/en/build/smart-contracts/aptos-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,
}
],
}),
);
4 changes: 2 additions & 2 deletions apps/nextra/pages/en/build/get-started/solana-cheatsheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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) |
| **Blockchain Interaction** | Solana web3.js library | [Aptos Typescript SDK](../sdks/ts-sdk.mdx) |
2 changes: 1 addition & 1 deletion apps/nextra/pages/en/build/guides/your-first-nft.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<Tabs items={["TypeScript", "Python"]}>
<Tabs.Tab>
Expand Down
8 changes: 4 additions & 4 deletions apps/nextra/pages/en/build/smart-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +31,7 @@ Move allows developers to write programs that flexibly manage and transfer asset
<Card.Title>Create Package</Card.Title>
<Card.Description>Get started by learning how to create a Move package</Card.Description>
</Card>
<Card href="smart-contracts/objects">
<Card href="smart-contracts/move-objects">
<Card.Title>Objects</Card.Title>
<Card.Description>Learn how to use the Object standard on Aptos to create composable and flexible primitives on chain</Card.Description>
</Card>
Expand All @@ -56,8 +56,8 @@ Move allows developers to write programs that flexibly manage and transfer asset

Here is a `hello_blockchain` example of move

<RemoteCodeblock
permalink="https://github.com/aptos-labs/aptos-core/blob/77e1d222ebc5e7294e115e0d090c001da1d0e072/aptos-move/move-examples/hello_blockchain/sources/hello_blockchain.move#L1-L59"
<RemoteCodeblock
permalink="https://github.com/aptos-labs/aptos-core/blob/77e1d222ebc5e7294e115e0d090c001da1d0e072/aptos-move/move-examples/hello_blockchain/sources/hello_blockchain.move#L1-L59"
/>

## ⚒️ Developer Resources
Expand Down
4 changes: 2 additions & 2 deletions apps/nextra/pages/en/build/smart-contracts/_meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default {
type: "separator",
title: "Aptos Standards",
},
"aptos-objects": {
title: "Objects",
"object": {
title: "Object",
},
"digital-asset": {
title: "Digital Asset (DA)",
Expand Down
40 changes: 20 additions & 20 deletions apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This standard replaces the legacy [Aptos Token Standard](aptos-token.mdx). The m
| **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).

<Callout type="info">
Note that all Digital Asset modules are deployed at the reserved address `0x4`.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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](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};
Expand Down Expand Up @@ -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};
Expand All @@ -182,15 +182,15 @@ public entry fun mint_token(creator: &signer) {
);
}
```

<Callout type="info">
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.
</Callout>

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};
Expand All @@ -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`.

<GraphQLEditor
query={`query GetCollectionIdByName($creatorAddress: String!, $collectionName: String!) {
Expand Down Expand Up @@ -246,7 +246,7 @@ You can find the addresses of your recently created “unnamed” `Token`s by us
"token_name": "Horse Emojis #127"
}`}
/>

<Callout type="info">
In general, using unnamed tokens give you the most flexibility because the Object can be deleted later, but named tokens simplify looking up addresses.
</Callout>
Expand All @@ -256,15 +256,15 @@ 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<T: key>(owner: &signer, object: object::Object<T>, to: address)
```

#### 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};
Expand Down Expand Up @@ -292,15 +292,15 @@ public entry fun burn_token(token: Object<Token>) {
token::burn(burn_ref);
}
```

<Callout type="warning">
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.
</Callout>

#### 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};
Expand All @@ -320,7 +320,7 @@ public entry fun mint_token(creator: &signer) {
// Store the mutator ref somewhere safe
}
```

<Callout type="warning">
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).
</Callout>
Expand All @@ -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(
Expand All @@ -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:

Expand All @@ -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)
- [`aptos_token` source code](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-token-objects/sources/aptos_token.move)
Loading

0 comments on commit 2d5306f

Please sign in to comment.