Smart contracts for the Softlaw marketplace, built with Foundry for deployment on Polkadot's Asset Hub (Passet Hub TestNet).
This project includes a pre-configured DevContainer with all tools installed:
Requirements:
- Docker
- VS Code with Remote-Containers extension
Setup:
- Open project in VS Code
- Click "Reopen in Container" when prompted
- Add your
PRIVATE_KEYto.envfile - Start developing - Foundry and all dependencies are pre-installed
The DevContainer automatically:
- Installs Foundry and Solidity tools
- Loads your
.envfile - Configures the development environment
- Sets up git and shell aliases
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryupSetup Environment:
cp .env.example .env
# Add your PRIVATE_KEY to .envGet Testnet Tokens: Polkadot Faucet
forge build # Build contracts
forge test # Run all tests
forge test --gas-report # With gas usage
forge coverage # Coverage reportSee Deployment Guide for complete instructions.
⚠️ Important:forge scripthas issues with proxy deployments on Polkadot networks. Usecast send --create --legacyfor reliable deployments. See the deployment guide.
| Property | Value |
|---|---|
| Network | Polkadot Hub TestNet |
| Chain ID | 420420417 |
| RPC | https://services.polkadothub-rpc.com/testnet |
| Explorer | https://polkadot.testnet.routescan.io/ |
| Faucet | https://faucet.polkadot.io/?parachain=1111 |
RPC endpoint configured in foundry.toml as polkadotHubTestnet.
# Build documentation
./build-docs.sh
# View locally
open docs/book/index.html
# Or serve with live reload
cd docs && mdbook serve --open- 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
The marketplace consists of 5 core contracts:
| Contract | Type | Description |
|---|---|---|
| IPAsset | ERC721 | IP asset ownership and licensing |
| LicenseToken | ERC1155 | License ownership and management |
| GovernanceArbitrator | Governance | Dispute resolution and arbitration |
| Marketplace | Trading | IP asset and license marketplace |
| RevenueDistributor | Logic | Revenue sharing and royalties |
All contracts except RevenueDistributor use UUPS upgradeable pattern.
.
├── 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
# 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.htmlAfter 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 -vvNote:
cast callandcast codemay return empty on Polkadot networks. Use Solidity scripts for reliable contract reads.