---
title: "Class: TransactionBuilder"
canonical_url: "https://nimiq.dev/web-client/reference/classes/transactionbuilder"
---
# Class: TransactionBuilder

[@nimiq/core](../globals) / TransactionBuilder

Defined in: @nimiq/core/types/wasm/web.d.ts:2438

The TransactionBuilder class provides helper methods to easily create standard types of transactions.
It can only be instantiated from a Client with `client.transactionBuilder()`.

## Methods

### [dispose]()

> **[dispose]**(): `void`

Defined in: @nimiq/core/types/wasm/web.d.ts:2441

#### Returns

`void`

---

### free()

> **free**(): `void`

Defined in: @nimiq/core/types/wasm/web.d.ts:2440

#### Returns

`void`

---

### newAddStake()

> `static` **newAddStake**(`sender`, `staker_address`, `value`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2450

Adds stake to a staker in the staking contract and transfers `value` amount of luna (NIM's smallest unit)
from the sender account to this staker.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for value and fee do not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### staker_address

[`Address`](Address)

##### value

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newBasic()

> `static` **newBasic**(`sender`, `recipient`, `value`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2459

Creates a basic transaction that transfers `value` amount of luna (NIM's smallest unit) from the
sender to the recipient.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for value and fee do not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### recipient

[`Address`](Address)

##### value

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newBasicWithData()

> `static` **newBasicWithData**(`sender`, `recipient`, `data`, `value`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2468

Creates a basic transaction that transfers `value` amount of luna (NIM's smallest unit) from the
sender to the recipient. It can include arbitrary `data`, up to 64 bytes.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for value and fee do not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### recipient

[`Address`](Address)

##### data

`Uint8Array`

##### value

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newCreateStaker()

> `static` **newCreateStaker**(`sender`, `delegation`, `value`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2477

Creates a new staker in the staking contract and transfers `value` amount of luna (NIM's smallest unit)
from the sender account to this new staker.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for value and fee do not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### delegation

[`Address`](Address)

##### value

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newCreateValidator()

> `static` **newCreateValidator**(`sender`, `reward_address`, `signing_key`, `voting_key_pair`, `signal_data`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2485

Registers a new validator in the staking contract.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### reward_address

[`Address`](Address)

##### signing_key

[`PublicKey`](PublicKey)

##### voting_key_pair

[`BLSKeyPair`](BLSKeyPair)

##### signal_data

`string`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newDeactivateValidator()

> `static` **newDeactivateValidator**(`sender`, `validator`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2493

Deactivates a validator in the staking contract.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### validator

[`Address`](Address)

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newDeleteValidator()

> `static` **newDeleteValidator**(`sender`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2501

Deleted a validator the staking contract. The deposit is returned to the Sender

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newRemoveStake()

> `static` **newRemoveStake**(`recipient`, `value`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2510

Removes stake from the staking contract and transfers `value` amount of luna (NIM's smallest unit)
from the staker to the recipient.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for value and fee do not fit within a u64 or the networkId is unknown.

#### Parameters

##### recipient

[`Address`](Address)

##### value

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newRetireStake()

> `static` **newRetireStake**(`sender`, `retire_stake`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2519

Retires a portion of the inactive stake balance of the staker. This is a
signaling transaction and as such does not transfer any value.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for fee and `retire_stake` do not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### retire_stake

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newRetireValidator()

> `static` **newRetireValidator**(`sender`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2527

Retires a validator in the staking contract.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newSetActiveStake()

> `static` **newSetActiveStake**(`sender`, `new_active_balance`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2536

Sets the active stake balance of the staker. This is a
signaling transaction and as such does not transfer any value.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the numbers given for fee and `new_active_balance` do not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### new_active_balance

`bigint`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newSetSignalData()

> `static` **newSetSignalData**(`sender`, `validator`, `signal_data`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2547

Sets the signal data of a validator in the staking contract. In contrast to
`newUpdateValidator`, this transaction is signed with the validator's *signing (warm) key*,
so the cold key is not required to signal protocol upgrades. Pass `undefined` as
`signalData` to clear the signal.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### validator

[`Address`](Address)

##### signal_data

`string`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newSignalVersion()

> `static` **newSignalVersion**(`sender`, `validator`, `version`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2558

Signals support for the given protocol `version` with the validator's *signing (warm) key*
by updating the validator's signal data in the staking contract. In contrast to
`newSetSignalData`, this only updates the protocol-version bytes of the signal data and
preserves the rest. To clear the signal data entirely, use `newSetSignalData` with `null`.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### validator

[`Address`](Address)

##### version

`number`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newUpdateStaker()

> `static` **newUpdateStaker**(`sender`, `new_delegation`, `reactivate_all_stake`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2567

Updates a staker in the staking contract to stake for a different validator. This is a
signaling transaction and as such does not transfer any value.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the number given for fee does not fit within a u64 or the networkId is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### new_delegation

[`Address`](Address)

##### reactivate_all_stake

`boolean`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)

---

### newUpdateValidator()

> `static` **newUpdateValidator**(`sender`, `reward_address`, `signing_key`, `voting_key_pair`, `signal_data`, `fee`, `validity_start_height`, `network_id`): [`Transaction`](Transaction)

Defined in: @nimiq/core/types/wasm/web.d.ts:2575

Updates parameters of a validator in the staking contract.

The returned transaction is not yet signed. You can sign it e.g. with `tx.sign(keyPair)`.

Throws when the fee does not fit within a u64 or the `networkId` is unknown.

#### Parameters

##### sender

[`Address`](Address)

##### reward_address

[`Address`](Address)

##### signing_key

[`PublicKey`](PublicKey)

##### voting_key_pair

[`BLSKeyPair`](BLSKeyPair)

##### signal_data

`string`

##### fee

`bigint`

##### validity_start_height

`number`

##### network_id

`number`

#### Returns

[`Transaction`](Transaction)


## Sitemap

See the full [sitemap](https://nimiq.dev/sitemap.md) for all pages.
