Input Redemption
Spending money you already hold means pointing at the specific coins you own and proving you are allowed to spend them. This gives an application a way to name those coins when asking a wallet to build a transaction, along with everything the wallet needs to check the claim before it signs.
Summary
- Why
- Applications needed a way to spend and prove the validity of existing transaction outputs, not just create new ones, so that tokens or data already on chain could be updated, extended, or consumed.
- What
- BRC-4 defines how an application tells a wallet which existing transaction outputs to unlock and spend as inputs to a new transaction, including the proof and unlocking data the wallet needs.
- How
- The application adds an "inputs" field to its BRC-1 transaction request, keyed by transaction ID, each containing the raw transaction, a proof, and an "outputsToRedeem" array listing which output index to spend and the unlocking script to use.
What this lets you do
- Request that a wallet spend a specific existing output as an input
- Attach proof data so the wallet can verify the output really exists
- Supply a pre-built unlocking script for each input
- Describe why an input is being redeemed with a spendingDescription
- Chain new transactions to prior tokenized outputs
Written by claude-sonnet-5 from the specification text. Where the two differ, the original is correct.
Reference for an AI
Everything an assistant needs to answer questions about BRC-4 accurately, including what it depends on.
The specification
Abstract
We define a mechanism by which BRC-1 applications can denote UTXOs to be unlocked and redeemed by wallets as part of new Bitcoin transactions. We extend the message format defined by BRC-1 with information about the inputs requested by the application, including all information needed for a wallet to check the veracity of any inputs being redeemed.
Motivation
BRC-1 defines a mechanism for an application to request the creation of a Bitcoin transaction by a wallet, but it is incomplete without a way for applications to consume and use tokens that previously existed. Allowing applications to unlock and redeem inputs as part of their transactions also facilitates their ability to update, extend or delete assets that are tokenized within Bitcoin UTXOs.
Status Note
BRC-4 is historical. Current wallets consume application-provided inputs through BRC-100 createAction with inputBEEF, inputs[].outpoint, inputs[].unlockingScript or inputs[].unlockingScriptLength, inputs[].inputDescription, and optional sequenceNumber. Extended BRC-8 input envelopes are deprecated for current implementations.
Specification
We extend the BRC-1 Transaction Creation Request message with an additional field, the inputs field. This is an object whose keys are the TXIDs of transactions that contain outputs which are to be spent as part of this transaction, and whose values comprise extended BRC-8 transaction envelopes.
In addition to the normal envelope fields, we specify that these input envelopes contain an additional field called outputsToRedeem, which is an array of objects. Each of the objects comprises an output from the subject transaction that is to be redeemed and used as input to the transaction being requested by the application.
We specify that each of the objects in the array contains index and unlockingScript. The index value is an integer that denotes which output to redeem from the transaction, and the unlockingScript comprises a BRC-14 hex-formatted input script.
We further specify that each of the elements in each of the outputsToRedeem arrays may contain an additional spendingDescription string that describes the redemption of the tokens being used.
Example
Here is an example of a Transaction Creation Request object that contains an input:
{
"inputs": {
"900b7e9ced44f8a7605bd4c1b7054b8fb958385998954d772820a8b81eabb56f": {
"rawTx": "010000000135620d3a8fb626b763cb7b9a3c3197eda9bd6709ef1e4ebc2b359607800eaa95020000006b483045022100c3ec1792f1780e453c6ea692271bcc5388fb179d6455897f4b4200706e8b9f150220352cc2ff81a5c698e4626aec8976643134efab91ca1c80729670c2d007c77cfd4121037798f038cb7fc18b9d67baa87ed33122eb7be65b95b0dd304dc476c60043773dffffffff03e803000000000000c4210399322f558d92ced9c45d3bfe7dc5c01b830a4b61d71695ab0a1fa2cd90aba8b9ac2131546f446f44744b7265457a6248594b466a6d6f42756475466d53585855475a473462812d4eeb030fa496c2965f7e0f0b0e825d0547aceb7a9d4c76fd17e795753d8e2e0e82274ab36744a7968a43dc45b1cbdfab6c473045022100a58914da5346960ecb4de964f0f1e1be43a7645a11449c3a209f3fd69b34209b02205d4d4294d04c5f87fb16c2cdc3d9b41f9866fb3d7a690da08089c972d1393d816d75c8000000000000001976a91473a95c0b12e33b3d79f80508200a075bbab0906588ac4ea80200000000001976a91478daf10df51b3ea4c9292a72bf2e1e1d48ebe11288ac00000000",
"proof": {
"index": 2,
"txOrId": "900b7e9ced44f8a7605bd4c1b7054b8fb958385998954d772820a8b81eabb56f",
"targetType": "header",
"target": "00000020ed40984238c0d6ed157cfd4fda4b284b48bb5c3b00b3172a2b030000000000006dfcabcc55b822548d10198ad1ddc62700947c8053213bf254b5229c92b9f448c6d32f64f13d051aa8201615",
"nodes": [
"9c97050e4c5fcc7f3ae7f7de83668d1968a626d70690654dab0398b75ca447a1",
"fde37bbbec5cb48c085749aea7059412cc59c339bbc3e98960c081632382d538"
]
},
"outputsToRedeem": [
{
"index": 0,
"unlockingScript": "473044022040ac4ef063c5139ef940860ec993dea2b38f2226cb841c231d60833d185934d50220760c48202fc150e3090ffbda4ccfe4ebce36715b4396d3555fb2f3dc03346e5cc2",
"spendingDescription": "Complete a ToDo list item"
}
]
}
},
"description": "Complete a TODO task: \\"test\\""
}
Implementations
This functionality is implemented by current bsv-blockchain/ts-sdk BRC-100 wallet interfaces and bsv-blockchain/wallet-toolbox storage/action processing.