Class: Transaction
Transaction Builder
Constructors
Constructor
new Transaction(): Transaction;
Returns
Transaction
Properties
| Property | Type | Description |
|---|---|---|
object | { (value): object; system: object; clock: object; random: object; denyList: object; option: (tx) => TransactionResult; } | Add a new object input to the transaction. |
object.system | object | - |
object.clock | object | - |
object.random | object | - |
object.denyList | object | - |
object.option | (tx) => TransactionResult | - |
Accessors
pure
Get Signature
get pure(): {
<Type> (type, value):
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
(value):
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
u8: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
u16: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
u32: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
u64: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
u128: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
u256: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
bool: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
string: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
address: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
id: (value) =>
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
vector: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
option: | {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
};
Returns
<Type>(type, value):
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
Type Parameters
| Type Parameter |
|---|
Type extends PureTypeName |
Parameters
| Parameter | Type |
|---|---|
type | Type extends PureTypeName ? ValidPureTypeName<Type> : Type |
value | ShapeFromPureTypeName<Type> |
Returns
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
}
(value):
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
};
Parameters
| Parameter | Type | Description |
|---|---|---|
value | Uint8Array | SerializedBcs<any, any> | The pure value, serialized to BCS. If this is a Uint8Array, then the value is assumed to be raw bytes, and will be used directly. |
Returns
| {
$kind: "GasCoin";
GasCoin: true;
}
| {
$kind: "Input";
Input: number;
type?: "pure";
}
| {
$kind: "Input";
Input: number;
type?: "object";
}
| {
$kind: "Result";
Result: number;
}
| {
$kind: "NestedResult";
NestedResult: [number, number];
}
| Name | Type |
|---|---|
u8() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
u16() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
u32() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
u64() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
u128() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
u256() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
bool() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
string() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
address() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
id() | (value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
vector() | (type, value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
option() | (type, value) => | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } |
gas
Get Signature
get gas(): object;
Returns an argument for the gas coin, to be used in a transaction.
Returns
object
| Name | Type |
|---|---|
$kind | "GasCoin" |
GasCoin | true |
Methods
fromKind()
static fromKind(serialized): Transaction;
Converts from a serialize transaction kind (built with build({ onlyTransactionKind: true })) to a Transaction class.
Supports either a byte array, or base64-encoded bytes.
Parameters
| Parameter | Type |
|---|---|
serialized | string | Uint8Array |
Returns
Transaction
from()
static from(transaction): Transaction;
Converts from a serialized transaction format to a Transaction class.
There are two supported serialized formats:
- A string returned from
Transaction#serialize. The serialized format must be compatible, or it will throw an error. - A byte array (or base64-encoded bytes) containing BCS transaction data.
Parameters
| Parameter | Type |
|---|---|
transaction | string | Uint8Array | Transaction |
Returns
Transaction
registerGlobalSerializationPlugin()
static registerGlobalSerializationPlugin(name, step): void;
Parameters
| Parameter | Type |
|---|---|
name | string |
step | TransactionPlugin |
Returns
void
unregisterGlobalSerializationPlugin()
static unregisterGlobalSerializationPlugin(name): void;
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
void
registerGlobalBuildPlugin()
static registerGlobalBuildPlugin(name, step): void;
Parameters
| Parameter | Type |
|---|---|
name | string |
step | TransactionPlugin |
Returns
void
unregisterGlobalBuildPlugin()
static unregisterGlobalBuildPlugin(name): void;
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
void
addSerializationPlugin()
addSerializationPlugin(step): void;
Parameters
| Parameter | Type |
|---|---|
step | TransactionPlugin |
Returns
void
addBuildPlugin()
addBuildPlugin(step): void;
Parameters
| Parameter | Type |
|---|---|
step | TransactionPlugin |
Returns
void
addIntentResolver()
addIntentResolver(intent, resolver): void;
Parameters
| Parameter | Type |
|---|---|
intent | string |
resolver | TransactionPlugin |
Returns
void
setSender()
setSender(sender): void;
Parameters
| Parameter | Type |
|---|---|
sender | string |
Returns
void
setSenderIfNotSet()
setSenderIfNotSet(sender): void;
Sets the sender only if it has not already been set. This is useful for sponsored transaction flows where the sender may not be the same as the signer address.
Parameters
| Parameter | Type |
|---|---|
sender | string |
Returns
void
setExpiration()
setExpiration(expiration?): void;
Parameters
| Parameter | Type |
|---|---|
expiration? | | EnumSchemaInput<{ None: LiteralSchema<true, undefined>; Epoch: SchemaWithPipe<readonly [UnionSchema<[StringSchema<undefined>, SchemaWithPipe<readonly [NumberSchema<undefined>, IntegerAction<number, undefined>]>], undefined>, CheckAction<string | number, "Invalid u64">]>; }> | null |
Returns
void
setGasPrice()
setGasPrice(price): void;
Parameters
| Parameter | Type |
|---|---|
price | number | bigint |
Returns
void
setGasBudget()
setGasBudget(budget): void;
Parameters
| Parameter | Type |
|---|---|
budget | number | bigint |
Returns
void
setGasBudgetIfNotSet()
setGasBudgetIfNotSet(budget): void;
Parameters
| Parameter | Type |
|---|---|
budget | number | bigint |
Returns
void
setGasOwner()
setGasOwner(owner): void;
Parameters
| Parameter | Type |
|---|---|
owner | string |
Returns
void
setGasPayment()
setGasPayment(payments): void;
Parameters
| Parameter | Type |
|---|---|
payments | object[] |
Returns
void
getData()
getData(): object;
Get a snapshot of the transaction data, in JSON form:
Returns
object
| Name | Type | Default value |
|---|---|---|
version | 2 | - |
sender? | string | null | - |
expiration? | | EnumOutputShapeWithKeys<{ None: true; Epoch: string | number; }, "None" | "Epoch"> | null | - |
gasData | object | GasData |
gasData.budget | string | number | null | - |
gasData.price | string | number | null | - |
gasData.owner | string | null | - |
gasData.payment | object[] | null | - |
inputs | EnumOutputShapeWithKeys<{ Object: EnumOutputShapeWithKeys<{ ImmOrOwnedObject: { objectId: string; version: string | number; digest: string; }; SharedObject: { objectId: string; initialSharedVersion: string | number; mutable: boolean; }; Receiving: { objectId: string; version: string | number; digest: string; }; }, "ImmOrOwnedObject" | "SharedObject" | "Receiving">; Pure: { bytes: string; }; UnresolvedPure: { value: unknown; }; UnresolvedObject: { objectId: string; version?: string | number | null; digest?: string | null; initialSharedVersion?: string | number | null; mutable?: boolean | null; }; }, "Pure" | "Object" | "UnresolvedPure" | "UnresolvedObject">[] | - |
commands | EnumOutputShapeWithKeys<{ MoveCall: { package: string; module: string; function: string; typeArguments: string[]; arguments: ( | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; })[]; _argumentTypes?: object[] | null; }; TransferObjects: { objects: ( | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; })[]; address: | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; }; }; SplitCoins: { coin: | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; }; amounts: ( | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; })[]; }; MergeCoins: { destination: | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; }; sources: ( | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; })[]; }; Publish: { modules: string[]; dependencies: string[]; }; MakeMoveVec: { type: string | null; elements: ( | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; })[]; }; Upgrade: { modules: string[]; dependencies: string[]; package: string; ticket: | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; }; }; $Intent: { name: string; inputs: { [key: string]: | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: "pure"; } | { $kind: "Input"; Input: number; type?: "object"; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [number, number]; } | ( | { $kind: "GasCoin"; GasCoin: true; } | { $kind: "Input"; Input: number; type?: ... | ...; } | { $kind: "Input"; Input: number; type?: ... | ...; } | { $kind: "Result"; Result: number; } | { $kind: "NestedResult"; NestedResult: [..., ...]; })[]; }; data: { [key: string]: unknown; }; }; }, | "MoveCall" | "TransferObjects" | "SplitCoins" | "MergeCoins" | "Publish" | "MakeMoveVec" | "Upgrade" | "$Intent">[] | - |
objectRef()
objectRef(...args): object;
Add a new object input to the transaction using the fully-resolved object reference.
If you only have an object ID, use builder.object(id) instead.
Parameters
| Parameter | Type |
|---|---|
...args | [{ objectId: string; version: string | number; digest: string; }] |
Returns
object
| Name | Type |
|---|---|
$kind | "Input" |
Input | number |
type? | "object" |
receivingRef()
receivingRef(...args): object;
Add a new receiving input to the transaction using the fully-resolved object reference.
If you only have an object ID, use builder.object(id) instead.
Parameters
| Parameter | Type |
|---|---|
...args | [{ objectId: string; version: string | number; digest: string; }] |
Returns
object
| Name | Type |
|---|---|
$kind | "Input" |
Input | number |
type? | "object" |
sharedObjectRef()
sharedObjectRef(...args): object;
Add a new shared object input to the transaction using the fully-resolved shared object reference.
If you only have an object ID, use builder.object(id) instead.
Parameters
| Parameter | Type |
|---|---|
...args | [{ objectId: string; mutable: boolean; initialSharedVersion: string | number; }] |
Returns
object
| Name | Type |
|---|---|
$kind | "Input" |
Input | number |
type? | "object" |
add()
add<T>(command): T;
Add a transaction to the transaction
Type Parameters
| Type Parameter | Default type |
|---|---|
T | TransactionResult |
Parameters
| Parameter | Type |
|---|---|
command | Command | (tx) => T |
Returns
T
splitCoins()
splitCoins<Amounts>(coin, amounts): object & { [K in string | number | symbol]: { $kind: "NestedResult"; NestedResult: [number, number] } };
Type Parameters
| Type Parameter |
|---|
Amounts extends ( | string | number | bigint | SerializedBcs<any, any> | TransactionArgument)[] |
Parameters
| Parameter | Type |
|---|---|
coin | | string | TransactionObjectArgument |
amounts | Amounts |
Returns
object & { [K in string | number | symbol]: { $kind: "NestedResult"; NestedResult: [number, number] } }
mergeCoins()
mergeCoins(destination, sources): TransactionResult;
Parameters
| Parameter | Type |
|---|---|
destination | | string | TransactionObjectArgument |
sources | ( | string | TransactionObjectArgument)[] |
Returns
publish()
publish(__namedParameters): TransactionResult;
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { modules: string[] | number[][]; dependencies: string[]; } |
__namedParameters.modules | string[] | number[][] |
__namedParameters.dependencies | string[] |
Returns
upgrade()
upgrade(__namedParameters): TransactionResult;
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { modules: string[] | number[][]; dependencies: string[]; package: string; ticket: | string | TransactionObjectArgument; } |
__namedParameters.modules | string[] | number[][] |
__namedParameters.dependencies | string[] |
__namedParameters.package | string |
__namedParameters.ticket | | string | TransactionObjectArgument |
Returns
moveCall()
moveCall(__namedParameters): TransactionResult;
Parameters
| Parameter | Type |
|---|---|
__namedParameters | | { package: string; module: string; function: string; arguments?: ( | SerializedBcs<any, any> | TransactionArgument)[]; typeArguments?: string[]; } | { target: string; arguments?: ( | SerializedBcs<any, any> | TransactionArgument)[]; typeArguments?: string[]; } |
Returns
transferObjects()
transferObjects(objects, address): TransactionResult;
Parameters
| Parameter | Type |
|---|---|
objects | ( | string | TransactionObjectArgument)[] |
address | | string | SerializedBcs<any, any> | TransactionArgument |
Returns
makeMoveVec()
makeMoveVec(__namedParameters): TransactionResult;
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { elements: ( | string | TransactionObjectArgument)[]; type?: string; } |
__namedParameters.elements | ( | string | TransactionObjectArgument)[] |
__namedParameters.type? | string |
Returns
toJSON()
toJSON(options?): Promise<string>;
Parameters
| Parameter | Type |
|---|---|
options | SerializeTransactionOptions |
Returns
Promise<string>
sign()
sign(options): Promise<SignatureWithBytes>;
Build the transaction to BCS bytes, and sign it with the provided keypair.
Parameters
| Parameter | Type |
|---|---|
options | SignOptions |
Returns
Promise<SignatureWithBytes>
build()
build(options?): Promise<Uint8Array>;
Build the transaction to BCS bytes.
Parameters
| Parameter | Type |
|---|---|
options | BuildTransactionOptions |
Returns
Promise<Uint8Array>
getDigest()
getDigest(options?): Promise<string>;
Derive transaction digest
Parameters
| Parameter | Type |
|---|---|
options | { client?: IotaClient; } |
options.client? | IotaClient |
Returns
Promise<string>
getSigningDigest()
getSigningDigest(): Promise<string>;
Get the signing digest for transaction bytes. This is the Blake2b hash of the intent message that Ledger displays.
Returns
Promise<string>
prepareForSerialization()
prepareForSerialization(options): Promise<void>;
Parameters
| Parameter | Type |
|---|---|
options | SerializeTransactionOptions |
Returns
Promise<void>