Crowdfunding

Introduction

Automatic crowdfunding features are included in Signup - allowing users to make non-custodial contribution to a fundraising campaign.

Starting a campaign is as simple as beginning to accept contributions.

This can be done using the provider:

import Signup from "@signupcash/provider";
const signup = new Signup.cash({ addr: 'DEVELOPER BCH ADDRESS'});
// Determine what the user is willing to contribute before requesting it
const donationAmount = Number(satoshis)
const donationUnit = "SATS" //or "BCH"
‚Äč
// Request the contribution from the user using [sendAnyonCanPayCommitment](https://developer.bitcoin.org/glossary.html#term-SIGHASH_ANYONECANPAY)
const { payload } = await signup.sendAnyoneCanPayCommitment(
// Give the wallet info on the campaign outputs
// This must be consistent **across contributions** to be considered the "same campaign"
recipients: [{
value: 10000, //usually far more than what a single contributor will pay
address: "bitcoincash:bc1..."
}],
// Users contribution to the above recipients (usually far less than total)
donationAmount
donationUnit,
// Additional data which the campaign would like to be signed by contributor
{
alias: "",
comment: "",
title: ""
}
);

Then if the user approves the contribution request, an unbroadcasted signed transaction will be returned for those outputs, encoded in base64 and compatible with current Flipstarter campaigns.

This can then be stored, parsed, used to update the UI, etc.

Please refer to the Flipstarter backend's source code for more information on how to parse, store, and ultimately broadcast the final transaction if enough funds are collected.