Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions docs/03-move/98-move-examples/03-hello-blockchain.md
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

Comment on lines +33 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix path: directory name uses underscore, not hyphen.
Repo link (Line 9) points to hello_blockchain; the cd path uses hello-blockchain.

-cd <work_dir>/starcoin/vm2/move-examples/hello-blockchain
+cd <work_dir>/starcoin/vm2/move-examples/hello_blockchain
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```shell
# Switch to the project directory
cd <work_dir>/starcoin/vm2/move-examples/hello-blockchain
🤖 Prompt for AI Agents
In docs/03-move/98-move-examples/03-hello-blockchain.md around lines 33 to 36,
the cd command uses a hyphenated directory name "hello-blockchain" but the
actual repo/directory is named "hello_blockchain"; update the path to use the
underscore (cd <work_dir>/starcoin/vm2/move-examples/hello_blockchain) and scan
nearby lines (including the repo link on line 9) to ensure all references
consistently use "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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Verify dev deploy CLI flags; usage is inconsistent across docs.
Here -s appears to be used as a blob path, while other pages pass an address after -s. Please confirm the correct syntax with your current starcoin-cmd and unify across all pages.

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 i18n

Length 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)

  • Fix docs/03-move/98-move-examples/03-hello-blockchain.md:54 (and i18n/zh/docusaurus-plugin-content-docs/current/03-move/98-move-examples/03-hello-blockchain.md:46): currently "dev deploy -s <work_dir>/…/hello-blockchain.v0.0.1.blob" — change to "dev deploy <work_dir>/…/hello-blockchain.v0.0.1.blob -s 0x -b" (match other examples such as docs/03-move/98-move-examples/02-create-a-new-nft.md:76).
  • Remove/replace hard-coded absolute paths found (examples): docs/03-move/98-move-examples/05-shared-account.md:37 (/home/bob/…), docs/03-move/12-call-function.md:68 (/home/ubuntu/…) and their i18n copies — use <work_dir> or /path/to/ placeholders or relative paths.
🤖 Prompt for AI Agents
In docs/03-move/98-move-examples/03-hello-blockchain.md around lines 53–55 (and
the i18n copy
i18n/zh/docusaurus-plugin-content-docs/current/03-move/98-move-examples/03-hello-blockchain.md
line ~46), change the dev deploy invocation to use the sender flag correctly and
avoid hard-coded paths: replace the current "dev deploy -s
<work_dir>/…/hello-blockchain.v0.0.1.blob" with "dev deploy
<work_dir>/…/hello-blockchain.v0.0.1.blob -s 0x<address> -b"; additionally, scan
and update other docs with absolute paths
(docs/03-move/98-move-examples/05-shared-account.md,
docs/03-move/12-call-function.md and their i18n copies) to use <work_dir> or
/path/to/ placeholders or relative paths instead of hard-coded /home/... values.

{
"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"
}
]
}
```
110 changes: 110 additions & 0 deletions docs/03-move/98-move-examples/04-resource-groups.md
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
]
}
```
61 changes: 61 additions & 0 deletions docs/03-move/98-move-examples/05-shared-account.md
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

❓ Verification inconclusive

Avoid absolute paths and confirm deploy flag semantics.
Replace user-specific path; confirm whether -s is sender or path and make consistent.

-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

Avoid absolute paths; clarify -s is the sender.
Replace the user-specific absolute path with a repo-relative or placeholder path; -s is the sender flag (usage: dev deploy <path> -s <sender>). (starcoin.org)

-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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Deploy the contract
dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 /home/bob/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blob
# Deploy the contract
dev deploy -s 0x82cbfefb8076f2da3339b782fb074438 <work_dir>/starcoin/vm2/move-examples/shared_account/release/shared_account.v0.0.1.blob
🤖 Prompt for AI Agents
In docs/03-move/98-move-examples/05-shared-account.md around lines 36 to 38, the
deploy example uses a user-specific absolute path and a confusing flag order;
replace the absolute path with a repo-relative or placeholder path (e.g.,
./shared_account/release/shared_account.v0.0.1.blob or <path-to-blob>) and
update the command to show the sender flag clearly (usage: dev deploy <path> -s
<sender>), e.g., put the path first and -s 0x82cb... after it, and add a brief
note that -s specifies the sender address.

# 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
```
114 changes: 114 additions & 0 deletions docs/03-move/98-move-examples/06-defi.md
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
🤖 Prompt for AI Agents
In docs/03-move/98-move-examples/06-defi.md around lines 23–24, add a brief
upfront security disclaimer immediately above the "Account import data (JSON
format):" line warning that the shown accounts are test-only keys, should not be
used on mainnet, must be funded via a faucet for testing, and private keys must
be kept secure and rotated regularly in production; keep the text concise (1–2
sentences) and clearly labeled as a security note.

```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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

  • Action now: Assume keys are compromised; rotate/delete them wherever used.
  • Fix docs: Replace with placeholders and add a warning about generating local throwaway keys (devnet only).

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
In docs/03-move/98-move-examples/06-defi.md around lines 25 to 46, the JSON
example contains real-looking private_key values which must be removed; replace
each concrete private_key and account value with placeholder tokens (e.g.,
<SPONSOR_ACCOUNT_ADDRESS>, <SPONSOR_PRIVATE_KEY_HEX>, etc.) and insert a short
warning immediately above the JSON block instructing readers to generate or use
throwaway/devnet keys only (and to rotate/revoke any exposed keys). Ensure the
sanitized JSON matches the suggested placeholder format from the review and do
not commit any real secrets; optionally add (or offer separately) a small
“generate accounts + faucet” snippet for the chosen devnet if desired.


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
```
Loading