|
| 1 | +# Transaction Format |
| 2 | + |
| 3 | +- [Transaction](#transaction) |
| 4 | +- [Input](#input) |
| 5 | + - [InputCoin](#inputcoin) |
| 6 | + - [InputContract](#inputcontract) |
| 7 | +- [Output](#output) |
| 8 | + - [OutputCoin](#outputcoin) |
| 9 | + - [OutputContract](#outputcontract) |
| 10 | +- [Witness](#witness) |
| 11 | + |
| 12 | +## Transaction |
| 13 | + |
| 14 | +| name | type | description | |
| 15 | +| ---------------- | ----------------------- | -------------------------- | |
| 16 | +| `scriptLength` | `uint16` | Script length, in words. | |
| 17 | +| `script` | `byte[]` | Script to execute. | |
| 18 | +| `gasPrice` | `uint64` | Gas price for transaction. | |
| 19 | +| `gasLimit` | `uint64` | Gas limit for transaction. | |
| 20 | +| `inputsCount` | `uint8` | Number of inputs. | |
| 21 | +| `inputs` | [Input](#input)`[]` | List of inputs. | |
| 22 | +| `outputsCount` | `uint8` | Number of outputs. | |
| 23 | +| `outputs` | [Output](#output)`[]` | List of outputs. | |
| 24 | +| `witnessesCount` | `uint8` | Number of witnesses. | |
| 25 | +| `witnesses` | [Witness](#witness)`[]` | List of witnesses. | |
| 26 | + |
| 27 | +## Input |
| 28 | + |
| 29 | +``` |
| 30 | +enum InputType : uint8 { |
| 31 | + Coin = 0, |
| 32 | + Contract = 1, |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +| name | type | description | |
| 37 | +| ------ | ----------------------------------------------------------------- | -------------- | |
| 38 | +| `type` | `InputType` | Type of input. | |
| 39 | +| `data` | One of [InputCoin](#inputcoin) or [InputContract](#inputcontract) | Input data. | |
| 40 | + |
| 41 | + |
| 42 | +### InputCoin |
| 43 | + |
| 44 | +| name | type | description | |
| 45 | +| -------------- | ---------- | --------------------------------------------------- | |
| 46 | +| `utxoID` | `byte[32]` | UTXO ID. | |
| 47 | +| `dataLength` | `uint16` | Length of data, in bytes. | |
| 48 | +| `data` | `byte[]` | Data to input into script. | |
| 49 | +| `witnessIndex` | `uint8` | Index of witness that authorizes spending the coin. | |
| 50 | + |
| 51 | +### InputContract |
| 52 | + |
| 53 | +| name | type | description | |
| 54 | +| ------------ | ---------- | ------------ | |
| 55 | +| `utxoID` | `byte[32]` | UTXO ID. | |
| 56 | +| `contractID` | `byte[32]` | Contract ID. | |
| 57 | + |
| 58 | +## Output |
| 59 | + |
| 60 | +``` |
| 61 | +enum OutputType : uint8 { |
| 62 | + Coin = 0, |
| 63 | + Contract = 1, |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +| name | type | description | |
| 68 | +| ------ | --------------------------------------------------------------------- | --------------- | |
| 69 | +| `type` | `OutputType` | Type of output. | |
| 70 | +| `data` | One of [OutputCoin](#outputcoin) or [OutputContract](#outputcontract) | Output data. | |
| 71 | + |
| 72 | +### OutputCoin |
| 73 | + |
| 74 | +| name | type | description | |
| 75 | +| -------- | ---------- | --------------------------------- | |
| 76 | +| `to` | `byte[32]` | Receiving address or script hash. | |
| 77 | +| `amount` | `uint64` | Amount of coins to send. | |
| 78 | + |
| 79 | +### OutputContract |
| 80 | + |
| 81 | +| name | type | description | |
| 82 | +| -------------------- | ------- | ------------------------------------------------------- | |
| 83 | +| `inputIndex` | `uint8` | Index of input contract. | |
| 84 | +| `amountWitnessIndex` | `uint8` | Index of witness for amount of coins owned by contract. | |
| 85 | +| `stateWitnessIndex` | `uint8` | Index of witness for state root of contract. | |
| 86 | + |
| 87 | +## Witness |
| 88 | + |
| 89 | +| name | type | description | |
| 90 | +| ------------ | -------- | --------------------------------- | |
| 91 | +| `dataLength` | `uint16` | Length of witness data, in bytes. | |
| 92 | +| `data` | `byte[]` | Witness data. | |
0 commit comments