Skip to content

taigfs/devconnect-mintwork

Repository files navigation

Mintwork - Work Marketplace on Scroll

Decentralized job marketplace with WETH escrow and Work Credential NFTs on Scroll Sepolia.

Status React Vite License: MIT

You can access the Mintwork DApp Frontend repository here.

πŸ”— Quick Links

Overview

Mintwork is a smart contract system that enables:

  • Job Creation: Requesters create jobs and lock WETH in escrow
  • Work Submission: Workers claim jobs and submit their work
  • Payment & NFT Minting: Upon approval, workers receive WETH payment and a Work Credential NFT

Contracts

  • WorkNFT.sol: ERC-721 NFT that serves as a verifiable credential of completed work
  • WorkMarketplace.sol: Escrow-based marketplace that manages jobs and payments

Prerequisites

  • Foundry
  • Private key with ETH on Scroll Sepolia
  • WETH contract address on Scroll Sepolia

Setup

  1. Clone and install dependencies:
git clone <your-repo>
cd devconnect-mintwork
forge install
  1. Configure environment variables:
# Copy the example file
cp env.example .env

# Edit .env with your values
PRIVATE_KEY=your_private_key_here
WETH_ADDRESS=0x5300000000000000000000000000000000000004
  1. Build:
forge build

Deployment

Deploy to Scroll Sepolia

Option 1: Using Makefile (Recommended)

# Export environment variables
export PRIVATE_KEY="your_private_key_here"
export WETH_ADDRESS="0x5300000000000000000000000000000000000004"

# Deploy contracts
make deploy

Option 2: Using .env file

# Load environment variables
source .env

# Deploy contracts
forge script script/DeployWorkNFT.s.sol:DeployMintwork \
    --rpc-url https://sepolia-rpc.scroll.io \
    --broadcast \
    --verify \
    -vvvv

Option 3: Using export directly

# Export environment variables
export PRIVATE_KEY="your_private_key_here"
export WETH_ADDRESS="0x5300000000000000000000000000000000000004"

# Deploy contracts
forge script script/DeployWorkNFT.s.sol:DeployMintwork \
    --rpc-url https://sepolia-rpc.scroll.io \
    --broadcast \
    --verify \
    -vvvv

Makefile Commands

make build          # Build the project
make test           # Run tests
make fmt            # Format code
make deploy         # Deploy to Scroll Sepolia (with verification)
make deploy-no-verify # Deploy without verification (faster)
make deploy-local    # Deploy to local Anvil node
make help           # Show all available commands

Network Information

Scroll Sepolia Testnet:

Development

Build

forge build

Test

forge test

Format

forge fmt

Gas Snapshots

forge snapshot

Local Testing with Anvil

# Start local node
anvil

# Deploy to local node
forge script script/DeployWorkNFT.s.sol:DeployMintwork \
    --rpc-url http://localhost:8545 \
    --broadcast

Architecture

devconnect-mintwork/
β”œβ”€ src/
β”‚  β”œβ”€ Mintwork_Escrow.sol               # Contract for escrow custody and management of funds/payments
β”‚  β”œβ”€ Mintwork_NFT.sol                  # Main NFT contract (ERC-721 or ERC-1155), representing the "Work"
β”œβ”€ script/
β”‚  └─ DeployWorkNFT.sol                 # Hardhat/Foundry script for deploying the contracts
β”œβ”€ .env.example                         # Example environment variables (private keys, RPC URLs, etc.)
β”œβ”€ flattens/
β”‚     β”œβ”€ WorkMarketplace.flatten.sol    # Flattened version of the WorkMarketplace contract (for verification or auditing)
β”‚     β”œβ”€ WorkNFT.flatten.sol            # Flattened version of the WorkNFT contract (all dependencies in one file)
β”œβ”€ Makefile                             # Shortcuts for common commands (compile, test, deploy)
β”œβ”€ out/
β”‚     β”œβ”€ Mintwork_Escrow.sol/           # Compilation artifacts generated by Foundry (ABI, bytecode, metadata)
β”‚     β”œβ”€ Mintwork_NFT.sol/              # Compilation artifacts for the NFT contract (ABI, bytecode, metadata)
└─ ...

Deployment Flow

  1. Deploy WorkNFT contract
  2. Deploy WorkMarketplace contract with WETH and WorkNFT addresses
  3. Transfer WorkNFT ownership to WorkMarketplace (allows marketplace to mint NFTs)

Job Lifecycle

  1. Create Job: Requester creates job and locks WETH in escrow
  2. Take Job: Worker claims the job
  3. Submit Work: Worker submits delivery URL
  4. Approve Work: Requester approves β†’ Worker receives WETH + Work Credential NFT
  5. Cancel Job: Requester can cancel before job is taken (refund)

Smart Contract Functions

WorkMarketplace

  • createJob(reward, deadline, title, description) - Create a new job with WETH escrow
  • takeJob(jobId) - Claim a job
  • submitWork(jobId, deliveryUrl) - Submit completed work
  • approveWork(jobId) - Approve work and trigger payment + NFT mint
  • cancelJob(jobId) - Cancel job and refund WETH (only if not taken)

WorkNFT

  • mintWorkNft(...) - Mint Work Credential NFT (only callable by WorkMarketplace)

Security Features

  • βœ… ReentrancyGuard on payment functions
  • βœ… Ownable access control
  • βœ… WETH held in escrow until approval
  • βœ… Only marketplace can mint NFTs

Troubleshooting

Error: "contract source info format must be..."

  • Make sure to specify the contract name: script/DeployWorkNFT.s.sol:DeployMintwork

Error: "WETH address zero"

  • Ensure WETH_ADDRESS environment variable is set

Verification fails:

  • You may need a Scrollscan API key for contract verification
  • Add to .env: ETHERSCAN_API_KEY=your_scrollscan_api_key

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors