Interface: TransactionBuilderLike
A builder for creating transactions. Use finish to finalize the
transaction data.
Methods
executeWithGasStation()
executeWithGasStation(signer, asyncOpts_?): Promise<string>;
Execute the transaction using the gas station and return the JSON
transaction effects. This will fail unless data is set with the
gas_station_sponsor function.
NOTE: These effects are not necessarily compatible with
TransactionEffects
Parameters
signer
asyncOpts_?
signal
AbortSignal
Returns
Promise<string>
expiration()
expiration(epoch): TransactionBuilderLike;
Set the expiration of the transaction to be a specific epoch.
Parameters
epoch
bigint
Returns
TransactionBuilderLike
finish()
finish(): TransactionLike;
Convert this builder into a transaction.
Returns
gas()
gas(objectRefs): TransactionBuilderLike;
Add gas coins that will be consumed. Optional.
Parameters
objectRefs
Returns
TransactionBuilderLike
gasBudget()
gasBudget(budget): TransactionBuilderLike;
Set the gas budget for the transaction.
Parameters
budget
bigint
Returns
TransactionBuilderLike
gasPrice()
gasPrice(price): TransactionBuilderLike;
Set the gas price for the transaction.
Parameters
price
bigint
Returns
TransactionBuilderLike
gasStationSponsor()
gasStationSponsor(
url,
duration,
headers
): TransactionBuilderLike;
Set the gas station sponsor.
Parameters
url
string
duration
number | undefined
headers
Map<string, string[]> | undefined
Returns
TransactionBuilderLike
makeMoveVec()
makeMoveVec(
elements,
typeTag,
name
): TransactionBuilderLike;
Make a move vector from a list of elements. The elements must all be of
the type indicated by type_tag.
Parameters
elements
typeTag
name
string
Returns
TransactionBuilderLike
mergeCoins()
mergeCoins(primaryCoin, consumedCoins): TransactionBuilderLike;
Merge multiple coins into one.
This method combines the balances of multiple coins of the same coin
type into a single coin. The primary_coin will receive the balances
from all consumed_coins. After merging, the consumed_coins will
be consumed and no longer exist.
Parameters
primaryCoin
consumedCoins
Returns
TransactionBuilderLike
moveCall()
moveCall(
package_,
module,
function_,
moveArguments,
typeArgs,
names
): TransactionBuilderLike;
Call a Move function with the given arguments.
Parameters
package_
module
function_
moveArguments
typeArgs
names
string[]
Returns
TransactionBuilderLike
pay()
pay(coins, payments): TransactionBuilderLike;
Send coins to multiple recipients, each paired with the amount to send.
The amounts specify quantities in the coins' smallest unit (NANOS for IOTA coins, where 1 IOTA equals 1_000_000_000 NANOS).
The coins are merged into the first one, the amounts are split off it in a single command, and each split coin is transferred to its corresponding recipient, with one transfer command per unique recipient. The remainder stays in the first coin.
All provided coins must have the same coin type. Mixing coins of different types will result in an error.
To pay IOTA directly from the gas coin, use
TransactionBuilder::pay_iota() instead.
For a single recipient, consider using
TransactionBuilder::send_coins() or TransactionBuilder::send_iota()
instead.
Parameters
coins
payments
Payment[]
Returns
TransactionBuilderLike
payIota()
payIota(payments): TransactionBuilderLike;
Send IOTA to multiple recipients, each paired with the amount to send.
The amounts specify quantities in NANOS, where 1 IOTA equals 1_000_000_000 NANOS. They are split off the gas coin in a single command, and each split coin is transferred to its corresponding recipient, with one transfer command per unique recipient.
To pay with specific coins, or with a coin type other than IOTA, use
TransactionBuilder::pay(). For a single recipient, consider using
TransactionBuilder::send_iota() instead.
Parameters
payments
Payment[]
Returns
TransactionBuilderLike
publishPackage()
publishPackage(packageData, upgradeCapName): TransactionBuilderLike;
Publish a list of modules with the given dependencies. The result
assigned to upgrade_cap_name is the 0x2::package::UpgradeCap
Move type. Note that the upgrade capability needs to be handled
after this call:
- transfer it to the transaction sender or another address
- burn it
- wrap it for access control
- discard the it to make a package immutable
The arguments required for this command are:
modules: is the modules' bytecode to be publisheddependencies: is the list of IDs of the transitive dependencies of the package
Parameters
packageData
upgradeCapName
string
Returns
TransactionBuilderLike
sendCoins()
sendCoins(
coins,
recipient,
amount
): TransactionBuilderLike;
Transfer some coins to a recipient address. If multiple coins are provided then they will be merged.
The amount parameter specifies the quantity in NANOS, where 1 IOTA
equals 1_000_000_000 NANOS.
If amount is provided, that amount is split from the provided coins
and sent.
If amount is None, the entire coins are transferred.
All provided coins must have the same coin type. Mixing coins of different types will result in an error.
If you intend to transfer all provided coins to another address in a
single transaction, consider using
TransactionBuilder::transfer_objects() instead.
Parameters
coins
recipient
amount
PtbArgumentLike | undefined
Returns
TransactionBuilderLike
sendIota()
sendIota(recipient, amount): TransactionBuilderLike;
Send IOTA to a recipient address.
The amount parameter specifies the quantity in NANOS, where 1 IOTA
equals 1_000_000_000 NANOS. That amount is split from the gas coin and
sent.
Parameters
recipient
amount
Returns
TransactionBuilderLike
setSender()
setSender(sender): void;
Set the sender address.
Parameters
sender
Returns
void
splitCoins()
splitCoins(
coin,
amounts,
names
): TransactionBuilderLike;
Split a coin by the provided amounts.
Parameters
coin
amounts
names
string[]
Returns
TransactionBuilderLike
sponsor()
sponsor(sponsor): TransactionBuilderLike;
Set the sponsor of the transaction.
Parameters
sponsor
Returns
TransactionBuilderLike
stake()
stake(stake, validatorAddress): TransactionBuilderLike;
Add stake to a validator's staking pool.
This is a high-level function which will split the provided stake amount from the gas coin and then stake using the resulting coin.
Parameters
stake
validatorAddress
Returns
TransactionBuilderLike
transferObjects()
transferObjects(recipient, objects): TransactionBuilderLike;
Transfer a list of objects to the given address, without producing any result.
Parameters
recipient
objects
Returns
TransactionBuilderLike
unstake()
unstake(stakedIota): TransactionBuilderLike;
Withdraw stake from a validator's staking pool.
Parameters
stakedIota
Returns
TransactionBuilderLike
upgrade()
upgrade(
packageId,
packageData,
upgradeTicket,
name
): TransactionBuilderLike;
Upgrade a Move package.
modules: is the modules' bytecode for the modules to be publisheddependencies: is the list of IDs of the transitive dependencies of the package to be upgradedpackage: is the ID of the current package being upgradedticket: is the upgrade ticket
To get the ticket, you have to call the
0x2::package::authorize_upgrade function, and pass the package
ID, the upgrade policy, and package digest.
Parameters
packageId
packageData
upgradeTicket
name
string | undefined
Returns
TransactionBuilderLike
withClient()
withClient(client): ClientTransactionBuilderLike;