Proposal Templates
CredDAO includes 6 pre-built proposal templates for common governance scenarios.
Using Templates
TemplateSelector Component
import { TemplateSelector } from '@/components/proposals/TemplateSelector'
<TemplateSelector
onSelect={(title, description, type) => {
// Populate form with template
setFormData({ title, description, type })
}}
onClose={() => setShowTemplates(false)}
/>Programmatic Usage
import {
PROPOSAL_TEMPLATES,
getTemplateById,
applyTemplate
} from '@/lib/proposalTemplates'
// Get specific template
const template = getTemplateById('treasury-transfer')
// Apply with field values
const { title, description } = applyTemplate(template, {
amount: '1000',
token: 'USDC',
recipient: '7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU',
justification: 'Development grant'
})Available Templates
1. Treasury Transfer
Request transfer of funds from the DAO treasury.
| Field | Type | Required |
|---|---|---|
| amount | number | ✓ |
| token | text | ✓ |
| recipient | address | ✓ |
| recipient_name | text | |
| justification | textarea | ✓ |
Type: Standard
2. Governance Parameter Change
Propose changes to DAO governance parameters.
| Field | Type | Required |
|---|---|---|
| parameter | select | ✓ |
| current_value | text | ✓ |
| proposed_value | text | ✓ |
| rationale | textarea | ✓ |
Options: Quorum, Voting Period, Time Lock, Proposal Threshold
Type: Standard
3. Smart Contract Upgrade
Propose an upgrade to DAO smart contracts.
| Field | Type | Required |
|---|---|---|
| contract_name | text | ✓ |
| current_version | text | ✓ |
| new_version | text | ✓ |
| audit_link | text | |
| changes | textarea | ✓ |
Type: Expedited
4. Grant Funding Request
Request funding for a project or initiative.
| Field | Type | Required |
|---|---|---|
| project_name | text | ✓ |
| team_lead | text | ✓ |
| total_amount | number | ✓ |
| duration | text | ✓ |
| description | textarea | ✓ |
Type: Standard
5. Emergency Action
Critical action requiring immediate attention.
| Field | Type | Required |
|---|---|---|
| action | text | ✓ |
| risk_level | select | ✓ |
| impact | textarea | ✓ |
| resolution | textarea | ✓ |
Options: Critical, High
Type: Emergency
6. Partnership Proposal
Propose a partnership with another organization.
| Field | Type | Required |
|---|---|---|
| partner_name | text | ✓ |
| partner_url | text | |
| partnership_type | select | ✓ |
| benefits | textarea | ✓ |
Options: Strategic, Integration, Marketing, Technical
Type: Standard
Template Structure
interface ProposalTemplate {
id: string
name: string
description: string
category: 'treasury' | 'governance' | 'technical' | 'community'
type: 'standard' | 'expedited' | 'emergency'
template: {
title: string // Template with placeholders
description: string // Markdown template
}
fields: TemplateField[]
}
interface TemplateField {
id: string
label: string
placeholder: string
type: 'text' | 'number' | 'address' | 'select' | 'textarea'
required: boolean
options?: { value: string; label: string }[]
}Category Colors
| Category | Badge Style |
|---|---|
| treasury | Green |
| governance | Blue |
| technical | Purple |
| community | Orange |
Type Requirements
| Type | Min Tier | Voting Period | Time Lock |
|---|---|---|---|
| standard | bronze | 7 days | 2 days |
| expedited | silver | 3 days | 1 day |
| emergency | gold | 1 day | 0 hours |
Creating Custom Templates
Add templates to PROPOSAL_TEMPLATES array:
const customTemplate: ProposalTemplate = {
id: 'custom-id',
name: 'Custom Template',
description: 'Description of template',
category: 'governance',
type: 'standard',
template: {
title: 'Proposal: [field_name]',
description: `
## Section
[field_name] content here.
`
},
fields: [
{
id: 'field_name',
label: 'Field Label',
placeholder: 'Enter value...',
type: 'text',
required: true
}
]
}