Softlaw Marketplace Contracts

Smart contracts for the Softlaw marketplace, built with Foundry for deployment on Polkadot's Asset Hub (Passet Hub TestNet).

Development Environment

This project includes a pre-configured DevContainer with all tools installed:

Requirements:

  • Docker
  • VS Code with Remote-Containers extension

Setup:

  1. Open project in VS Code
  2. Click "Reopen in Container" when prompted
  3. Add your PRIVATE_KEY to .env file
  4. Start developing - Foundry and all dependencies are pre-installed

The DevContainer automatically:

  • Installs Foundry and Solidity tools
  • Loads your .env file
  • Configures the development environment
  • Sets up git and shell aliases

Option 2: Manual Setup

Install Foundry:

curl -L https://foundry.paradigm.xyz | bash
foundryup

Setup Environment:

cp .env.example .env
# Add your PRIVATE_KEY to .env

Get Testnet Tokens: Polkadot Faucet

Build & Test

forge build                    # Build contracts
forge test                     # Run all tests
forge test --gas-report        # With gas usage
forge coverage                 # Coverage report

Deployment

See Deployment Guide for complete instructions.

⚠️ Important: forge script has issues with proxy deployments on Polkadot networks. Use cast send --create --legacy for reliable deployments. See the deployment guide.

Network Information

PropertyValue
NetworkPolkadot Hub TestNet
Chain ID420420417
RPChttps://services.polkadothub-rpc.com/testnet
Explorerhttps://polkadot.testnet.routescan.io/
Faucethttps://faucet.polkadot.io/?parachain=1111

RPC endpoint configured in foundry.toml as polkadotHubTestnet.

Documentation

Build and View

# Build documentation
./build-docs.sh

# View locally
open docs/book/index.html

# Or serve with live reload
cd docs && mdbook serve --open

What's Included

  • Architecture Diagrams: 16 Mermaid diagrams showing system flow, contract interactions, and state machines
  • Contract Reference: Auto-generated from NatSpec in interfaces
  • User Flows: Step-by-step sequences for key operations

Contract Architecture

The marketplace consists of 5 core contracts:

ContractTypeDescription
IPAssetERC721IP asset ownership and licensing
LicenseTokenERC1155License ownership and management
GovernanceArbitratorGovernanceDispute resolution and arbitration
MarketplaceTradingIP asset and license marketplace
RevenueDistributorLogicRevenue sharing and royalties

All contracts except RevenueDistributor use UUPS upgradeable pattern.

Project Structure

.
├── src/              # Smart contracts
│   ├── interfaces/   # Contract interfaces
│   ├── IPAsset.sol
│   ├── LicenseToken.sol
│   ├── GovernanceArbitrator.sol
│   ├── Marketplace.sol
│   └── RevenueDistributor.sol
├── script/           # Deployment scripts
│   ├── deployment-guide.md        # Deployment instructions
│   ├── DeployProduction.s.sol     # Deploy all contracts
│   ├── DeployIPAsset.s.sol        # Individual deployments
│   └── SetupAddresses.s.sol       # Wire contracts together
└── test/             # Test files

Testing

# Run all tests
forge test

# Specific test file
forge test --match-path "test/IPAsset.t.sol"

# Specific contract tests
forge test --match-contract IPAssetTest

# With gas reporting
forge test --gas-report

# Coverage
forge coverage
forge coverage --report html && open coverage/index.html

Verification

After deployment, verify contracts using Solidity scripts (recommended for Polkadot networks):

# Verify all deployed contracts
forge script script/helpers/VerifyFullDeployment.s.sol:VerifyFullDeployment \
  --rpc-url polkadotHubTestnet -vv

# Check specific contract
forge script script/helpers/CheckIPAsset.s.sol:CheckIPAsset \
  --rpc-url polkadotHubTestnet -vv

Note: cast call and cast code may return empty on Polkadot networks. Use Solidity scripts for reliable contract reads.