Skip to content

dumbdevss/Movement-Document-Management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure Document Management on Movement Network

A decentralized document management system built on the Movement Network that enables secure document upload, sharing, and digital signing with blockchain-based verification and IPFS storage.

Overview

The Secure Document Management smart contract provides a robust solution for managing sensitive documents on-chain. Documents are stored as IPFS hashes with metadata tracked on the blockchain, enabling:

  • Decentralized Storage: Document content stored on IPFS, metadata on-chain
  • Access Control: Owner-controlled permission management for document signers
  • Digital Signatures: Blockchain-verified signatures with immutable audit trails
  • Fee-Based Uploads: Small upload fee (0.05 MOVE) to prevent spam and abuse
  • Event Tracking: Complete audit trail through on-chain events

This system is ideal for applications requiring document verification, such as contracts, agreements, certifications, legal documents, and any scenario where proof of signing is critical.

What's Included

  • Movement CLI installation script (from l1-migration branch)
  • Secure Document Contract: Production-ready Move module with tests
  • Helper Scripts: Easy commands for deployment and testing
  • Project Structure: Standard Move project layout

Prerequisites

No prerequisites needed! The installation script will download a prebuilt Movement CLI binary.

System Requirements

  • Disk Space: ~50MB for the Movement CLI binary
  • Platform: Linux x86_64 (Replit compatible)
  • Time: Installation takes ~10 seconds

Quick Start

1. Install the Movement CLI

The installation script downloads a prebuilt Movement CLI binary from the l1-migration branch:

bash scripts/install-cli.sh

Note: This takes about 10 seconds. The script will attempt to configure your PATH automatically.

2. Initialize Your Configuration

Set up your Movement CLI configuration for the testnet:

bash scripts/init.sh

You'll be prompted to:

  • Select custom network
  • Enter REST URL: https://testnet.movementnetwork.xyz/v1
  • Enter Faucet URL: https://faucet.testnet.movementnetwork.xyz/
  • Generate a new private key (or provide your own)

Your configuration will be saved in .movement/config.yaml

⚠️ IMPORTANT: Never commit .movement/config.yaml to git - it contains your private key!

3. Fund Your Account

Get testnet MOVE tokens to pay for transactions:

movement account fund-with-faucet --account default

4. Build the Move Module

Compile the secure document management module:

bash scripts/build.sh

5. Test the Move Module

Run the unit tests:

bash scripts/test.sh

6. Deploy to Testnet

Deploy your module to the Movement testnet:

movement move publish --named-addresses document_management=default

To reduce gas costs (omit debug artifacts):

movement move publish --named-addresses document_management=default --included-artifacts none

Note If movement command fails and the cli is installed. install please run

export PATH="$HOME/bin:$PATH"

Project Structure

.
├── Move.toml                     # Move package configuration
├── sources/
│   └── document_management.move     # Your Move module
├── scripts/
│   ├── install-cli.sh           # Install Movement CLI
│   ├── init.sh                  # Initialize CLI configuration
│   ├── build.sh                 # Compile the module
│   ├── test.sh                  # Run tests
│   └── verify.sh                # Verify setup
└── tests/                       # Additional test files (optional)

The Secure Document Management Module

Core Features

Document Upload

  • Store document metadata on-chain with IPFS hash
  • Automatic timestamp recording
  • 0.05 APT upload fee (prevents spam)
  • Unique document ID enforcement

Access Control

  • Owner-based permission system
  • Granular signer management
  • Owner can sign by default

Digital Signatures

  • One signature per user per document
  • Blockchain-verified signing
  • Immutable signature records

Event System

  • Upload events with full metadata
  • Signature events for audit trails
  • Share events for access grants

Key Functions

Entry Functions (Callable via transactions)

  • upload_document: Upload a new document with metadata and IPFS hash (requires 0.05 MOVE fee)
  • add_signer: Grant signing permission to an address (owner only)
  • sign_document: Sign a document if you have permission

View Functions (Read-only queries)

  • get_document: Retrieve complete document details including name, IPFS hash, timestamps, owner, signatures, and allowed signers
  • get_document_count: Get total number of uploaded documents
  • is_signed_by: Check if a specific address has signed a document
  • get_upload_fee: Query the current upload fee

Usage Examples

Uploading a Document

movement move run \
  --function-id 'default::secure_docs::upload_document' \
  --args string:"Contract Agreement" \
  --args string:"QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG" \
  --args string:"doc_001"

Adding a Signer

movement move run \
  --function-id 'default::secure_docs::add_signer' \
  --args string:"doc_001" \
  --args address:"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1"

Signing a Document

movement move run \
  --function-id 'default::secure_docs::sign_document' \
  --args string:"doc_001"

Development Workflow

Edit Your Module

Modify sources/document_management.move or add new .move files to the sources/ directory.

Update Dependencies

Edit Move.toml to change dependencies. The default configuration uses the Aptos Framework.

Address Configuration

The Move.toml file uses a placeholder address _ for document_management. When compiling or publishing:

# Use the default profile address
movement move compile --named-addresses document_management=default

# Or specify an explicit address
movement move compile --named-addresses document_management=0xYOUR_ADDRESS

Tip: Edit Move.toml and set document_management = "0xYOUR_ADDRESS" to avoid using --named-addresses every time.

Architecture Details

Resource Account Pattern

The contract uses a resource account to manage state independently from the deployer:

  • DocState: Stored under the resource account, contains all documents and counters
  • ResourceAccountCap: Stored under deployer's address, holds signing capability
  • Benefits: Cleaner separation, predictable addresses, better security

Fee Collection

Upload fees are collected in the resource account's MOVE balance. This design:

  • Prevents spam uploads
  • Creates sustainable tokenomics
  • Can be withdrawn by admin if needed (extend contract)

IPFS Integration

Documents store only the IPFS hash on-chain. Off-chain components should:

  1. Upload document content to IPFS
  2. Get IPFS hash (e.g., QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG)
  3. Call upload_document with the hash
  4. Store the document ID for future reference

Movement CLI Commands

Essential Movement CLI commands for working with your contract:

# Check CLI version
movement --version

# Compile module
movement move compile --named-addresses document_management=default

# Run tests
movement move test

# Publish module
movement move publish --named-addresses document_management=default

# Check account balance
movement account list

# Fund account (testnet only)
movement account fund-with-faucet --account default

Security Considerations

Access Control

  • Only document owners can add signers
  • Only allowed signers can sign documents
  • Signatures are immutable once recorded

Error Handling

The contract includes comprehensive error checking:

  • E_NOT_AUTHORIZED: Caller is not the document owner
  • E_DOCUMENT_NOT_FOUND: Document ID doesn't exist
  • E_ALREADY_SIGNED: User already signed this document
  • E_NOT_ALLOWED_TO_SIGN: User not in allowed signers list
  • E_DOCUMENT_ALREADY_EXISTS: Document ID collision
  • E_INSUFFICIENT_FUNDS: Not enough APT for upload fee

Best Practices

  1. Unique Document IDs: Use UUIDs or hash-based IDs
  2. IPFS Pinning: Ensure documents are pinned for availability
  3. Key Management: Securely store private keys
  4. Fee Awareness: Users need at least 0.05 MOVE + gas fees

Resources

Network Information

Movement Testnet (Bardock)

Future Enhancements

Potential features to add:

  • Document revocation
  • Multi-signature requirements (N-of-M signing)
  • Document expiration dates
  • Admin fee withdrawal function
  • Document transfer between owners
  • Batch operations
  • Document categories/tags

Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests
  • Share your implementations

Join the Movement community and help build the future of decentralized document management!

About

Document Management template built on Movement network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors