Partially Signed Transactions

Listing an Ordinal for Sale

You can create a PSBT to list a specific ordinal that you own for sale at a specific price where someone else can trustlessly complete the partially signed transaction with their inputs to pay the lsited amount as well as their output script which the ordinal will be sent to. Code to do this can be found here: https://github.com/libsv/go-bt/blob/master/ord/listing.go

This can allow for a Dutch auction where the seller can start at a price and keep decreasing until someone takes the offer.

To list an ordinal for sale, you just create a new Bitcoin transaction with 1 input (your ordinal utxo) and 1 output (where you want your payment to go with the listing amount) and sign with SIGHASH_SIGNLE | SIGHASHANYONECANPAY (using forkID). Here is an example:

{
    "hex": "01000000016aced9aba38603b99a6660aaeed4119ced36540ed9e165c16ae41a36b17f028f000000006b4830450221008f321ff2fd9ae676203aae97c0f041ca0a4a99fd80d34efffa7406b65654e06002207ee3b7d45ec247cf83311dfe7984fa1cea830ca5abb438d9cba4534b52fc9fb3c32103b5a2ed046a33eeb504cbdd0aab9737f61a1b48178b284f40ae32b5efb71b89d4ffffffff01f4010000000000001976a9147921b5e173f5f664f566a9cd9514a1d0d85a76b688ac00000000",
    "txid": "a0574646e4fe5a42ae5a2f1ab6e77e1167e9107329f07dc19f816c8f50b32c8e",
    "hash": "a0574646e4fe5a42ae5a2f1ab6e77e1167e9107329f07dc19f816c8f50b32c8e",
    "size": 192,
    "version": 1,
    "locktime": 0,
    "vin": [
        {
            "n": 0,
            "txid": "8f027fb1361ae46ac165e1d90e5436ed9c11d4eeaa60669ab90386a3abd9ce6a",
            "vout": 0,
            "scriptSig": {
                "asm": "30450221008f321ff2fd9ae676203aae97c0f041ca0a4a99fd80d34efffa7406b65654e06002207ee3b7d45ec247cf83311dfe7984fa1cea830ca5abb438d9cba4534b52fc9fb3c3 03b5a2ed046a33eeb504cbdd0aab9737f61a1b48178b284f40ae32b5efb71b89d4",
                "hex": "4830450221008f321ff2fd9ae676203aae97c0f041ca0a4a99fd80d34efffa7406b65654e06002207ee3b7d45ec247cf83311dfe7984fa1cea830ca5abb438d9cba4534b52fc9fb3c32103b5a2ed046a33eeb504cbdd0aab9737f61a1b48178b284f40ae32b5efb71b89d4",
                "isTruncated": false
            },
            "sequence": 4294967295,
            "voutDetails": {
                "value": 1e-8,
                "n": 0,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 c25e9a2b70ec83d7b4fbd0f36f00a86723a48e6b OP_EQUALVERIFY OP_CHECKSIG OP_FALSE OP_IF 6f7264 OP_TRUE 746578742f706c61696e3b636861727365743d7574662d38 OP_FALSE 48656c6c6f2c20776f726c6421 OP_ENDIF",
                    "hex": "76a914c25e9a2b70ec83d7b4fbd0f36f00a86723a48e6b88ac0063036f72645118746578742f706c61696e3b636861727365743d7574662d38000d48656c6c6f2c20776f726c642168",
                    "type": "nonstandard",
                    "isTruncated": false
                },
                "scripthash": "0a45a232478e6e97f88487433fdb762eca3d8346174ec925f3d6d898e9764afc"
            }
        }
    ],
    "vout": [
        {
            "value": 0.000005,
            "n": 0,
            "scriptPubKey": {
                "asm": "OP_DUP OP_HASH160 7921b5e173f5f664f566a9cd9514a1d0d85a76b6 OP_EQUALVERIFY OP_CHECKSIG",
                "hex": "76a9147921b5e173f5f664f566a9cd9514a1d0d85a76b688ac",
                "reqSigs": 1,
                "type": "pubkeyhash",
                "addresses": [
                    "1C3V9TTJefP8Hft96sVf54mQyDJh8Ze4w4"
                ],
                "isTruncated": false
            },
            "scripthash": "80bd9afab38010571221a07495ba4601d052e8f5170c7fe9b076c5709f551a3a"
        }
    ],
    "vincount": 1,
    "voutcount": 1,
    "vinvalue": 1e-8,
    "voutvalue": 0.000005,
    "isUnknown": true
}

To accept the offer, you need to create a new tx, add 2 dummy inputs, the input from the PSBT above, then your input(s) to pay for the tx. Then 1 dummy output equal to the first 2 dummy input amounts (so those sats just passthrough), then your output for where to receive the ordinal, then the output from the PSBT above, then your change output(s), and then an optional platform fee. Then sign the rest of the inputs regularly (SIGHASH_ALL).

Making a bid for an Ordinal

You can create a PSBT to bid at a specific price for a specific ordinal that someone else owns where they can accept the bid truslessly by completing the partially signed transaction. Code to do this can be found here: https://github.com/libsv/go-bt/blob/master/ord/bidding.go

To bid at a price for a specific ordinal, you just create a new Bitcoin transaction (similar to the one above) but backwards. You add 2 dummy inputs, then the ordinal input, then your input(s); 1 dummy output (equal to the amount of the 2 dummy inputs), then your receive output, then dummy seller receive output, then change and platform fees. Then you sign all inputs except for the ordinal input (at index #2) with SIGHASH_SIGNLE (using forkID). Here is an example:

To accept the bid, you need to replace the dummy script in output at index #2 with the script that you want the money to go to and then sign the ordinal input regularly (SIGHASH_ALL).

Example diagram from Magic Eden OSS docs:

Last updated