How valterlobo/phygital_assets works
Project Type and Purpose
• This is a blockchain smart‐contract project built with Foundry (“forge,” “anvil,” “cast”).
• Purpose: “Phygital Assets” platform to tokenize physical goods as ERC-721 NFTs, deployable to Ethereum (or test) networks.
• Key workflows: deploy contracts, mint NFTs via on‐chain scripts, run automated tests and gas snapshots.
File Structure Analysis
• Top‐level:
• lib/forge-std, lib/openzeppelin-contracts – external Solidity libraries for testing and ERC-721 implementation
• src/ – PhygitalAssets.sol and related contract code
• script/ – Solidity deployment & minting scripts (PhygitalAssetsDeploy.s.sol, PhygitalAssetsMint.s.sol)
• test/ – Foundry test suites
• .github/workflows/test.yml – CI configuration to run forge test
• .env.example – RPC URLs, private keys for off‐chain tooling
• Foundry handles build, test, format, snapshot and local chain (anvil).
README Insights
• Shows commands for build (forge build), test (forge test), deploy & mint scripts with forge script … --rpc-url … --broadcast
• Mentions provider services (Infura, Alchemy) configured via .env
Main Components
a. On-Chain Components
• PhygitalAssets Smart Contract (ERC-721)
• Underlying OpenZeppelin ERC-721 library
• Ethereum Network (Testnet or Mainnet)
b. Off-Chain Components
• Developer Machine / CI Agent
• Foundry Toolchain (forge, cast, anvil)
• Deployment & Mint Scripts
• .env Configuration (RPC URL, keys)
• External RPC Providers (Infura, Alchemy)
• Testing Framework (forge test)
• GitHub Actions (CI pipeline)
Relationships and Data Flow
• Developer invokes forge/anvil locally for unit tests → tests import src/ and lib/ → simulate chain
• Deploy Script reads .env → calls RPC provider → broadcasts contract bytecode to Ethereum
• Mint Script calls contract’s mint function → stores metadata & NFT on-chain
• CI pipeline runs forge test on push (via GitHub Actions)
• cast commands (optional) query or interact with deployed contract
Architectural Patterns & Principles
• Modular contracts using OpenZeppelin libraries for security and upgrades
• Separation of concerns:
• src/ contains production code
• lib/ holds external dependencies
• script/ isolates deployment logic
• test/ covers contract behavior
• Infrastructure as Code: scripts + environment files define deployments
• CI/CD integration via GitHub workflows