Skip to main content

IGraphQlTransactionBuilder

Namespace: IotaSdk

A builder for creating transactions which uses a GraphQL client to automatically resolve inputs. Use finish to finalize the transaction data.

public interface IGraphQlTransactionBuilder

Attributes NullableContextAttribute

Methods​

AuthorizeUpgrade(PtbArgument, UpgradePolicy, Digest, String)​

Authorize a package upgrade by calling 0x2::package::authorize_upgrade.

The result assigned to upgrade_ticket_name is the UpgradeTicket expected by upgrade(). The digest is the digest of the package being upgraded to (MovePackageData::digest()).

For the standard upgrade flow, use upgrade_package() instead.

GraphQlTransactionBuilder AuthorizeUpgrade(PtbArgument upgradeCapability, UpgradePolicy upgradePolicy, Digest digest, string upgradeTicketName)

Parameters​

upgradeCapability PtbArgument

upgradePolicy UpgradePolicy

digest Digest

upgradeTicketName String

Returns​

GraphQlTransactionBuilder

CommitUpgrade(PtbArgument, PtbArgument)​

Commit a package upgrade by calling 0x2::package::commit_upgrade, consuming the UpgradeReceipt returned by upgrade().

GraphQlTransactionBuilder CommitUpgrade(PtbArgument upgradeCapability, PtbArgument upgradeReceipt)

Parameters​

upgradeCapability PtbArgument

upgradeReceipt PtbArgument

Returns​

GraphQlTransactionBuilder

DivideCoin(PtbArgument, UInt64, TypeTag)​

GraphQlTransactionBuilder DivideCoin(PtbArgument coin, ulong count, TypeTag? coinType = null)

Parameters​

coin PtbArgument

count UInt64

coinType TypeTag?

Returns​

GraphQlTransactionBuilder

DryRun(Boolean)​

Dry run the transaction.

Task<GraphQlDryRunResult> DryRun(bool skipChecks = false)

Parameters​

skipChecks Boolean

Returns​

Task<GraphQlDryRunResult>

Exceptions​

SdkFfiException

Execute(TransactionSigner, WaitForTransaction?)​

Execute the transaction and optionally wait for finalization.

If the wait fails, the error is returned although the transaction was executed, and its effects are lost. To keep them, pass no wait_for and call wait_for_transaction on the client afterwards.

Task<TransactionEffects> Execute(TransactionSigner signer, WaitForTransaction? waitFor = null)

Parameters​

signer TransactionSigner

waitFor WaitForTransaction?

Returns​

Task<TransactionEffects>

Exceptions​

SdkFfiException

ExecuteWithGasStation(GasStation, TransactionSigner)​

Execute the transaction with its gas paid by gas_station, and wait for finalization.

Task<TransactionEffects> ExecuteWithGasStation(GasStation gasStation, TransactionSigner signer)

Parameters​

gasStation GasStation

signer TransactionSigner

Returns​

Task<TransactionEffects>

Exceptions​

SdkFfiException

ExecuteWithSponsorSigner(TransactionSigner, TransactionSigner, WaitForTransaction?)​

Execute the transaction with both the sender's and the sponsor's signature, and optionally wait for finalization.

If the wait fails, the error is returned although the transaction was executed, and its effects are lost. To keep them, pass no wait_for and call wait_for_transaction on the client afterwards.

Use this when you hold the sponsor's key. The sponsor's address must be set with sponsor, which is also where the gas coins are drawn from. When the sponsor is a service that keeps its own key and submits for you, use execute_with_gas_station instead.

Task<TransactionEffects> ExecuteWithSponsorSigner(TransactionSigner signer, TransactionSigner sponsorSigner, WaitForTransaction? waitFor = null)

Parameters​

signer TransactionSigner

sponsorSigner TransactionSigner

waitFor WaitForTransaction?

Returns​

Task<TransactionEffects>

Exceptions​

SdkFfiException

Expiration(UInt64)​

Set the expiration of the transaction to be a specific epoch.

GraphQlTransactionBuilder Expiration(ulong epoch)

Parameters​

epoch UInt64

Returns​

GraphQlTransactionBuilder

Finish()​

Convert this builder into a transaction.

Task<Transaction> Finish()

Returns​

Task<Transaction>

Exceptions​

SdkFfiException

FinishWithBudget(UInt64)​

Convert this builder into a transaction with the given gas budget, used as-is (no estimation or minimum clamp) and overriding any budget set via gas_budget.

Task<Transaction> FinishWithBudget(ulong gasBudget)

Parameters​

gasBudget UInt64

Returns​

Task<Transaction>

Exceptions​

SdkFfiException

Gas(ObjectId[])​

Add gas coins that will be consumed. Optional.

GraphQlTransactionBuilder Gas(ObjectId[] objectIds)

Parameters​

objectIds ObjectId[]

Returns​

GraphQlTransactionBuilder

GasBudget(UInt64)​

Set the gas budget for the transaction.

GraphQlTransactionBuilder GasBudget(ulong budget)

Parameters​

budget UInt64

Returns​

GraphQlTransactionBuilder

GasPrice(UInt64)​

Set the gas price for the transaction.

GraphQlTransactionBuilder GasPrice(ulong price)

Parameters​

price UInt64

Returns​

GraphQlTransactionBuilder

MakeMoveVec(MoveArg[], TypeTag, String)​

Make a move vector from a list of elements. The elements must all be of the type indicated by type_tag.

GraphQlTransactionBuilder MakeMoveVec(MoveArg[] elements, TypeTag typeTag, string name)

Parameters​

elements MoveArg[]

typeTag TypeTag

name String

Returns​

GraphQlTransactionBuilder

MergeCoins(PtbArgument, PtbArgument[])​

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.

GraphQlTransactionBuilder MergeCoins(PtbArgument primaryCoin, PtbArgument[] consumedCoins)

Parameters​

primaryCoin PtbArgument

consumedCoins PtbArgument[]

Returns​

GraphQlTransactionBuilder

MoveCall(Address, Identifier, Identifier, PtbArgument[], TypeTag[], String[])​

Call a Move function with the given arguments.

GraphQlTransactionBuilder MoveCall(Address package, Identifier module, Identifier function, PtbArgument[] arguments = null, TypeTag[] typeArgs = null, String[] names = null)

Parameters​

package Address

module Identifier

function Identifier

arguments PtbArgument[]

typeArgs TypeTag[]

names String[]

Returns​

GraphQlTransactionBuilder

Pay(PtbArgument[], Payment[])​

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 pay_iota() instead.

For a single recipient, consider using send_coins() or send_iota() instead.

GraphQlTransactionBuilder Pay(PtbArgument[] coins, Payment[] payments)

Parameters​

coins PtbArgument[]

payments Payment[]

Returns​

GraphQlTransactionBuilder

PayIota(Payment[])​

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 pay(). For a single recipient, consider using send_iota() instead.

GraphQlTransactionBuilder PayIota(Payment[] payments)

Parameters​

payments Payment[]

Returns​

GraphQlTransactionBuilder

PublishPackage(MovePackageData, String)​

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 published
  • dependencies: is the list of IDs of the transitive dependencies of the package
GraphQlTransactionBuilder PublishPackage(MovePackageData packageData, string upgradeCapName)

Parameters​

packageData MovePackageData

upgradeCapName String

Returns​

GraphQlTransactionBuilder

SendCoins(PtbArgument[], Address, PtbArgument)​

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.

GraphQlTransactionBuilder SendCoins(PtbArgument[] coins, Address recipient, PtbArgument? amount = null)

Parameters​

coins PtbArgument[]

recipient Address

amount PtbArgument?

Returns​

GraphQlTransactionBuilder

SendIota(Address, PtbArgument)​

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.

GraphQlTransactionBuilder SendIota(Address recipient, PtbArgument amount)

Parameters​

recipient Address

amount PtbArgument

Returns​

GraphQlTransactionBuilder

Sender(Address)​

Set the sender address.

GraphQlTransactionBuilder Sender(Address sender)

Parameters​

sender Address

Returns​

GraphQlTransactionBuilder

SplitCoins(PtbArgument, PtbArgument[], String[])​

Split a coin into many.

GraphQlTransactionBuilder SplitCoins(PtbArgument coin, PtbArgument[] amounts, String[] names = null)

Parameters​

coin PtbArgument

amounts PtbArgument[]

names String[]

Returns​

GraphQlTransactionBuilder

Sponsor(Address)​

Set the sponsor of the transaction.

GraphQlTransactionBuilder Sponsor(Address sponsor)

Parameters​

sponsor Address

Returns​

GraphQlTransactionBuilder

Stake(PtbArgument, Address)​

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.

GraphQlTransactionBuilder Stake(PtbArgument stake, Address validatorAddress)

Parameters​

stake PtbArgument

validatorAddress Address

Returns​

GraphQlTransactionBuilder

TransferObjects(Address, PtbArgument[])​

Transfer a list of objects to the given address, without producing any result.

GraphQlTransactionBuilder TransferObjects(Address recipient, PtbArgument[] objects)

Parameters​

recipient Address

objects PtbArgument[]

Returns​

GraphQlTransactionBuilder

Unstake(PtbArgument)​

Withdraw stake from a validator's staking pool.

GraphQlTransactionBuilder Unstake(PtbArgument stakedIota)

Parameters​

stakedIota PtbArgument

Returns​

GraphQlTransactionBuilder

Upgrade(ObjectId, MovePackageData, PtbArgument, String)​

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, use authorize_upgrade(). The result assigned to name is the UpgradeReceipt expected by commit_upgrade().

GraphQlTransactionBuilder Upgrade(ObjectId packageId, MovePackageData packageData, PtbArgument upgradeTicket, string? name = null)

Parameters​

packageId ObjectId

packageData MovePackageData

upgradeTicket PtbArgument

name String?

Returns​

GraphQlTransactionBuilder

UpgradePackage(ObjectId, MovePackageData, PtbArgument, UpgradePolicy)​

Upgrade a Move package.

This is a high-level function which chains authorize_upgrade(), upgrade() and commit_upgrade() using the digest from the provided MovePackageData. Use the individual functions for custom upgrade flows.

GraphQlTransactionBuilder UpgradePackage(ObjectId packageId, MovePackageData packageData, PtbArgument upgradeCapability, UpgradePolicy upgradePolicy)

Parameters​

packageId ObjectId

packageData MovePackageData

upgradeCapability PtbArgument

upgradePolicy UpgradePolicy

Returns​

GraphQlTransactionBuilder