-
Notifications
You must be signed in to change notification settings - Fork 28
New vm2 example #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
New vm2 example #224
Changes from all commits
ee976e6
936e90b
262e097
78a070f
1db53e1
6215f41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Hello Blockchain | ||
|
|
||
| This section mainly introduces how developers can test and deploy a sample project on the Starcoin blockchain to verify | ||
| the blockchain's availability. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| The sample project is located in | ||
| the [hello-blockchain](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-examples/hello_blockchain) | ||
| repository. Please clone the Starcoin repository to your local machine and compile the following tools: | ||
|
|
||
| 1. [starcoin-cmd](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/cmd/starcoin): Used for connecting to | ||
| nodes. | ||
| 2. [move-package-manager2](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-package-manager): Used | ||
| for packaging Move modules. | ||
|
|
||
| Assuming the Starcoin binary has been compiled successfully, execute the following commands to connect to the Starcoin | ||
| console and package the project: | ||
|
|
||
| ```shell | ||
| # Connect to the Starcoin console, where <network> is the network name (e.g., dev, barnard, etc.) | ||
| starcoin -n <network> console | ||
|
|
||
| # View the node's sync progress; ensure the local node is fully synced before submitting test transactions | ||
| starcoin% node sync progress | ||
| ``` | ||
|
|
||
| ## Test Command Set | ||
|
|
||
| First, use `mpm2` to build the Blob binary package. Note that before packaging, you need to modify the module target | ||
| address in `Move.toml` to the deployment address, for example, `0x143e9f2175f92f51d9adaeee2b3d8bf0`. | ||
|
|
||
| ```shell | ||
| # Switch to the project directory | ||
| cd <work_dir>/starcoin/vm2/move-examples/hello-blockchain | ||
|
|
||
| # Execute the packaging command | ||
| mpm2 release | ||
|
|
||
| INCLUDING DEPENDENCY MoveStdlib | ||
| INCLUDING DEPENDENCY StarcoinFramework | ||
| INCLUDING DEPENDENCY StarcoinStdlib | ||
| BUILDING hello-blockchain | ||
|
|
||
| Packaging Modules: | ||
| 0x143e9f2175f92f51d9adaeee2b3d8bf0::message | ||
| Release done: release/hello-blockchain.v0.0.1.blob, package hash: 0x4c3ba39b4e716aa4d80b3697721107e39e8d6d9244a5ece3de4670335749b030 | ||
| ``` | ||
|
|
||
| Deploy and test the contract in the Starcoin console: | ||
|
|
||
| ```shell | ||
| # Deploy the contract; if the result shows "Executed", it indicates successful deployment | ||
| starcoin% dev deploy -s <work_dir>/starcoin/vm2/move-examples/hello-blockchain/release/hello-blockchain.v0.0.1.blob | ||
| txn 0x12481f66a05a56d93cb51d34e05c1815919ba6cea40ee073621f1d05a66341ac submitted. | ||
|
Comment on lines
+53
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify Run to locate inconsistencies and hard-coded absolute paths: 🏁 Script executed: #!/bin/bash
rg -nP -C1 'dev\s+deploy\b' docs i18n
rg -nP '/home/|\\Users\\' docs i18nLength of output: 10783 Unify dev deploy usage: -s is the sender address — fix flag misuse & remove hard-coded paths Starcoin docs show -s/--sender is the publisher/sender address; canonical usage is: dev deploy <blob_path> -s 0x... -b. (cookbook.starcoin.org)
🤖 Prompt for AI Agents |
||
| { | ||
| "ok": { | ||
| ... | ||
| "dry_run_output": { | ||
| "explained_status": "Executed", | ||
| "status": "Executed", | ||
| } | ||
| ... | ||
| } | ||
| } | ||
|
|
||
| # Set the message | ||
| starcoin% account execute-function -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::message::set_message --arg b"abcdefg" -b | ||
|
|
||
| # View the message; the result is the BCS encoding of "abcdefg" | ||
| starcoin% dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::message::get_message --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| { | ||
| "bytes": "0x61626364656667" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Resource Groups | ||
|
|
||
| This section explains how to test and deploy the `resource-groups` sample project on the Starcoin blockchain to test the | ||
| resource group functionality under VM2. The contract consists of two parts: the `primary` module tests the basic | ||
| functionality of resource groups, while the `secondary` module tests cross-module resource group references. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| The project is located in | ||
| the [resource-groups](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-examples/resource_groups) | ||
| repository. Please clone the Starcoin repository to your local machine and compile the following tools: | ||
|
|
||
| 1. [starcoin-cmd](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/cmd/starcoin): Used for connecting to | ||
| nodes. | ||
| 2. [move-package-manager2](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-package-manager): Used | ||
| for packaging Move modules. | ||
|
|
||
| Assuming the Starcoin binary has been compiled successfully, execute the following commands to connect to the Starcoin | ||
| console and package the project: | ||
|
|
||
| ```shell | ||
| # Connect to the Starcoin console, where <network> is the network name (e.g., dev, barnard, etc.) | ||
| starcoin -n <network> console | ||
|
|
||
| # View the node's sync progress; ensure the local node is fully synced before submitting test transactions | ||
| starcoin% node sync progress | ||
| There are no running sync tasks. | ||
| ``` | ||
|
|
||
| ## Test Command Set | ||
|
|
||
| ### Primary Module | ||
|
|
||
| ```shell | ||
| # Deploy the Primary module | ||
| dev deploy -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 <work_dir>/starcoin/vm2/move-examples/resource_groups/primary/release/ResourceGroupsPrimary.v0.0.1.blob | ||
|
|
||
| # Initialize the resource group with an initial value of 10000 | ||
| account execute-function --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::primary::init -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --arg 10000u64 -b | ||
|
|
||
| # Check the value, expected to return 10000 | ||
| dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::primary::read --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| 10000 | ||
| ] | ||
| } | ||
|
|
||
| # Set the value to 20000 | ||
| account execute-function -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::primary::set_value --arg 20000u64 -b | ||
|
|
||
| # Check the value, expected to return 20000 | ||
| dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::primary::read --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| 20000 | ||
| ] | ||
| } | ||
|
|
||
| # Remove the value | ||
| account execute-function -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::primary::remove -b | ||
|
|
||
| # Check if the resource exists, expected to return false | ||
| dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::primary::exists_at --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| false | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Secondary Module | ||
|
|
||
| ```shell | ||
| # Deploy the Secondary module | ||
| dev deploy -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 <work_dir>/starcoin/vm2/move-examples/resource_groups/secondary/release/ResourceGroupsSecondary.v0.0.1.blob | ||
|
|
||
| # Initialize the resource group with an initial value of 10000 | ||
| account execute-function --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::secondary::init -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --arg 10000u32 -b | ||
|
|
||
| # Check the value, expected to return 10000 | ||
| dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::secondary::read --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| 10000 | ||
| ] | ||
| } | ||
|
|
||
| # Set the value to 20000 | ||
| account execute-function -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::secondary::set_value --arg 20000u32 -b | ||
|
|
||
| # Check the value, expected to return 20000 | ||
| dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::secondary::read --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| 20000 | ||
| ] | ||
| } | ||
|
|
||
| # Remove the value | ||
| account execute-function -s 0x143e9f2175f92f51d9adaeee2b3d8bf0 --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::secondary::remove -b | ||
|
|
||
| # Check if the resource exists, expected to return false | ||
| dev call --function 0x143e9f2175f92f51d9adaeee2b3d8bf0::secondary::exists_at --arg 0x143e9f2175f92f51d9adaeee2b3d8bf0 | ||
| { | ||
| "ok": [ | ||
| false | ||
| ] | ||
| } | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||
| # Shared Account | ||||||||||
|
|
||||||||||
| This section explains how to test and deploy the `shared-account` sample project on the Starcoin blockchain. The project | ||||||||||
| simulates an NFT commission distribution scenario: a derived account is created from a main account, a portion of tokens | ||||||||||
| is deposited into the derived account, and accounts participating in commission distribution are added. When | ||||||||||
| distribution is required, tokens are disbursed directly from the derived account. | ||||||||||
|
|
||||||||||
| ## Prerequisites | ||||||||||
|
|
||||||||||
| The project is located in | ||||||||||
| the [shared-account](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-examples/shared_account) | ||||||||||
| repository. Please clone the Starcoin repository to your local machine and compile the following tools: | ||||||||||
|
|
||||||||||
| 1. [starcoin-cmd](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/cmd/starcoin): Used for connecting to | ||||||||||
| nodes. | ||||||||||
| 2. [move-package-manager2](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-package-manager): Used | ||||||||||
| for packaging Move modules. | ||||||||||
|
|
||||||||||
| Assuming the Starcoin binary has been compiled successfully, execute the following commands to connect to the Starcoin | ||||||||||
| console and package the project: | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Connect to the Starcoin console, where <network> is the network name (e.g., dev, barnard, etc.) | ||||||||||
| starcoin -n <network> console | ||||||||||
|
|
||||||||||
| # View the node's sync progress; ensure the local node is fully synced before submitting test transactions | ||||||||||
| starcoin% node sync progress | ||||||||||
| There are no running sync tasks. | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Test Command Set | ||||||||||
|
|
||||||||||
| The following steps demonstrate how to deploy and test the `shared-account` contract in the Starcoin console: | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Deploy the contract | ||||||||||
| dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 /home/bob/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blob | ||||||||||
|
|
||||||||||
|
Comment on lines
+36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Verification inconclusiveAvoid absolute paths and confirm deploy flag semantics. -dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 /home/bob/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blob
+dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 <work_dir>/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blobAvoid absolute paths; clarify -dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 /home/bob/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blob
+dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 <work_dir>/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blob📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| # Query the derived account address | ||||||||||
| dev call --function 0x82cbfefb8076f2da3339b782fb074438::SharedAccount::get_derive_account --arg 0x82cbfefb8076f2da3339b782fb074438 --arg b"1" | ||||||||||
| { | ||||||||||
| "ok": [ | ||||||||||
| "0x711f9777700a13eaf73b173aa2664216" | ||||||||||
| ] | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # Transfer tokens to the derived account to ensure sufficient balance for distribution | ||||||||||
| account transfer -r 0x711f9777700a13eaf73b173aa2664216 -v 10000000000 | ||||||||||
|
|
||||||||||
| # Initialize the derived account | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::SharedAccount::initialize_with_resource_account --arg b"1" -b | ||||||||||
|
|
||||||||||
| # Add participant account R1 for distribution | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::SharedAccount::add_address --arg b"1" --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 --arg 100u64 -b | ||||||||||
|
|
||||||||||
| # Add participant account R2 for distribution | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::SharedAccount::add_address --arg b"1" --arg 0x7111c56355d63f3434aa7de8b3c94aff --arg 100u64 -b | ||||||||||
|
|
||||||||||
| # Execute commission distribution | ||||||||||
| account execute-function --function 0x82cbfefb8076f2da3339b782fb074438::SharedAccount::disperse -t 0x1::starcoin_coin::STC --arg 0x711f9777700a13eaf73b173aa2664216 -b | ||||||||||
| ``` | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,114 @@ | ||||||||||
| # Decentralized Finance (DeFi) | ||||||||||
|
|
||||||||||
| This section explains how to test and deploy the `defi` sample project on the Starcoin blockchain. The project’s main | ||||||||||
| functionality is to test a scenario where a sponsor (S) authorizes a recipient (R) to receive a certain amount of locked | ||||||||||
| tokens, which the recipient can claim after a specified lockup period. | ||||||||||
|
|
||||||||||
| ## Prerequisites | ||||||||||
|
|
||||||||||
| The project is located in the [defi](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-examples/defi) | ||||||||||
| repository. Please clone the Starcoin repository to your local machine and compile the following tools: | ||||||||||
|
|
||||||||||
| 1. [starcoin-cmd](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/cmd/starcoin): Used for connecting to | ||||||||||
| nodes. | ||||||||||
| 2. [move-package-manager2](https://github.com/starcoinorg/starcoin/tree/dual-verse-dag/vm2/move-package-manager): Used | ||||||||||
| for packaging Move modules. | ||||||||||
|
|
||||||||||
| Assuming the Starcoin binary has been compiled successfully, import the following account information: | ||||||||||
|
|
||||||||||
| - Sponsor (S) account: `0x82cbfefb8076f2da3339b782fb074438` | ||||||||||
| - Recipient (R1) account: `0x95cb8c2ef522014bd03f633bd6c8dee6` | ||||||||||
| - Recipient (R2) account: `0x7111c56355d63f3434aa7de8b3c94aff` | ||||||||||
|
|
||||||||||
| Account import data (JSON format): | ||||||||||
|
|
||||||||||
|
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an upfront security disclaimer for account handling. Given the account import that follows, add a brief disclaimer about test-only keys, rotation, and funding via faucet. -Account import data (JSON format):
+Account import data (JSON format):
+
+> Security note: Use throwaway dev/test accounts only. If any example key ever held funds on a public network, consider it compromised and rotate immediately.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| ```json | ||||||||||
| [ | ||||||||||
| { | ||||||||||
| "ok": { | ||||||||||
| "account": "0x82cbfefb8076f2da3339b782fb074438", | ||||||||||
| "private_key": "0x01f747e8476fe3727ca29ae87fd44dd8d222609b42517274908c9ef24023169a" | ||||||||||
| } | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "ok": { | ||||||||||
| "account": "0x95cb8c2ef522014bd03f633bd6c8dee6", | ||||||||||
| "private_key": "0x37528fbbace04e2b3609de312bdcfeb4704cd83a3488b9fc836118d02835c36e" | ||||||||||
| } | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| "ok": { | ||||||||||
| "account": "0x7111c56355d63f3434aa7de8b3c94aff", | ||||||||||
| "private_key": "0xb1a0d666adaae36d103631a182f8742717c7a650f374912804a1f5e740f4b1b7" | ||||||||||
| } | ||||||||||
| } | ||||||||||
| ] | ||||||||||
| ``` | ||||||||||
|
Comment on lines
+25
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard-stop: Private keys committed in docs (rotate immediately; replace with placeholders). The JSON sample embeds three real-looking private_key values. This is a critical secret-leak pattern (also flagged by Gitleaks). Even if intended for dev/test, never publish usable keys. Anyone can sweep funds on any network where these keys are funded.
Apply this diff to sanitize the sample and protect readers: -```json
-[
- {
- "ok": {
- "account": "0x82cbfefb8076f2da3339b782fb074438",
- "private_key": "0x01f747e8476fe3727ca29ae87fd44dd8d222609b42517274908c9ef24023169a"
- }
- },
- {
- "ok": {
- "account": "0x95cb8c2ef522014bd03f633bd6c8dee6",
- "private_key": "0x37528fbbace04e2b3609de312bdcfeb4704cd83a3488b9fc836118d02835c36e"
- }
- },
- {
- "ok": {
- "account": "0x7111c56355d63f3434aa7de8b3c94aff",
- "private_key": "0xb1a0d666adaae36d103631a182f8742717c7a650f374912804a1f5e740f4b1b7"
- }
- }
-]
-```
+```json
+[
+ { "ok": { "account": "<SPONSOR_ACCOUNT_ADDRESS>", "private_key": "<SPONSOR_PRIVATE_KEY_HEX>" } },
+ { "ok": { "account": "<RECIPIENT1_ACCOUNT_ADDRESS>","private_key": "<RECIPIENT1_PRIVATE_KEY_HEX>" } },
+ { "ok": { "account": "<RECIPIENT2_ACCOUNT_ADDRESS>","private_key": "<RECIPIENT2_PRIVATE_KEY_HEX>" } }
+]
+```Add this warning right above the JSON: +> Important
+> - Do NOT use or publish real private keys. Generate local, throwaway keys for dev/test only.
+> - Replace the placeholders below with your locally generated keys (e.g., via `starcoin% account generate`), and never reuse them on mainnet.I can also add a short “generate accounts + faucet” snippet tailored to your preferred network. Want me to push that? 🧰 Tools🪛 Gitleaks (8.28.0)[high] 30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) [high] 36-36: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) [high] 42-42: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| Execute the following commands to connect to the Starcoin console and package the project: | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Connect to the Starcoin console, where <network> is the network name (e.g., dev, barnard, etc.) | ||||||||||
| starcoin -n <network> console | ||||||||||
|
|
||||||||||
| # View the node's sync progress; ensure the local node is fully synced before submitting test transactions | ||||||||||
| starcoin% node sync progress | ||||||||||
| There are no running sync tasks. | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Test Command Set | ||||||||||
|
|
||||||||||
| ### Standard Workflow | ||||||||||
|
|
||||||||||
| Sponsor S authorizes Recipient R1 with 100 STC, locked for 60 seconds. R1 can claim the 100 STC after the 60-second | ||||||||||
| lockup period. | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Initialize: Ensure the S account has an STC balance, and use S to authorize R1 as the recipient | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::initialize_sponsor -t 0x1::starcoin_coin::STC --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 -b | ||||||||||
|
|
||||||||||
| # Add locked coins: Authorize 100 STC (STC has 9 decimals, so pass 100 * 1e9), locked for 60 seconds | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::add_locked_coins -t 0x1::starcoin_coin::STC --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 --arg 100000000000u64 --arg 60u64 -b | ||||||||||
|
|
||||||||||
| # View the total number of locks for S | ||||||||||
| dev call --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::total_locks -t 0x1::starcoin_coin::STC --arg 0x82cbfefb8076f2da3339b782fb074438 | ||||||||||
|
|
||||||||||
| # View the locked amount for R1 by S | ||||||||||
| dev call --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::locked_amount -t 0x1::starcoin_coin::STC --arg 0x82cbfefb8076f2da3339b782fb074438 --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 | ||||||||||
|
|
||||||||||
| # View the lockup time for R1 by S | ||||||||||
| dev call --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::claim_time_secs -t 0x1::starcoin_coin::STC --arg 0x82cbfefb8076f2da3339b782fb074438 --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 | ||||||||||
|
|
||||||||||
| # View the withdrawal address for the lock | ||||||||||
| dev call --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::withdrawal_address -t 0x1::starcoin_coin::STC --arg 0x82cbfefb8076f2da3339b782fb074438 | ||||||||||
|
|
||||||||||
| # R1 claims the locked tokens from S (claiming within 60 seconds will result in an error) | ||||||||||
| account execute-function -s 0x95cb8c2ef522014bd03f633bd6c8dee6 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::claim -t 0x1::starcoin_coin::STC --arg 0x82cbfefb8076f2da3339b782fb074438 -b | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ### Error Claim Workflow | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Error claim: R1 attempts to claim locked tokens from an incorrect account | ||||||||||
| account execute-function -s 0x95cb8c2ef522014bd03f633bd6c8dee6 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::claim -t 0x1::starcoin_coin::STC --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 -b | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ### Update Lockup | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Update the lockup time to 600 seconds | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::update_lockup -t 0x1::starcoin_coin::STC --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 --arg 600u64 -b | ||||||||||
|
|
||||||||||
| # Verify if the lockup time has been updated | ||||||||||
| dev call --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::claim_time_secs -t 0x1::starcoin_coin::STC --arg 0x82cbfefb8076f2da3339b782fb074438 --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ### Cancel Lockup | ||||||||||
|
|
||||||||||
| ```shell | ||||||||||
| # Re-add locked coins: Authorize 100 STC, locked for 60 seconds | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::add_locked_coins -t 0x1::starcoin_coin::STC --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 --arg 100000000000u64 --arg 60u64 -b | ||||||||||
|
|
||||||||||
| # Cancel the lockup | ||||||||||
| account execute-function -s 0x82cbfefb8076f2da3339b782fb074438 --function 0x82cbfefb8076f2da3339b782fb074438::locked_coins::cancel_lockup -t 0x1::starcoin_coin::STC --arg 0x95cb8c2ef522014bd03f633bd6c8dee6 -b | ||||||||||
| ``` | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix path: directory name uses underscore, not hyphen.
Repo link (Line 9) points to hello_blockchain; the cd path uses hello-blockchain.
📝 Committable suggestion
🤖 Prompt for AI Agents