@fuel-ts/account .WalletUnlocked
WalletUnlocked
provides the functionalities for an unlocked wallet.
↳ WalletUnlocked
• new WalletUnlocked(privateKey
, provider?
): WalletUnlocked
Creates a new BaseWalletUnlocked instance.
Name | Type | Description |
---|---|---|
privateKey | BytesLike | The private key of the wallet. |
provider? | Provider | A Provider instance (optional). |
BaseWalletUnlocked .constructor
packages/account/src/wallet/base-wallet-unlocked.ts:40
• Protected
Optional
_connector: FuelConnector
The connector for use with external wallets
BaseWalletUnlocked ._connector
packages/account/src/account.ts:76
• Protected
Optional
_provider: Provider
The provider used to interact with the network.
packages/account/src/account.ts:71
• Readonly
address: AbstractAddress
The address associated with the account.
packages/account/src/account.ts:66
• signer: () => Signer
▸ (): Signer
A function that returns the wallet's signer.
packages/account/src/wallet/base-wallet-unlocked.ts:32
▪ Static
defaultPath: string
= "m/44'/1179993420'/0'/0/0"
Default HDWallet path.
BaseWalletUnlocked .defaultPath
packages/account/src/wallet/base-wallet-unlocked.ts:27
• get
privateKey(): string
Gets the private key of the wallet.
string
The private key of the wallet.
BaseWalletUnlocked.privateKey
packages/account/src/wallet/base-wallet-unlocked.ts:51
• get
provider(): Provider
The provider used to interact with the network.
Throws
FuelError
if the provider is not set.
A Provider instance.
BaseWalletUnlocked.provider
packages/account/src/account.ts:99
• set
provider(provider
): void
Sets the provider for the account.
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
void
BaseWalletUnlocked.provider
packages/account/src/account.ts:112
• get
publicKey(): string
Gets the public key of the wallet.
string
BaseWalletUnlocked.publicKey
packages/account/src/wallet/base-wallet-unlocked.ts:60
▸ addBatchTransfer(request
, transferParams
): ScriptTransactionRequest
Adds multiple transfers to a script transaction request.
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. |
The updated script transaction request.
BaseWalletUnlocked .addBatchTransfer
packages/account/src/account.ts:454
▸ addTransfer(request
, transferParams
): ScriptTransactionRequest
Adds a transfer to the given transaction request.
Name | Type | Description |
---|---|---|
request | ScriptTransactionRequest | The script transaction request to add transfers to. |
transferParams | TransferParams | The object representing the transfer to be made. |
The updated transaction request with the added transfer.
BaseWalletUnlocked .addTransfer
packages/account/src/account.ts:436
▸ batchTransfer(transferParams
, txParams?
): Promise
<TransactionResponse
>
Transfers multiple amounts of a token to multiple recipients.
Name | Type | Description |
---|---|---|
transferParams | TransferParams [] | An array of TransferParams objects representing the transfers to be made. |
txParams | TxParamsType | Optional transaction parameters. |
Promise
<TransactionResponse
>
A promise that resolves to a TransactionResponse
object representing the transaction result.
BaseWalletUnlocked .batchTransfer
packages/account/src/account.ts:419
▸ connect(provider
): Provider
Changes the provider connection for the account.
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
The updated Provider instance.
packages/account/src/account.ts:122
▸ createTransfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionRequest
>
A helper that creates a transfer transaction request and returns it.
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). |
Promise
<TransactionRequest
>
A promise that resolves to the prepared transaction request.
BaseWalletUnlocked .createTransfer
packages/account/src/account.ts:381
▸ encrypt(password
): Promise
<string
>
Encrypts an unlocked wallet with a password.
Name | Type | Description |
---|---|---|
password | string | the password to encrypt the wallet with. |
Promise
<string
>
packages/account/src/wallet/base-wallet-unlocked.ts:157
▸ fund<T
>(request
, params
): Promise
<T
>
Funds a transaction request by adding the necessary resources.
Name | Type | Description |
---|---|---|
T | extends TransactionRequest | The type of the TransactionRequest. |
Name | Type | Description |
---|---|---|
request | T | The transaction request to fund. |
params | EstimatedTxParams | The estimated transaction parameters. |
Promise
<T
>
A promise that resolves to the funded transaction request.
packages/account/src/account.ts:264
▸ getBalance(assetId?
): Promise
<BN
>
Retrieves the balance of the account for the given asset.
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID to check the balance for (optional). |
Promise
<BN
>
A promise that resolves to the balance amount.
BaseWalletUnlocked .getBalance
packages/account/src/account.ts:216
▸ getBalances(): Promise
<CoinQuantity
[]>
Retrieves all the balances for the account.
Promise
<CoinQuantity
[]>
A promise that resolves to an array of Coins and their quantities.
BaseWalletUnlocked .getBalances
packages/account/src/account.ts:227
▸ getCoins(assetId?
): Promise
<Coin
[]>
Retrieves coins owned by the account.
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID of the coins to retrieve (optional). |
Promise
<Coin
[]>
A promise that resolves to an array of Coins.
packages/account/src/account.ts:147
▸ getMessages(): Promise
<Message
[]>
Retrieves messages owned by the account.
Promise
<Message
[]>
A promise that resolves to an array of Messages.
BaseWalletUnlocked .getMessages
packages/account/src/account.ts:181
▸ getResourcesToSpend(quantities
, excludedIds?
): Promise
<Resource
[]>
Retrieves resources satisfying the spend query for the account.
Name | Type | Description |
---|---|---|
quantities | CoinQuantityLike [] | Quantities of resources to be obtained. |
excludedIds? | ExcludeResourcesOption | IDs of resources to be excluded from the query (optional). |
Promise
<Resource
[]>
A promise that resolves to an array of Resources.
BaseWalletUnlocked .getResourcesToSpend
packages/account/src/account.ts:134
▸ lock(): WalletLocked
Locks the wallet and returns an instance of WalletLocked.
An instance of WalletLocked.
packages/account/src/wallet/wallets.ts:48
▸ populateTransactionWitnessesSignature<T
>(transactionRequestLike
): Promise
<T
>
Populates a transaction with the witnesses signature.
Name | Type |
---|---|
T | extends TransactionRequest |
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to populate. |
Promise
<T
>
The populated transaction request.
BaseWalletUnlocked .populateTransactionWitnessesSignature
packages/account/src/wallet/base-wallet-unlocked.ts:95
▸ sendTransaction(transactionRequestLike
, «destructured»?
): Promise
<TransactionResponse
>
Populates the witness signature for a transaction and sends it to the network using provider.sendTransaction
.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to send. |
«destructured» | ProviderSendTxParams | - |
Promise
<TransactionResponse
>
A promise that resolves to the TransactionResponse object.
BaseWalletUnlocked .sendTransaction
packages/account/src/wallet/base-wallet-unlocked.ts:114
▸ signMessage(message
): Promise
<string
>
Signs a message with the wallet's private key.
Name | Type | Description |
---|---|---|
message | string | The message to sign. |
Promise
<string
>
A promise that resolves to the signature as a ECDSA 64 bytes string.
BaseWalletUnlocked .signMessage
packages/account/src/wallet/base-wallet-unlocked.ts:70
▸ signTransaction(transactionRequestLike
): Promise
<string
>
Signs a transaction with the wallet's private key.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to sign. |
Promise
<string
>
A promise that resolves to the signature as a ECDSA 64 bytes string.
BaseWalletUnlocked .signTransaction
packages/account/src/wallet/base-wallet-unlocked.ts:81
▸ simulateTransaction(transactionRequestLike
, «destructured»?
): Promise
<CallResult
>
Populates the witness signature for a transaction and sends a call to the network using provider.call
.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to simulate. |
«destructured» | EstimateTransactionParams | - |
Promise
<CallResult
>
A promise that resolves to the CallResult object.
BaseWalletUnlocked .simulateTransaction
packages/account/src/wallet/base-wallet-unlocked.ts:134
▸ transfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a destination address.
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). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/account.ts:402
▸ transferToContract(contractId
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a contract address.
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). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
BaseWalletUnlocked .transferToContract
packages/account/src/account.ts:475
▸ withdrawToBaseLayer(recipient
, amount
, txParams?
): Promise
<TransactionResponse
>
Withdraws an amount of the base asset to the base chain.
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). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
BaseWalletUnlocked .withdrawToBaseLayer
packages/account/src/account.ts:529
▸ fromEncryptedJson(jsonWallet
, password
, provider?
): Promise
<WalletUnlocked
>
Create a Wallet Unlocked from an encrypted JSON.
Name | Type | Description |
---|---|---|
jsonWallet | string | The encrypted JSON keystore. |
password | string | The password to decrypt the JSON. |
provider? | Provider | A Provider instance (optional). |
Promise
<WalletUnlocked
>
An unlocked wallet instance.
packages/account/src/wallet/wallets.ts:123
▸ fromExtendedKey(extendedKey
, provider?
): WalletUnlocked
Create a Wallet Unlocked from an extended key.
Name | Type | Description |
---|---|---|
extendedKey | string | The extended key. |
provider? | Provider | A Provider instance (optional). |
An instance of WalletUnlocked.
packages/account/src/wallet/wallets.ts:109
▸ fromMnemonic(mnemonic
, path?
, passphrase?
, provider?
): WalletUnlocked
Create a Wallet Unlocked from a mnemonic phrase.
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). |
An instance of WalletUnlocked.
packages/account/src/wallet/wallets.ts:89
▸ fromSeed(seed
, path?
, provider?
): WalletUnlocked
Create a Wallet Unlocked from a seed.
Name | Type | Description |
---|---|---|
seed | string | The seed phrase. |
path? | string | The derivation path (optional). |
provider? | Provider | A Provider instance (optional). |
An instance of WalletUnlocked.
packages/account/src/wallet/wallets.ts:73
▸ generate(generateOptions?
): WalletUnlocked
Generate a new Wallet Unlocked with a random key pair.
Name | Type | Description |
---|---|---|
generateOptions? | GenerateOptions | Options to customize the generation process (optional). |
An instance of WalletUnlocked.