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 |
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
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 |
build() → {xdr.SorobanTransactionData}
Returns:
- Type:
-
xdr.SorobanTransactionData
a copy of the final data structure
getFootprint() → {xdr.LedgerFootprint}
Returns:
- Type:
-
xdr.LedgerFootprint
the storage access pattern
getReadOnly() → {Array.<xdr.LedgerKey>}
Returns:
- Type:
-
Array.<xdr.LedgerKey>
the read-only storage access pattern
getReadWrite() → {Array.<xdr.LedgerKey>}
Returns:
- Type:
-
Array.<xdr.LedgerKey>
the read-write storage access pattern
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 |
readWrite |
Array.<xdr.LedgerKey>
|
null
|
<optional> |
the set of ledger keys to set in
the read-write portion of the transaction's |
setReadOnly(readOnly) → {SorobanDataBuilder}
Parameters:
Name | Type | Description |
---|---|---|
readOnly |
Array.<xdr.LedgerKey>
|
read-only keys in the access footprint |
Returns:
- Type:
-
SorobanDataBuilder
setReadWrite(readWrite) → {SorobanDataBuilder}
Parameters:
Name | Type | Description |
---|---|---|
readWrite |
Array.<xdr.LedgerKey>
|
read-write keys in the access footprint |
Returns:
- Type:
-
SorobanDataBuilder
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) |
Returns:
- Type:
-
SorobanDataBuilder
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 |
Returns:
- Type:
-
SorobanDataBuilder
(static) fromXDR(data) → {xdr.SorobanTransactionData}
Decodes and builds a xdr.SorobanTransactionData instance.
Parameters:
Name | Type | Description |
---|---|---|
data |
Uint8Array
|
Buffer
|
string
|
raw input to decode |
Returns:
- Type:
-
xdr.SorobanTransactionData