Class

SorobanDataBuilder

SorobanDataBuilder(sorobanDataopt)

Supports building xdr.SorobanTransactionData structures with various items set to specific values.

This is recommended for when you are building Operation.extendFootprintTtl / Operation.restoreFootprint operations and need to TransactionBuilder.setSorobanData to avoid (re)building the entire data structure from scratch.

Constructor

# new SorobanDataBuilder(sorobanDataopt)

Parameters:
Name Type Attributes Description
sorobanData string | xdr.SorobanTransactionData <optional>

either a base64-encoded string that represents an xdr.SorobanTransactionData instance or an XDR instance itself (it will be copied); if omitted or "falsy" (e.g. an empty string), it starts with an empty instance

View Source js-stellar-base/src/sorobandata_builder.js, line 33

Example
// You want to use an existing data blob but override specific parts.
const newData = new SorobanDataBuilder(existing)
  .setReadOnly(someLedgerKeys)
  .setRefundableFee("1000")
  .build();

// You want an instance from scratch
const newData = new SorobanDataBuilder()
  .setFootprint([someLedgerKey], [])
  .setRefundableFee("1000")
  .build();

Classes

SorobanDataBuilder

Methods

# appendFootprint(readOnly, readWrite) → {SorobanDataBuilder}

Appends the given ledger keys to the existing storage access footprint.

Parameters:
Name Type Description
readOnly Array.<xdr.LedgerKey>

read-only keys to add

readWrite Array.<xdr.LedgerKey>

read-write keys to add

View Source js-stellar-base/src/sorobandata_builder.js, line 110

this builder instance

# build() → {xdr.SorobanTransactionData}

View Source js-stellar-base/src/sorobandata_builder.js, line 174

a copy of the final data structure

xdr.SorobanTransactionData

# getFootprint() → {xdr.LedgerFootprint}

View Source js-stellar-base/src/sorobandata_builder.js, line 193

the storage access pattern

xdr.LedgerFootprint

# getReadOnly() → {Array.<xdr.LedgerKey>}

View Source js-stellar-base/src/sorobandata_builder.js, line 183

the read-only storage access pattern

Array.<xdr.LedgerKey>

# getReadWrite() → {Array.<xdr.LedgerKey>}

View Source js-stellar-base/src/sorobandata_builder.js, line 188

the read-write storage access pattern

Array.<xdr.LedgerKey>

# setFootprint(readOnlyopt, readWriteopt) → {SorobanDataBuilder}

Sets the storage access footprint to be a certain set of ledger keys.

You can also set each field explicitly via SorobanDataBuilder.setReadOnly and SorobanDataBuilder.setReadWrite or add to the existing footprint via SorobanDataBuilder.appendFootprint.

Passing null|undefined to either parameter will IGNORE the existing values. If you want to clear them, pass [], instead.

Parameters:
Name Type Attributes Description
readOnly Array.<xdr.LedgerKey> | null <optional>

the set of ledger keys to set in the read-only portion of the transaction's sorobanData, or null | undefined to keep the existing keys

readWrite Array.<xdr.LedgerKey> | null <optional>

the set of ledger keys to set in the read-write portion of the transaction's sorobanData, or null | undefined to keep the existing keys

View Source js-stellar-base/src/sorobandata_builder.js, line 136

this builder instance

# setReadOnly(readOnly) → {SorobanDataBuilder}

Parameters:
Name Type Description
readOnly Array.<xdr.LedgerKey>

read-only keys in the access footprint

View Source js-stellar-base/src/sorobandata_builder.js, line 151

# setReadWrite(readWrite) → {SorobanDataBuilder}

Parameters:
Name Type Description
readWrite Array.<xdr.LedgerKey>

read-write keys in the access footprint

View Source js-stellar-base/src/sorobandata_builder.js, line 163

# setResourceFee(fee) → {SorobanDataBuilder}

Sets the resource fee portion of the Soroban data.

Parameters:
Name Type Description
fee number | bigint | string

the resource fee to set (int64)

View Source js-stellar-base/src/sorobandata_builder.js, line 79

# setResources(cpuInstrs, readBytes, writeBytes) → {SorobanDataBuilder}

Sets up the resource metrics.

You should almost NEVER need this, as its often generated / provided to you by transaction simulation/preflight from a Soroban RPC server.

Parameters:
Name Type Description
cpuInstrs number

number of CPU instructions

readBytes number

number of bytes being read

writeBytes number

number of bytes being written

View Source js-stellar-base/src/sorobandata_builder.js, line 96

# static fromXDR(data) → {xdr.SorobanTransactionData}

Decodes and builds a xdr.SorobanTransactionData instance.

Parameters:
Name Type Description
data Uint8Array | Buffer | string

raw input to decode

View Source js-stellar-base/src/sorobandata_builder.js, line 67

xdr.SorobanTransactionData