Skip to content

Instantly share code, notes, and snippets.

@katelynsills
Last active April 22, 2020 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katelynsills/a4da9e9aa8e9a56140c138722a626fee to your computer and use it in GitHub Desktop.
Save katelynsills/a4da9e9aa8e9a56140c138722a626fee to your computer and use it in GitHub Desktop.
How to mint payments and give them to users
const offerHook = userOfferHandle => {
const ticketsAmount = baytownBucks(1000);
const ticketsPayment = baytownBucksMint.mintPayment(ticketsAmount);
let tempContractHandle;
const contractSelfInvite = zcf.makeInvitation(
offerHandle => (tempContractHandle = offerHandle),
);
zcf
.getZoeService()
.offer(
contractSelfInvite,
harden({ give: { Ticket: ticketsAmount } }),
harden({ Ticket: ticketsPayment }),
).then(() => {
// the contract transfers tickets to the auditorium leveraging Zoe offer safety
zcf.reallocate(
[tempContractHandle, userOfferHandle],
[
zcf.getCurrentAllocation(userOfferHandle),
zcf.getCurrentAllocation(tempContractHandle),
],
);
zcf.complete([tempContractHandle, userOfferHandle]);
return defaultAcceptanceMsg;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment