TransactionBuilder handles collecting multiple instructions and signing them all together before sending the transaction to the chain. There are convenience methods to create spawn, invoke, or delete instructions. Once all instructions are added, the send method will contact one or more nodes to submit the transaction. After a call to the send method, the transaction is ready for new instructions.

If any of the instructions in this transaction fails, all other instructions will fail, too.

### Hierarchy

- TransactionBuilder

## Index

### Constructors

- constructor

### Properties

- bc
- instructions

### Methods

- append
- delete
- deriveID
- hasInstructions
- invoke
- prepend
- send
- spawn
- toString

## Constructors

### constructor

- new TransactionBuilder(bc: ByzCoinRPC): TransactionBuilder

- - Defined in src/v2/byzcoin/transactionBuilder.ts:17

  #### Parameters

  - ##### bc: ByzCoinRPC

  #### Returns TransactionBuilder

## Properties

### Protected bc

bc: ByzCoinRPC

- Defined in src/v2/byzcoin/transactionBuilder.ts:19

### Private instructions

instructions: Instruction[] = []

- Defined in src/v2/byzcoin/transactionBuilder.ts:17

## Methods

### append

- append(inst: Instruction): Instruction

- - Defined in src/v2/byzcoin/transactionBuilder.ts:52

  Appends a new instruction.

  #### Parameters

  - ##### inst: Instruction

    the new instruction to append

  #### Returns Instruction

  the appended instruction

### delete

- delete(iid: Buffer, contractID: string): Instruction

- - Defined in src/v2/byzcoin/transactionBuilder.ts:100

  Appends a delete instruction.

  #### Parameters

  - ##### iid: Buffer

    the instance ID where the instruction is sent to

  - ##### contractID: string

    to be deleted - must match the actual contract

  #### Returns Instruction

  new instruction - can be used for deriveID

### deriveID

- deriveID(index: number, name?: string): InstanceID

- - Defined in src/v2/byzcoin/transactionBuilder.ts:110

  Returns the ID that will be produced by the given instruction

  #### Parameters

  - ##### index: number

    of the instruction

  - ##### Default value name: string = ""

    if given, will be passed to deriveID

  #### Returns InstanceID

### hasInstructions

- hasInstructions(): boolean

- - Defined in src/v2/byzcoin/transactionBuilder.ts:42

  #### Returns boolean

  true if one or more instructions are available.

### invoke

- invoke(iid: Buffer, contractID: string, command: string, args: Argument[]): Instruction

- - Defined in src/v2/byzcoin/transactionBuilder.ts:89

  Appends an invoke instruction.

  #### Parameters

  - ##### iid: Buffer

    the instance ID where the instruction is sent to

  - ##### contractID: string

    the contractID to invoke

  - ##### command: string

    to be invoked on the contract

  - ##### args: Argument[]

    arguments of the command

  #### Returns Instruction

  new instruction - can be used for deriveID

### prepend

- prepend(inst: Instruction): Instruction

- - Defined in src/v2/byzcoin/transactionBuilder.ts:63

  Prepends a new instruction

  #### Parameters

  - ##### inst: Instruction

    the instruction to prepend

  #### Returns Instruction

  the prepended instruction

### send

- send(signers: ISigner[][], wait?: number): Promise<[ClientTransaction, AddTxResponse]>

- - Defined in src/v2/byzcoin/transactionBuilder.ts:31

  Signs all instructions and sends them to the nodes. The `instructions` field is only emptied if the transaction has been accepted successfully. If the transaction fails, it can be retried.

  #### Parameters

  - ##### signers: ISigner[][]

    one set of signers per instruction. If there is only one set for multiple instructions, always the same set of signers will be used.

  - ##### Default value wait: number = 0

    if 0, doesn't wait for inclusion. If > 0, waits for inclusion for this many blockIntervals.

  #### Returns Promise<[ClientTransaction, AddTxResponse]>

### spawn

- spawn(iid: Buffer, contractID: string, args: Argument[]): Instruction

- - Defined in src/v2/byzcoin/transactionBuilder.ts:76

  Appends a spawn instruction.

  #### Parameters

  - ##### iid: Buffer

    the instance ID where the instruction is sent to

  - ##### contractID: string

    the contractID to spawn

  - ##### args: Argument[]

    arguments of the contract

  #### Returns Instruction

  new instruction - can be used for deriveID

### toString

- toString(): string

- - Defined in src/v2/byzcoin/transactionBuilder.ts:120

  returns a useful and readable representation of all instructions in this transaction.

  #### Returns string

Generated using TypeDoc