TransactionBuilder
type TransactionBuilder
A builder for creating transactions. Use `finish` to finalize the transaction data.
type TransactionBuilder struct {
// contains filtered or unexported fields
}
func LiftFromExternalTransactionBuilder
func LiftFromExternalTransactionBuilder(handle uint64) *TransactionBuilder
func NewTransactionBuilder
func NewTransactionBuilder(sender *Address) *TransactionBuilder
Create a new transaction builder and initialize its elements to default.
func TransactionBuilderFromProgrammableTransaction
func TransactionBuilderFromProgrammableTransaction(ptb *ProgrammableTransaction) *TransactionBuilder
Create a transaction builder from a programmable transaction.
The returned builder has the original inputs and commands but no sender, gas payment, sponsor, or expiration; the sender defaults to the zero address and must be set via `set_sender` before `finish` is called.
func TransactionBuilderFromTransaction
func TransactionBuilderFromTransaction(transaction *Transaction) (*TransactionBuilder, error)
Reconstruct a transaction builder from a finalized transaction. Calling `finish` on the returned builder produces a transaction equal to the input.
Only programmable transactions are supported; other transaction kinds will return an error.
func (*TransactionBuilder) DebugString
func (_self *TransactionBuilder) DebugString() string
func (*TransactionBuilder) Destroy
func (object *TransactionBuilder) Destroy()
func (*TransactionBuilder) ExecuteWithGasStation
func (_self *TransactionBuilder) ExecuteWithGasStation(signer *TransactionSigner) (Value, error)
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`
func (*TransactionBuilder) Expiration
func (_self *TransactionBuilder) Expiration(epoch uint64) *TransactionBuilder
Set the expiration of the transaction to be a specific epoch.
func (*TransactionBuilder) Finish
func (_self *TransactionBuilder) Finish() (*Transaction, error)
Convert this builder into a transaction.
func (*TransactionBuilder) Gas
func (_self *TransactionBuilder) Gas(objectRefs []ObjectReference) *TransactionBuilder
Add gas coins that will be consumed. Optional.
func (*TransactionBuilder) GasBudget
func (_self *TransactionBuilder) GasBudget(budget uint64) *TransactionBuilder
Set the gas budget for the transaction.
func (*TransactionBuilder) GasPrice
func (_self *TransactionBuilder) GasPrice(price uint64) *TransactionBuilder
Set the gas price for the transaction.
func (*TransactionBuilder) GasStationSponsor
func (_self *TransactionBuilder) GasStationSponsor(url string, duration *time.Duration, headers *map[string][]string) *TransactionBuilder
Set the gas station sponsor.
func (*TransactionBuilder) MakeMoveVec
func (_self *TransactionBuilder) MakeMoveVec(elements []*MoveArg, typeTag *TypeTag, name string) *TransactionBuilder
Make a move vector from a list of elements. The elements must all be of the type indicated by `type_tag`.
func (*TransactionBuilder) MergeCoins
func (_self *TransactionBuilder) MergeCoins(primaryCoin *PtbArgument, consumedCoins []*PtbArgument) *TransactionBuilder
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.
func (*TransactionBuilder) MoveCall
func (_self *TransactionBuilder) MoveCall(varPackage *Address, module *Identifier, function *Identifier, arguments []*PtbArgument, typeArgs []*TypeTag, names []string) *TransactionBuilder
Call a Move function with the given arguments.
func (*TransactionBuilder) Pay
func (_self *TransactionBuilder) Pay(coins []*PtbArgument, payments []Payment) *TransactionBuilder
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.
func (*TransactionBuilder) PayIota
func (_self *TransactionBuilder) PayIota(payments []Payment) *TransactionBuilder
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.
func (*TransactionBuilder) PublishPackage
func (_self *TransactionBuilder) PublishPackage(packageData *MovePackageData, upgradeCapName string) *TransactionBuilder
Publish a list of modules with the given dependencies. The result assigned to `upgrade_cap_name` is the `0x2:📦: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 published - `dependencies`: is the list of IDs of the transitive dependencies of the package
func (*TransactionBuilder) SendCoins
func (_self *TransactionBuilder) SendCoins(coins []*PtbArgument, recipient *Address, amount **PtbArgument) *TransactionBuilder
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.
func (*TransactionBuilder) SendIota
func (_self *TransactionBuilder) SendIota(recipient *Address, amount *PtbArgument) *TransactionBuilder
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.
func (*TransactionBuilder) SetSender
func (_self *TransactionBuilder) SetSender(sender *Address)
Set the sender address.
func (*TransactionBuilder) SplitCoins
func (_self *TransactionBuilder) SplitCoins(coin *PtbArgument, amounts []*PtbArgument, names []string) *TransactionBuilder
Split a coin by the provided amounts.
func (*TransactionBuilder) Sponsor
func (_self *TransactionBuilder) Sponsor(sponsor *Address) *TransactionBuilder
Set the sponsor of the transaction.
func (*TransactionBuilder) Stake
func (_self *TransactionBuilder) Stake(stake *PtbArgument, validatorAddress *Address) *TransactionBuilder
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.
func (*TransactionBuilder) TransferObjects
func (_self *TransactionBuilder) TransferObjects(recipient *Address, objects []*PtbArgument) *TransactionBuilder
Transfer a list of objects to the given address, without producing any result.
func (*TransactionBuilder) Unstake
func (_self *TransactionBuilder) Unstake(stakedIota *PtbArgument) *TransactionBuilder
Withdraw stake from a validator's staking pool.
func (*TransactionBuilder) Upgrade
func (_self *TransactionBuilder) Upgrade(packageId *ObjectId, packageData *MovePackageData, upgradeTicket *PtbArgument, name *string) *TransactionBuilder
Upgrade a Move package.
- `modules`: is the modules' bytecode for the modules to be published - `dependencies`: is the list of IDs of the transitive dependencies of the package to be upgraded - `package`: is the ID of the current package being upgraded - `ticket`: is the upgrade ticket
To get the ticket, you have to call the `0x2:📦:authorize_upgrade` function, and pass the package ID, the upgrade policy, and package digest.
func (*TransactionBuilder) WithClient
func (_self *TransactionBuilder) WithClient(client *GraphQlClient) *ClientTransactionBuilder