@bitcann/contracts
Version:
Bitcoin Cash for Assigned Names and Numbers
100 lines • 9.58 kB
JavaScript
export default {
'contractName': 'ConflictResolver',
'constructorInputs': [],
'abi': [
{
'name': 'call',
'inputs': [],
},
],
'bytecode': 'OP_TXINPUTCOUNT OP_4 OP_NUMEQUALVERIFY OP_TXOUTPUTCOUNT OP_4 OP_NUMEQUALVERIFY OP_INPUTINDEX OP_1 OP_NUMEQUALVERIFY OP_INPUTINDEX OP_UTXOBYTECODE OP_INPUTINDEX OP_OUTPUTBYTECODE OP_EQUALVERIFY OP_INPUTINDEX OP_OUTPUTTOKENCATEGORY OP_0 OP_EQUALVERIFY OP_0 OP_UTXOBYTECODE OP_2 OP_UTXOBYTECODE OP_OVER OP_EQUALVERIFY OP_3 OP_UTXOBYTECODE OP_OVER OP_EQUALVERIFY OP_2 OP_OUTPUTBYTECODE OP_EQUALVERIFY OP_0 OP_UTXOTOKENCATEGORY OP_2 OP_UTXOTOKENCATEGORY 20 OP_SPLIT OP_SWAP OP_ROT OP_EQUALVERIFY OP_1 OP_EQUALVERIFY OP_2 OP_UTXOTOKENCATEGORY OP_3 OP_UTXOTOKENCATEGORY OP_EQUALVERIFY OP_2 OP_UTXOTOKENCOMMITMENT 14 OP_SPLIT OP_NIP OP_3 OP_UTXOTOKENCOMMITMENT 14 OP_SPLIT OP_NIP OP_EQUALVERIFY OP_2 OP_UTXOTOKENAMOUNT OP_3 OP_UTXOTOKENAMOUNT OP_LESSTHAN OP_VERIFY OP_0 OP_OUTPUTTOKENAMOUNT OP_0 OP_UTXOTOKENAMOUNT OP_3 OP_UTXOTOKENAMOUNT OP_ADD OP_NUMEQUALVERIFY OP_3 OP_OUTPUTTOKENCATEGORY OP_0 OP_EQUAL',
'source': "pragma cashscript 0.11.5;\n\ncontract ConflictResolver() {\n /**\n * Resolves a conflict between two competing registration auctions for the same name.\n * \n * RULE:\n * - If any new auction is created when an auction already exists, then the new auction is open for penalization.\n *\n * Anyone can provide proof of an active auction's existence and take away the funds from the \"new\" invalid auction\n * as a form of reward for keeping the system secure and predictable.\n * Therefore, it's the responsibility of the application to check for any running auctions for the same name.\n * \n * @inputs\n * - Input0: Registry Contract's authorizedThreadNFT i.e immutable NFT with commitment that has the lockingBytecode of this contract\n * - Input1: Any input from this contract.\n * - Input2: Valid auctionNFT from Registry Contract.\n * - Input3: Invalid auctionNFT from Registry Contract.\n * \n * @outputs\n * - Output0: Registry Contract's authorizedThreadNFT back to the Registry contract.\n * - Output1: Input1 back to this contract without any change.\n * - Output2: Valid auctionNFT back to Registry Contract.\n * - Output3: BCH change/reward to caller.\n */\n function call() {\n require(tx.inputs.length == 4, \"Transaction: must have exactly 4 inputs\");\n require(tx.outputs.length == 4, \"Transaction: must have exactly 4 outputs\");\n\n // This contract can only be used at input1 and it should return the input1 back to itself.\n require(this.activeInputIndex == 1, \"Input 1: conflict resolver contract UTXO must be at this index\");\n require(tx.inputs[this.activeInputIndex].lockingBytecode == tx.outputs[this.activeInputIndex].lockingBytecode, \"Input 1: locking bytecode must match output 1\");\n // Ensure that no tokenCategory is minted here.\n require(tx.outputs[this.activeInputIndex].tokenCategory == 0x, \"Output 1: must not have any token category (pure BCH only)\");\n\n // This contract can only be used with the 'lockingbytecode' used in the 0th input.\n // Note: This contract can be used with any contract that fulfills these conditions, and that is fine\n // because those contracts will not be manipulating the utxos of the Registry contract. Instead, they will\n // be manipulating their own utxos.\n bytes registryInputLockingBytecode = tx.inputs[0].lockingBytecode;\n require(tx.inputs[2].lockingBytecode == registryInputLockingBytecode, \"Input 2: valid auction locking bytecode does not match registry input's locking bytecode\");\n require(tx.inputs[3].lockingBytecode == registryInputLockingBytecode, \"Input 3: invalid auction locking bytecode does not match registry input's locking bytecode\");\n require(tx.outputs[2].lockingBytecode == registryInputLockingBytecode, \"Output 2: valid auction locking bytecode does not match registry input's locking bytecode\");\n\n // All the token categories in the transaction should be the same.\n bytes registryInputCategory = tx.inputs[0].tokenCategory;\n\n // auctionNFT should be mutable\n bytes auctionCategory, bytes auctionCapability = tx.inputs[2].tokenCategory.split(32);\n require(auctionCategory == registryInputCategory, \"Input 2: valid auction token category prefix must match registry\");\n // Valid auction capability should be mutable.\n require(auctionCapability == 0x01, \"Input 2: valid auction capability must be mutable (0x01)\");\n\n // Invalid and valid auctionNFTs both should have the same category and capability.\n require(tx.inputs[2].tokenCategory == tx.inputs[3].tokenCategory, \"Input 2 and 3: auction token categories must match\");\n // Both auctionNFTs should also have the same 'name'\n require(tx.inputs[2].nftCommitment.split(20)[1] == tx.inputs[3].nftCommitment.split(20)[1], \"Input 2 and 3: auction names must match\");\n // The valid auctionNFT will have a lower registrationID\n require(tx.inputs[2].tokenAmount < tx.inputs[3].tokenAmount, \"Input 2: valid auction registration ID must be lower than input 3\");\n\n // tokenAmount from the invalid auctionNFT goes to the authorizedThreadNFT to be accumulated later\n // and merged back with the CounterNFT using the `Accumulator` Contract\n require(tx.outputs[0].tokenAmount == tx.inputs[0].tokenAmount + tx.inputs[3].tokenAmount, \"Output 0: token amount must equal input 0 + input 3 amounts (accumulation)\");\n\n // Attach any output to take away the funds as reward\n require(tx.outputs[3].tokenCategory == 0x, \"Output 3: reward must be pure BCH (no token category)\");\n }\n}",
'debug': {
'bytecode': 'c3549dc4549dc0519dc0c7c0cd88c0d1008800c752c7788853c7788852cd8800ce52ce01207f7c7b88518852ce53ce8852cf01147f7753cf01147f778852d053d09f6900d300d053d0939d53d10087',
'sourceMap': '27:12:27:28;:32::33;:4::78:1;28:12:28:29:0;:33::34;:4::80:1;31:12:31:33:0;:37::38;:4::106:1;32:22:32:43:0;:12::60:1;:75::96:0;:64::113:1;:4::164;34:23:34:44:0;:12::59:1;:63::65:0;:4::129:1;40:51:40:52:0;:41::69:1;41:22:41:23:0;:12::40:1;:44::72:0;:4::166:1;42:22:42:23:0;:12::40:1;:44::72:0;:4::168:1;43:23:43:24:0;:12::41:1;:4::168;46:44:46:45:0;:34::60:1;49:63:49:64:0;:53::79:1;:86::88:0;:53::89:1;50:12:50:27:0;:31::52;:4::122:1;52:33:52:37:0;:4::99:1;55:22:55:23:0;:12::38:1;:52::53:0;:42::68:1;:4::124;57:22:57:23:0;:12::38:1;:45::47:0;:12::48:1;:::51;:65::66:0;:55::81:1;:88::90:0;:55::91:1;:::94;:4::139;59:22:59:23:0;:12::36:1;:49::50:0;:39::63:1;:12;:4::134;63:23:63:24:0;:12::37:1;:51::52:0;:41::65:1;:78::79:0;:68::92:1;:41;:4::172;66:23:66:24:0;:12::39:1;:43::45:0;:4::104:1',
'logs': [],
'requires': [
{
'ip': 2,
'line': 27,
'message': 'Transaction: must have exactly 4 inputs',
},
{
'ip': 5,
'line': 28,
'message': 'Transaction: must have exactly 4 outputs',
},
{
'ip': 8,
'line': 31,
'message': 'Input 1: conflict resolver contract UTXO must be at this index',
},
{
'ip': 13,
'line': 32,
'message': 'Input 1: locking bytecode must match output 1',
},
{
'ip': 17,
'line': 34,
'message': 'Output 1: must not have any token category (pure BCH only)',
},
{
'ip': 23,
'line': 41,
'message': "Input 2: valid auction locking bytecode does not match registry input's locking bytecode",
},
{
'ip': 27,
'line': 42,
'message': "Input 3: invalid auction locking bytecode does not match registry input's locking bytecode",
},
{
'ip': 30,
'line': 43,
'message': "Output 2: valid auction locking bytecode does not match registry input's locking bytecode",
},
{
'ip': 39,
'line': 50,
'message': 'Input 2: valid auction token category prefix must match registry',
},
{
'ip': 41,
'line': 52,
'message': 'Input 2: valid auction capability must be mutable (0x01)',
},
{
'ip': 46,
'line': 55,
'message': 'Input 2 and 3: auction token categories must match',
},
{
'ip': 57,
'line': 57,
'message': 'Input 2 and 3: auction names must match',
},
{
'ip': 63,
'line': 59,
'message': 'Input 2: valid auction registration ID must be lower than input 3',
},
{
'ip': 71,
'line': 63,
'message': 'Output 0: token amount must equal input 0 + input 3 amounts (accumulation)',
},
{
'ip': 76,
'line': 66,
'message': 'Output 3: reward must be pure BCH (no token category)',
},
],
},
'compiler': {
'name': 'cashc',
'version': '0.11.5',
},
'updatedAt': '2025-09-01T12:51:28.996Z',
};
//# sourceMappingURL=ConflictResolver.js.map