Skip to content
Discussions/App Development/Can keyword non-consuming effectively allow for double spent?Forum ↗

Can keyword non-consuming effectively allow for double spent?

App Development4 posts262 views5 likesLast activity Nov 2021
AM
amiracamOP
Nov 2021

most definitely a newbie question, but I’m going thru the cert prep and in the video, it illustrates a choice where a new token is created and states that by default a token will be archived, it also goes to state that therefore by default it protects against double spent, however it also goes to say that said mechanism can be defeated by prefixing the choice with the keyword “non consuming”

If so, is it then possible to allow for double spending?

What is the scenario that " non consuming" is meant to provide for?

Isn’t the DAML design about proposing a new contract state which if approved by the signatories becomes the current state i.e., in all cases?

thanks

-Charles

ST
stefanobaghino-da
Nov 2021

You can mark certain choices as nonconsuming and this is under your control, as much as it is visible to whomever chooses to agree to the terms described in the template that includes this choice. It only allows a “double spend” if that particular choice should rather consume the contract. It doesn’t defeat the mechanism, it adds an additional avenue of using contracts.

In general, if the asset should be consumed by the choice, all you have to do it is mark the choice as consuming and no “double spends” will be allowed. No contract can be consumed twice.

AM
amiracam
Nov 2021

thank you, but to be clear my understanding is that the default is “consuming” and that therefore no explicit annotation with “consuming” is required , do I have that correct ?

ST
stefanobaghino-da
Nov 2021

It’s not strictly required, that’s correct. I just wanted to be explicit about it. Please note that there are slightly different possibilities: Reference: choices — Daml SDK 1.17.1 documentation

← Back to Discussions