Class: WalletUnlocked
@fuel-ts/account.WalletUnlocked
WalletUnlocked
provides the functionalities for an unlocked wallet.
Hierarchy
↳
WalletUnlocked
Constructors
constructor
• new WalletUnlocked(privateKey
, provider?
): WalletUnlocked
Creates a new BaseWalletUnlocked instance.
Parameters
Name | Type | Description |
---|---|---|
privateKey | BytesLike | The private key of the wallet. |
provider? | Provider | A Provider instance (optional). |
Returns
Inherited from
BaseWalletUnlocked.constructor
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:40
Properties
_connector
• Protected
Optional
_connector: FuelConnector
The connector for use with external wallets
Inherited from
Defined in
packages/account/src/account.ts:85
_provider
• Protected
Optional
_provider: Provider
The provider used to interact with the network.
Inherited from
Defined in
packages/account/src/account.ts:80
address
• Readonly
address: AbstractAddress
The address associated with the account.
Inherited from
Defined in
packages/account/src/account.ts:75
signer
• signer: () => Signer
A function that returns the wallet's signer.
Type declaration
▸ (): Signer
Returns
Inherited from
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:32
defaultPath
▪ Static
defaultPath: string
= "m/44'/1179993420'/0'/0/0"
Default HDWallet path.
Inherited from
BaseWalletUnlocked.defaultPath
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:27
Accessors
privateKey
• get
privateKey(): string
Gets the private key of the wallet.
Returns
string
The private key of the wallet.
Inherited from
BaseWalletUnlocked.privateKey
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:51
provider
• get
provider(): Provider
The provider used to interact with the network.
Throws
FuelError
if the provider is not set.
Returns
A Provider instance.
Inherited from
BaseWalletUnlocked.provider
Defined in
packages/account/src/account.ts:108
• set
provider(provider
): void
Sets the provider for the account.
Parameters
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
Returns
void
Inherited from
BaseWalletUnlocked.provider
Defined in
packages/account/src/account.ts:121
publicKey
• get
publicKey(): string
Gets the public key of the wallet.
Returns
string
Inherited from
BaseWalletUnlocked.publicKey
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:60
Methods
addBatchTransfer
▸ addBatchTransfer(request
, transferParams
): ScriptTransactionRequest
Adds multiple transfers to a script transaction request.
Parameters
Name | Type | Description |
---|---|---|
request | ScriptTransactionRequest | The script transaction request to add transfers to. |
transferParams | TransferParams [] | An array of TransferParams objects representing the transfers to be made. |
Returns
The updated script transaction request.
Inherited from
BaseWalletUnlocked.addBatchTransfer
Defined in
packages/account/src/account.ts:405
addTransfer
▸ addTransfer(request
, transferParams
): ScriptTransactionRequest
Adds a transfer to the given transaction request.
Parameters
Name | Type | Description |
---|---|---|
request | ScriptTransactionRequest | The script transaction request to add transfers to. |
transferParams | TransferParams | The object representing the transfer to be made. |
Returns
The updated transaction request with the added transfer.
Inherited from
BaseWalletUnlocked.addTransfer
Defined in
packages/account/src/account.ts:387
batchTransfer
▸ batchTransfer(transferParams
, txParams?
): Promise
<TransactionResponse
>
Transfers multiple amounts of a token to multiple recipients.
Parameters
Name | Type | Description |
---|---|---|
transferParams | TransferParams [] | An array of TransferParams objects representing the transfers to be made. |
txParams | TxParamsType | Optional transaction parameters. |
Returns
Promise
<TransactionResponse
>
A promise that resolves to a TransactionResponse
object representing the transaction result.
Inherited from
BaseWalletUnlocked.batchTransfer
Defined in
packages/account/src/account.ts:370
connect
▸ connect(provider
): Provider
Changes the provider connection for the account.
Parameters
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
Returns
The updated Provider instance.
Inherited from
Defined in
packages/account/src/account.ts:131
createTransfer
▸ createTransfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionRequest
>
A helper that creates a transfer transaction request and returns it.
Parameters
Name | Type | Description |
---|---|---|
destination | string | AbstractAddress | The address of the destination. |
amount | BigNumberish | The amount of coins to transfer. |
assetId? | BytesLike | The asset ID of the coins to transfer (optional). |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionRequest
>
A promise that resolves to the prepared transaction request.
Inherited from
BaseWalletUnlocked.createTransfer
Defined in
packages/account/src/account.ts:332
encrypt
▸ encrypt(password
): Promise
<string
>
Encrypts an unlocked wallet with a password.
Parameters
Name | Type | Description |
---|---|---|
password | string | the password to encrypt the wallet with. |
Returns
Promise
<string
>
- the encrypted wallet.
Inherited from
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:156
fund
▸ fund<T
>(request
, params
): Promise
<T
>
Funds a transaction request by adding the necessary resources.
Type parameters
Name | Type | Description |
---|---|---|
T | extends TransactionRequest | The type of the TransactionRequest. |
Parameters
Name | Type | Description |
---|---|---|
request | T | The transaction request to fund. |
params | EstimatedTxParams | The estimated transaction parameters. |
Returns
Promise
<T
>
A promise that resolves to the funded transaction request.
Inherited from
Defined in
packages/account/src/account.ts:201
generateFakeResources
▸ generateFakeResources(coins
): Resource
[]
Generates an array of fake resources based on the provided coins.
Parameters
Name | Type | Description |
---|---|---|
coins | FakeResources [] | An array of FakeResources objects representing the coins. |
Returns
Resource
[]
An array of Resource
objects with generated properties.
Inherited from
BaseWalletUnlocked.generateFakeResources
Defined in
packages/account/src/account.ts:637
getBalance
▸ getBalance(assetId?
): Promise
<BN
>
Retrieves the balance of the account for the given asset.
Parameters
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID to check the balance for (optional). |
Returns
Promise
<BN
>
A promise that resolves to the balance amount.
Inherited from
Defined in
packages/account/src/account.ts:178
getBalances
▸ getBalances(): Promise
<GetBalancesResponse
>
Retrieves all the balances for the account.
Returns
Promise
<GetBalancesResponse
>
A promise that resolves to an array of Coins and their quantities.
Inherited from
BaseWalletUnlocked.getBalances
Defined in
packages/account/src/account.ts:189
getCoins
▸ getCoins(assetId?
, paginationArgs?
): Promise
<GetCoinsResponse
>
Retrieves coins owned by the account.
Parameters
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID of the coins to retrieve (optional). |
paginationArgs? | CursorPaginationArgs | - |
Returns
Promise
<GetCoinsResponse
>
A promise that resolves to an array of Coins.
Inherited from
Defined in
packages/account/src/account.ts:156
getMessages
▸ getMessages(paginationArgs?
): Promise
<GetMessagesResponse
>
Retrieves messages owned by the account.
Parameters
Name | Type |
---|---|
paginationArgs? | CursorPaginationArgs |
Returns
Promise
<GetMessagesResponse
>
A promise that resolves to an array of Messages.
Inherited from
BaseWalletUnlocked.getMessages
Defined in
packages/account/src/account.ts:168
getResourcesToSpend
▸ getResourcesToSpend(quantities
, excludedIds?
): Promise
<Resource
[]>
Retrieves resources satisfying the spend query for the account.
Parameters
Name | Type | Description |
---|---|---|
quantities | CoinQuantityLike [] | Quantities of resources to be obtained. |
excludedIds? | ExcludeResourcesOption | IDs of resources to be excluded from the query (optional). |
Returns
Promise
<Resource
[]>
A promise that resolves to an array of Resources.
Inherited from
BaseWalletUnlocked.getResourcesToSpend
Defined in
packages/account/src/account.ts:143
getTransactionCost
▸ getTransactionCost(transactionRequestLike
, transactionCostParams?
): Promise
<TransactionCost
>
Returns a transaction cost to enable user to set gasLimit and also reserve balance amounts on the transaction.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request object. |
transactionCostParams | TransactionCostParams | The transaction cost parameters (optional). |
Returns
Promise
<TransactionCost
>
A promise that resolves to the transaction cost object.
Inherited from
BaseWalletUnlocked.getTransactionCost
Defined in
packages/account/src/account.ts:528
lock
▸ lock(): WalletLocked
Locks the wallet and returns an instance of WalletLocked.
Returns
An instance of WalletLocked.
Defined in
packages/account/src/wallet/wallets.ts:48
populateTransactionWitnessesSignature
▸ populateTransactionWitnessesSignature<T
>(transactionRequestLike
): Promise
<T
>
Populates a transaction with the witnesses signature.
Type parameters
Name | Type |
---|---|
T | extends TransactionRequest |
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to populate. |
Returns
Promise
<T
>
The populated transaction request.
Inherited from
BaseWalletUnlocked.populateTransactionWitnessesSignature
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:95
sendTransaction
▸ sendTransaction(transactionRequestLike
, estimateTxDependencies?
): Promise
<TransactionResponse
>
Populates the witness signature for a transaction and sends it to the network using provider.sendTransaction
.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to send. |
estimateTxDependencies | EstimateTransactionParams | Whether to estimate the transaction dependencies. |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the TransactionResponse object.
Inherited from
BaseWalletUnlocked.sendTransaction
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:113
signMessage
▸ signMessage(message
): Promise
<string
>
Signs a message with the wallet's private key.
Parameters
Name | Type | Description |
---|---|---|
message | string | The message to sign. |
Returns
Promise
<string
>
A promise that resolves to the signature as a ECDSA 64 bytes string.
Inherited from
BaseWalletUnlocked.signMessage
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:70
signTransaction
▸ signTransaction(transactionRequestLike
): Promise
<string
>
Signs a transaction with the wallet's private key.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to sign. |
Returns
Promise
<string
>
A promise that resolves to the signature as a ECDSA 64 bytes string.
Inherited from
BaseWalletUnlocked.signTransaction
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:81
simulateTransaction
▸ simulateTransaction(transactionRequestLike
, «destructured»?
): Promise
<CallResult
>
Populates the witness signature for a transaction and sends a call to the network using provider.dryRun
.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to simulate. |
«destructured» | EstimateTransactionParams | - |
Returns
Promise
<CallResult
>
A promise that resolves to the CallResult object.
Inherited from
BaseWalletUnlocked.simulateTransaction
Defined in
packages/account/src/wallet/base-wallet-unlocked.ts:133
transfer
▸ transfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a destination address.
Parameters
Name | Type | Description |
---|---|---|
destination | string | AbstractAddress | The address of the destination. |
amount | BigNumberish | The amount of coins to transfer. |
assetId? | BytesLike | The asset ID of the coins to transfer (optional). |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:353
transferToContract
▸ transferToContract(contractId
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a contract address.
Parameters
Name | Type | Description |
---|---|---|
contractId | string | AbstractAddress | The address of the contract. |
amount | BigNumberish | The amount of coins to transfer. |
assetId? | BytesLike | The asset ID of the coins to transfer (optional). |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Inherited from
BaseWalletUnlocked.transferToContract
Defined in
packages/account/src/account.ts:426
withdrawToBaseLayer
▸ withdrawToBaseLayer(recipient
, amount
, txParams?
): Promise
<TransactionResponse
>
Withdraws an amount of the base asset to the base chain.
Parameters
Name | Type | Description |
---|---|---|
recipient | string | AbstractAddress | Address of the recipient on the base chain. |
amount | BigNumberish | Amount of base asset. |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Inherited from
BaseWalletUnlocked.withdrawToBaseLayer
Defined in
packages/account/src/account.ts:479
fromEncryptedJson
▸ fromEncryptedJson(jsonWallet
, password
, provider?
): Promise
<WalletUnlocked
>
Create a Wallet Unlocked from an encrypted JSON.
Parameters
Name | Type | Description |
---|---|---|
jsonWallet | string | The encrypted JSON keystore. |
password | string | The password to decrypt the JSON. |
provider? | Provider | A Provider instance (optional). |
Returns
Promise
<WalletUnlocked
>
An unlocked wallet instance.
Defined in
packages/account/src/wallet/wallets.ts:123
fromExtendedKey
▸ fromExtendedKey(extendedKey
, provider?
): WalletUnlocked
Create a Wallet Unlocked from an extended key.
Parameters
Name | Type | Description |
---|---|---|
extendedKey | string | The extended key. |
provider? | Provider | A Provider instance (optional). |
Returns
An instance of WalletUnlocked.
Defined in
packages/account/src/wallet/wallets.ts:109
fromMnemonic
▸ fromMnemonic(mnemonic
, path?
, passphrase?
, provider?
): WalletUnlocked
Create a Wallet Unlocked from a mnemonic phrase.
Parameters
Name | Type | Description |
---|---|---|
mnemonic | string | The mnemonic phrase. |
path? | string | The derivation path (optional). |
passphrase? | BytesLike | The passphrase for the mnemonic (optional). |
provider? | Provider | A Provider instance (optional). |
Returns
An instance of WalletUnlocked.
Defined in
packages/account/src/wallet/wallets.ts:89
fromSeed
▸ fromSeed(seed
, path?
, provider?
): WalletUnlocked
Create a Wallet Unlocked from a seed.
Parameters
Name | Type | Description |
---|---|---|
seed | string | The seed phrase. |
path? | string | The derivation path (optional). |
provider? | Provider | A Provider instance (optional). |
Returns
An instance of WalletUnlocked.
Defined in
packages/account/src/wallet/wallets.ts:73
generate
▸ generate(generateOptions?
): WalletUnlocked
Generate a new Wallet Unlocked with a random key pair.
Parameters
Name | Type | Description |
---|---|---|
generateOptions? | GenerateOptions | Options to customize the generation process (optional). |
Returns
An instance of WalletUnlocked.
Defined in
packages/account/src/wallet/wallets.ts:59