Last active
April 22, 2020 04:14
-
-
Save katelynsills/a4da9e9aa8e9a56140c138722a626fee to your computer and use it in GitHub Desktop.
How to mint payments and give them to users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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