135 lines
4.1 KiB
Markdown
135 lines
4.1 KiB
Markdown
# EDUT Contracts
|
|
|
|
On-chain contracts and deployment artifacts for membership and entitlements.
|
|
|
|
## Scope
|
|
|
|
1. Human membership contract (soulbound governance identity).
|
|
2. Offer + entitlement settlement contract for fixed-SKU purchases.
|
|
3. ABI and deployment artifact publication.
|
|
|
|
## Current Contract
|
|
|
|
`contracts/EdutHumanMembership.sol`
|
|
|
|
Features:
|
|
|
|
1. One-time soulbound human token mint.
|
|
2. Sponsor mint support (`mintMembership(recipient)` can be paid by inviter/company wallet).
|
|
3. Owner-configurable flat mint price (`updateMintPrice`), launch default is fixed `100 USDC` (6 decimals).
|
|
4. Membership status lifecycle (`ACTIVE/SUSPENDED/REVOKED`) for runtime gates.
|
|
5. Treasury address control for settlement routing.
|
|
|
|
`contracts/EdutOfferEntitlement.sol`
|
|
|
|
Features:
|
|
|
|
1. Membership-gated entitlement purchases.
|
|
2. Owner-configurable offer registry (`upsertOffer`).
|
|
3. Fixed USDC settlement support (ETH optional if payment token is zero address).
|
|
4. Deterministic entitlement id sequence with state lifecycle (`ACTIVE/SUSPENDED/REVOKED`).
|
|
5. Emits offer + entitlement events for backend reconciliation.
|
|
|
|
## Local Commands
|
|
|
|
Use a Hardhat-supported Node runtime (`20.x` recommended).
|
|
|
|
1. `npm install`
|
|
2. `npm run build`
|
|
3. `npm run test`
|
|
4. `npm run check:addresses`
|
|
5. `npm run deploy:sepolia`
|
|
6. `npm run deploy:mainnet`
|
|
7. `npm run deploy:entitlement:sepolia`
|
|
8. `npm run deploy:entitlement:mainnet`
|
|
9. `npm run update:membership:price:sepolia`
|
|
10. `npm run update:membership:price:mainnet`
|
|
11. `npm run smoke:funding:sepolia`
|
|
|
|
`make check` wraps build + tests.
|
|
|
|
## Deployment Environment
|
|
|
|
Copy `.env.example` values into your shell/session before deploy:
|
|
|
|
1. `DEPLOYER_PRIVATE_KEY`
|
|
2. `BASE_SEPOLIA_RPC_URL` / `BASE_MAINNET_RPC_URL`
|
|
3. `TREASURY_WALLET`
|
|
4. `MINT_CURRENCY_ADDRESS` (USDC token contract on target chain)
|
|
5. `MINT_AMOUNT_ATOMIC`
|
|
6. `DEPLOY_OUTPUT_PATH` (optional)
|
|
7. `ENTITLEMENT_TREASURY_WALLET`
|
|
8. `MEMBERSHIP_CONTRACT_ADDRESS`
|
|
9. `PAYMENT_TOKEN_ADDRESS`
|
|
10. `OFFER_PRICE_ATOMIC`
|
|
11. `ENTITLEMENT_DEPLOY_OUTPUT_PATH` (optional)
|
|
12. `OFFERS_JSON` (optional path to per-offer seed config JSON)
|
|
13. `OFFERS_INLINE_JSON` (optional inline JSON array alternative to `OFFERS_JSON`)
|
|
14. `SEED_RETRIES` (optional, default `2`)
|
|
15. `SEED_RETRY_DELAY_MS` (optional, default `1200`)
|
|
16. `SEED_ONLY` (optional, `true` attaches to an existing entitlement contract and only seeds offers)
|
|
17. `ENTITLEMENT_CONTRACT_ADDRESS` (required when `SEED_ONLY=true`)
|
|
|
|
`update:membership:price:*` requires:
|
|
|
|
1. `MEMBERSHIP_CONTRACT_ADDRESS`
|
|
2. `MINT_CURRENCY_ADDRESS`
|
|
3. `MINT_AMOUNT_ATOMIC`
|
|
|
|
If no offer override JSON is provided, deploy script seeds default offers at `OFFER_PRICE_ATOMIC`.
|
|
Use `deploy/offers.template.json` to define per-offer prices and policy flags.
|
|
|
|
Smoke flow optional vars:
|
|
|
|
1. `E2E_IDENTITY_ASSURANCE_LEVEL`
|
|
2. `E2E_IDENTITY_ATTESTED_BY`
|
|
3. `E2E_IDENTITY_ATTESTATION_ID`
|
|
4. `E2E_OFFER_ID`
|
|
5. `E2E_ORG_ROOT_ID`
|
|
6. `E2E_PRINCIPAL_ID`
|
|
7. `E2E_PRINCIPAL_ROLE`
|
|
8. `E2E_WORKSPACE_ID`
|
|
9. `E2E_DEVICE_ID`
|
|
10. `E2E_PLATFORM`
|
|
11. `E2E_LAUNCHER_VERSION`
|
|
12. `E2E_GAS_LIMIT` (optional fixed gas limit, default `300000`)
|
|
13. `E2E_GAS_PRICE_WEI` (optional fixed gas price)
|
|
14. `SMOKE_MIN_GAS_PRICE_WEI` (optional threshold floor for funding estimator, default `1000000000`)
|
|
|
|
Example (Sepolia):
|
|
|
|
```bash
|
|
cd /Users/vsg/Documents/VSG\ Codex/contracts
|
|
export $(grep -v '^#' .env | xargs)
|
|
npm run deploy:sepolia
|
|
```
|
|
|
|
Full control-plane smoke (membership + marketplace + governance install/status):
|
|
|
|
```bash
|
|
cd /Users/vsg/Documents/VSG\ Codex/contracts
|
|
export $(grep -v '^#' .env | xargs)
|
|
npm run smoke:e2e:controlplane:sepolia
|
|
```
|
|
|
|
Offer readback verification against deployed entitlement contract:
|
|
|
|
```bash
|
|
cd /Users/vsg/Documents/VSG\ Codex/contracts
|
|
export BASE_SEPOLIA_RPC_URL="https://base-sepolia.g.alchemy.com/v2/<key>"
|
|
export ENTITLEMENT_CONTRACT_ADDRESS="0x..."
|
|
npm run verify:offers:sepolia
|
|
```
|
|
|
|
Sepolia smoke funding threshold from live fee data:
|
|
|
|
```bash
|
|
cd /Users/vsg/Documents/VSG\ Codex/contracts
|
|
export BASE_SEPOLIA_RPC_URL="https://base-sepolia.g.alchemy.com/v2/<key>"
|
|
npm run smoke:funding:sepolia
|
|
```
|
|
|
|
## Boundary
|
|
|
|
Contracts are settlement primitives. Runtime execution remains off-chain and fail-closed by entitlement state.
|