Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

crowdfund source realm

Package crowdfund is an accounting-only port of the classic Solidity Kickstarter-style crowdfunding contract to a gno...

Overview

Package crowdfund is an accounting-only port of the classic Solidity Kickstarter-style crowdfunding contract to a gno.land realm.

A creator Launches a campaign with a funding goal and a duration (in blocks). Backers Pledge (and may Unpledge before the deadline). After the deadline the creator can Claim if the goal was met, otherwise backers can Refund.

No real coin moves: pledges are tracked as plain uint64 accounting, exactly like the mapping(address => uint) balances of the Solidity original.

Functions 6

func Claim

crossing Action
1func Claim(cur realm, id int)
source

Claim lets the creator take the funds if the goal was met after the deadline.

func Launch

crossing Action
1func Launch(cur realm, goal uint64, durationBlocks int) int
source

Launch creates a new campaign owned by the caller and returns its id.

func Pledge

crossing Action
1func Pledge(cur realm, id int, amount uint64)
source

Pledge backs campaign id with amount (before the deadline).

func Refund

crossing Action
1func Refund(cur realm, id int)
source

Refund returns the caller's pledge if the campaign failed after the deadline.

func Render

1func Render(path string) string
source

Render shows all campaigns with a progress bar, goal, pledged and state.

func Unpledge

crossing Action
1func Unpledge(cur realm, id int, amount uint64)
source

Unpledge withdraws amount from the caller's pledge (before the deadline).

Types 1

type Campaign

struct
1type Campaign struct {
2	ID       int
3	Creator  address
4	Goal     uint64
5	Deadline int64     // block height after which the campaign is closed
6	Pledged  uint64    // running total pledged
7	Claimed  bool      // creator already claimed the funds
8	pledges  *avl.Tree // backer address (string) -> pledged uint64
9}
source

Campaign holds the state of a single crowdfunding campaign.

Imports 5

Source Files 2