From b28d18c230524de06724939338f02a874502d584 Mon Sep 17 00:00:00 2001 From: Clay Murphy <114445310+clay-aptos@users.noreply.github.com> Date: Wed, 7 Dec 2022 11:43:27 -0800 Subject: [PATCH 1/3] Make resource accounts not dependent on Mint NFT --- .../docs/guides/resource-accounts.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/developer-docs-site/docs/guides/resource-accounts.md b/developer-docs-site/docs/guides/resource-accounts.md index 722882f69a809..6f67ad0cd4204 100644 --- a/developer-docs-site/docs/guides/resource-accounts.md +++ b/developer-docs-site/docs/guides/resource-accounts.md @@ -18,14 +18,17 @@ In Aptos, a resource account is created based upon the SHA3-256 hash of the sour ## Setup -To properly set a resource account up, you will need to [initialize](https://github.com/aptos-labs/aptos-core/blob/2e9d8ee759fcd3f6e831034f05c1656b1c48efc4/aptos-move/move-examples/mint_nft/sources/minting.move#L73) the `mint_nft` module and retrieve the signer capability from both the resource account and module account. To do so, call `create_resource_account_and_publish_package` to publish the module under the resource account's address. +The easiest way to set up a resource account is by: -You have three options for creating a resource account: -* `create_resource_account_and_publish_package` - creates the resource account and results in loss of access to the resource account by design, because resource accounts are used to make contracts autonomous and immutable. -* `create_resource_account_and_fund` - creates the resource account and funds it, retaining access to the resource account's signer until explicitly calling `retrieve_resource_account_cap`. +1. Using Aptos CLI: `aptos account create-resource-account` creates a resource account, and `aptos move create-resource-account-and-publish-package` creates a resource account and publishes the specified package under the resource account's adddress. +1. Writing custom smart contracts code: in the `resource_account.move` module, developers can find the resource account creation functions `create_resource_account`, `create_resource_account_and_fund`, and `create_resource_account_and_publish_package`. Developers can then call those functions to create resource accounts in their smart contracts. + +Each of those options offers slightly different functionality: * `create_resource_account` - merely creates the resource account but doesn't fund it, retaining access to the resource account's signer until explicitly calling `retrieve_resource_account_cap`. +* `create_resource_account_and_fund` - creates the resource account and funds it, retaining access to the resource account's signer until explicitly calling `retrieve_resource_account_cap`. +* `create_resource_account_and_publish_package` - creates the resource account and results in loss of access to the resource account by design, because resource accounts are used to make contracts autonomous and immutable. -Follow these steps and examples, which assume use of `create_resource_account_and_publish_package`: +In this example, you will [initialize](https://github.com/aptos-labs/aptos-core/blob/2e9d8ee759fcd3f6e831034f05c1656b1c48efc4/aptos-move/move-examples/mint_nft/sources/minting.move#L73) the `mint_nft` module and retrieve the signer capability from both the resource account and module account. To do so, call `create_resource_account_and_publish_package` to publish the module under the resource account's address. 1. Initialize the module as shown in the [`minting.move`](https://github.com/aptos-labs/aptos-core/blob/2e9d8ee759fcd3f6e831034f05c1656b1c48efc4/aptos-move/move-examples/mint_nft/sources/minting.move#L73) example. 1. Call `create_resource_account_and_publish_package` to publish the module under the resource account's address, such as in the [`mint_nft.rs`](https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/e2e-move-tests/src/tests/mint_nft.rs#L62) end-to-end example. From b3c879e8776ad01cfc5109e29782b56196a5579a Mon Sep 17 00:00:00 2001 From: Clay Murphy <114445310+clay-aptos@users.noreply.github.com> Date: Wed, 7 Dec 2022 12:28:50 -0800 Subject: [PATCH 2/3] Add clarification from Wolfgang Addressing Christian's issue in: https://github.com/aptos-labs/aptos-core/issues/5672 --- developer-docs-site/docs/guides/resource-accounts.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/developer-docs-site/docs/guides/resource-accounts.md b/developer-docs-site/docs/guides/resource-accounts.md index 6f67ad0cd4204..3187acecad42a 100644 --- a/developer-docs-site/docs/guides/resource-accounts.md +++ b/developer-docs-site/docs/guides/resource-accounts.md @@ -14,7 +14,9 @@ Typically, a resource account is used for two main purposes: ## Restrictions -In Aptos, a resource account is created based upon the SHA3-256 hash of the source's address and additional seed data. A resource account can be created only once. An entity may call `create_account` in an attempt to claim an account ahead of the creation of a resource account. But if a resource account is found, Aptos will transition ownership of the account over to the resource account. This is done by validating that the account has yet to execute any transactions and that the `Account::signer_capbility_offer::for` is none. The probability of a collision where someone has legitimately produced a private key that maps to a resource account address is improbably low. +In Aptos, a resource account is created based upon the SHA3-256 hash of the source's address and additional seed data. A resource account can be created only once; for a given source address and seed, there can be only one resource account. That is because the calculation of the resource account address is fully determined by the former. + +An entity may call `create_account` in an attempt to claim an account ahead of the creation of a resource account. But if a resource account is found, Aptos will transition ownership of the account over to the resource account. This is done by validating that the account has yet to execute any transactions and that the `Account::signer_capbility_offer::for` is none. The probability of a collision where someone has legitimately produced a private key that maps to a resource account address is improbably low. ## Setup From f5484d721605a32ef39049fb6b81bd3d54360734 Mon Sep 17 00:00:00 2001 From: Clay Murphy Date: Thu, 8 Dec 2022 15:27:28 -0800 Subject: [PATCH 3/3] Add SHA to spellcheck dictionary --- developer-docs-site/scripts/additional_dict.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/developer-docs-site/scripts/additional_dict.txt b/developer-docs-site/scripts/additional_dict.txt index 7df860eff63a2..efe33d6f7225f 100644 --- a/developer-docs-site/scripts/additional_dict.txt +++ b/developer-docs-site/scripts/additional_dict.txt @@ -164,6 +164,7 @@ STM SYNACK Scalable SeaLevel +SHA SignMessagePayload SignerCap Skylake