Multi-chain smart contracts repository for MAP Protocol, featuring a modular architecture with shared libraries and chain-specific implementations.
mapo-contracts-v2/
βββ common/ # Shared contracts library (npm: @mapprotocol/common-contracts)
β βββ contracts/
β β βββ base/ # Abstract base contracts
β β βββ periphery/ # Peripheral utilities
β βββ package.json # Published as npm package
βββ maintainer/ # Maintainer contracts with dual toolchain
β βββ contracts/
β β βββ Maintainer.sol
β β βββ TSSManager.sol
β β βββ interfaces/
β βββ package.json
βββ protocol/ # Core protocol contracts
β βββ contracts/
β β βββ Gateway.sol
β β βββ Relay.sol
β β βββ VaultManager.sol
β β βββ interfaces/
β βββ package.json
βββ mos-solana/ # Solana-specific implementations
βββ affilate/ # Affiliate contracts
- Node.js >= 18.0.0
- Foundry
- npm or yarn
- Clone the repository:
git clone https://github.com/mapprotocol/mapo-contracts-v2.git
cd mapo-contracts-v2- Install dependencies for each module:
# Common library
cd common && npm install
# Maintainer contracts
cd ../maintainer && npm install
# Protocol contracts
cd ../protocol && npm installThe common/ directory is published as an npm package for reuse across projects.
npm install @mapprotocol/common-contractsimport "@mapprotocol/common-contracts/contracts/base/BaseImplementation.sol";
abstract contract MyContract is BaseImplementation {
function initialize(address _admin) public initializer {
__BaseImplementation_init(_admin);
// Your initialization logic
}
}- BaseImplementation: Abstract base contract with UUPS upgradeable pattern, pausable functionality, and access control
- AuthorityManager: Flexible authority and role management system
- TypeScript Support: Full TypeChain generated types for type-safe development
- Dual Toolchain: Works with both Foundry and Hardhat
Each module supports both Foundry and Hardhat:
# Foundry build
npm run build
# Hardhat build with TypeChain
npm run build:hardhat
# Clean all artifacts
npm run clean# Foundry tests
npm run test
# Hardhat tests
npm run test:hardhat
# Gas reports
npm run gas-report
# Coverage
npm run coverage# Format Solidity code
npm run format
# Type checking
npm run typecheck-
Foundry: Fast Rust-based toolchain for Solidity development
- Faster compilation and testing
- Built-in fuzzing capabilities
- Gas-optimized builds
-
Hardhat: Node.js toolchain for ecosystem compatibility
- TypeChain integration
- Extensive plugin ecosystem
- Better JavaScript/TypeScript integration
All core contracts use the UUPS (Universal Upgradeable Proxy Standard) pattern:
- Gas efficient proxy pattern
- Built-in upgrade authorization
- Compatible with OpenZeppelin's upgradeable contracts
Shared base contracts and utilities used across all modules.
Contracts for managing network maintainers and TSS (Threshold Signature Scheme) operations.
Core protocol contracts including:
- Gateway: Cross-chain message gateway
- Relay: Message relay system
- VaultManager: Asset vault management
- TokenRegistry: Token registration and mapping
Solana-specific Message Omnichain Service implementation.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request