So Iâm using a p2sh contract utilizing the new TransactionBuilder class in Cashscript v0.8.0 on BCHouse based on the v2 p2shAssuranceContract.
Overview
The main difference from the v2 assurance contract is that Iâm using several variations of the contract to allow deposits from non-WalletConnect wallets. This makes it:
- extremely simple to pledge to a campaign without connecting a wallet or using a web wallet.
- effectively âmulti-threadedâ (really queuing) so that multiple users can pledge at the same time without conflict.
The design of the contract is tailored more for platform usage though, since the address the user pays to is a covenant that requires the transaction spending the deposit to pledge the funds with the campaign utxo and output an NFT receipt (exactly like Mathieuâs v2 assurance contract) OR return the funds immediately.
So due to this covenant design, either the userâs wallet, the web browser, a platform like BCHouse, or an independent 3rd party (like unspent-phi) must execute the transaction. The web browser and the platform are in the best position to do that given the contract parameters.
Payment Requests
I go through the extra step of using BIP70, JPP, and JPPv2 on BCHouse to provide the contract parameters both in the memo field and url for users - allowing them in the worst case to recover from any potential issues with the platform. Some wallets like Bitcoin.com only provide the payment url to users after the fact while others give access to both the url and memo, so I had to use both unfortunately which can be a problem with legacy QR code readers.
Future work
Either way, a simple link to a 3rd party before payment can provide the contract parameters, for example, a separate site on IPFS like this implementation. An even better solution, is using a CashRPC implementation with the same parameters to store and verify the contract and destination address before funding, as well as act on the contract/utxos.
Additionally, the design of both v2 assurance contract and the BCHouse contract donât allow for compatibility with anyonecanpay type of pledges. This is something that could be fixed by requiring any âover-pledgingâ to be returned to the pledger immediately and allowing payouts IFF the outputs match the campaign goal as opposed to the campaign utxo value being >= the campaign goal:
So: require(output[0].value === fundingGoal)
not require(input[0].value >= fundingGoal)
Anyways, thereâs a lot to be desired from my implementation for both wallet connect and non-walletconnect users. I havenât really made this contract available for users on mainnet (minus my own tests and campaigns) for these reasons.