@dashevo/dashcore-lib
Version:
A pure and powerful JavaScript Dash library.
98 lines (56 loc) • 2.26 kB
Markdown
**Usage**: `new Opcode(data)`
**Description**: Instantiate an Opcode from its Opcode string or number
| parameters | type | required | Description |
| ---------- | ------------- | -------- | --------------------------- |
| **arg** | Number/String | yes | The opcode number or string |
**Returns**: {Opcode} A new Opcode instance
**Description**: map of the available opcodes
**Description**: Instantiate a new Opcode from a Buffer
**Parameters**:
| parameters | type | required | Description |
| ---------- | ------ | -------- | ----------- |
| **opcode** | Opcode | yes | |
**Returns**: {Boolean} - true if opcode is one of OP_0, OP_1, ..., OP_16
**Description**: Instantiate a new Opcode from a Buffer
**Parameters**:
| parameters | type | required | Description |
| ---------- | ------ | -------- | ---------------------- |
| **buf** | Buffer | yes | A Buffer of the script |
**Returns**: {Opcode}
**Description**: Instantiate a new Opcode from a Number
**Parameters**:
| parameters | type | required | Description |
| ---------- | ------ | -------- | --------------------- |
| **num** | Number | yes | A valid opcode number |
**Returns**: {Opcode}
**Description**: Instantiate a new Opcode from a smallInt
**Parameters**:
| parameters | type | required | Description |
| ---------- | ------ | -------- | ----------- |
| **n** | Number | yes | a small int |
**Returns**: {Opcode}
**Description**: Will return the Opcode as an hex
**Parameters**: None.
**Returns**: {string}
**Description**: Will return the opcode as a buffer
**Parameters**: None.
**Returns**: {Buffer} A buffer of the opcode
**Description**: Will output the opcode encoded as hex string
**Parameters**: None.
**Returns**: {number}
**Description**: Will return a string formatted for the console
**Parameters**: None.
**Returns**: {string} Script Opcode representation
```js
const opcode = new Opcode(...);
opcode.toInspect() // <Opcode: 041ff0fe0f7b15ffaa....>
```