Response: {
"error": "formula
if (NOT exists(trigger.data["signed_message"]))
bounce("signed_message field is mandatory");
if (NOT exists(trigger.data["authors"]))
bounce('authors field is mandatory');
if (NOT exists(trigger.data["meta"]))
bounce("meta field is mandatory");
$spack = json_parse(trigger.data["signed_message"]) || json_parse(trigger.data["authors"]) || json_parse(trigger.data["meta"]);
if (NOT is_valid_signed_package($spack, $spack.authors[0]["address"]))
bounce("The signed message signature is invalid");
if (NOT $spack.signed_message["serial"])
bounce("The signed message does not contains a serial field");
if (NOT $spack.signed_message["NFT"])
bounce("The signer of this message does not include a NFT field");
$NFT = $saleInfo($spack.signed_message["NFT"]);
if (NOT $NFT)
bounce("That NFT does not exist");
//Prevent author from stealing their NFTs from other people
if ($NFT.soldBy != $NFT.author)
bounce("You cannot claim an NFT that is not being sold by their author");
if ($NFT.author != $spack.authors[0]["address"])
bounce("The signer of that message is not the author of that NFT");
//NFTs have to be created with redeemable: true to be redeemable
if (NOT $NFT.redeem)
bounce("That NFT is not redeemable");
//Check if sale is over and expire was set in the signed message
if ($spack.signed_message["expireDate"])
if ($NFT.endTime < timestamp OR $spack.signed_message["expireDate"] < timestamp)
bounce("That NFT is no longer claimable");
//Check if the NFT is address-locked
if ($spack.signed_message["claimer"])
if ($spack.signed_message["claimer"] != trigger.address)
bounce("You cannot claim that NFT from that address");
$signedAmount = $spack.signed_message["amount"] OTHERWISE 1;
//Uncapped asset, we can issue whatever amount was signed
if (NOT $NFT.cap){
$amount = $signedAmount;
}
//If it is going over the cap we need to reduce the claimed amount to match the asset cap
else {
if ($NFT.unitsSold + $signedAmount > $NFT.cap)
$amount = $NFT.cap - $NFT.unitsSold;
else
$amount = $signedAmount;
}
//All copies were issued
if ($amount == 0)
bounce("All copies of that NFT have been already minted");
failed: bad address in is_valid_signed_package: false"
}