Documentation

Crowdfund

All-or-nothing fundraising with a goal and deadline. If the goal is met by the deadline, the creator receives the funds. Otherwise, contributors can claim refunds.

Use Cases

  • Community fundraisers with transparent goals
  • Project kickstarters with automatic refund on failure
  • Charity drives with on-chain accountability

Init Parameters

The contract is initialized through the initialize execute method after deployment:

ParameterTypeDescription
titleStringCampaign title (max 128 chars)
descriptionStringCampaign description (max 512 chars)
token_idTokenIdToken to accept (use all-zeros for native NORN)
goalu128Fundraising goal amount
deadlineu64Unix timestamp when the campaign ends

Execute Methods

MethodParametersDescription
initializetitle, description, token_id, goal, deadlineCreate the campaign. Only callable once.
contributeamount: u128Contribute tokens to the campaign. Must be active and before deadline.
finalize--End the campaign. If goal met, funds go to creator. If not, status set to Failed.
refund--Claim a refund after campaign has failed. Returns contributor's full amount.

Query Methods

MethodParametersReturnsDescription
get_config--CrowdfundConfigFull campaign configuration and status
get_contributionaddress: Addressu128Contribution amount for a specific address
get_total_raised--u128Total tokens raised so far
get_contributor_count--u64Number of unique contributors

Key Types

CampaignStatus

pub enum CampaignStatus {
    Active,     // Campaign is accepting contributions
    Succeeded,  // Goal met, funds released to creator
    Failed,     // Goal not met, contributors can refund
}

CrowdfundConfig

pub struct CrowdfundConfig {
    pub creator: Address,
    pub title: String,
    pub description: String,
    pub token_id: TokenId,
    pub goal: u128,
    pub deadline: u64,
    pub status: CampaignStatus,
    pub created_at: u64,
}

CLI Usage

# Deploy a crowdfund contract
norn wallet deploy-loom --name my-crowdfund
 
# Upload bytecode
norn wallet upload-bytecode --loom-id <LOOM_ID> \
  --bytecode crowdfund.wasm
 
# Initialize (borsh-encoded input)
norn wallet execute-loom --loom-id <LOOM_ID> --input <HEX>
 
# Query config
norn wallet query-loom --loom-id <LOOM_ID>