@fuel-ts/account .BaseWalletUnlocked
BaseWalletUnlocked
provides the base functionalities for an unlocked wallet.
↳ BaseWalletUnlocked
• new BaseWalletUnlocked(privateKey
, provider?
): BaseWalletUnlocked
Creates a new BaseWalletUnlocked instance.
Name | Type | Description |
---|---|---|
privateKey | BytesLike | The private key of the wallet. |
provider? | Provider | A Provider instance (optional). |
packages/account/src/wallet/base-wallet-unlocked.ts:39
• Protected
Optional
_connector: FuelConnector
packages/account/src/account.ts:54
• Protected
Optional
_provider: Provider
The provider used to interact with the network.
packages/account/src/account.ts:52
• Readonly
address: AbstractAddress
The address associated with the account.
packages/account/src/account.ts:47
• signer: () => Signer
▸ (): Signer
A function that returns the wallet's signer.
packages/account/src/wallet/base-wallet-unlocked.ts:31
▪ Static
defaultPath: string
= "m/44'/1179993420'/0'/0/0"
Default HDWallet path.
packages/account/src/wallet/base-wallet-unlocked.ts:26
• get
privateKey(): string
Gets the private key of the wallet.
string
The private key of the wallet.
packages/account/src/wallet/base-wallet-unlocked.ts:50
• get
provider(): Provider
The provider used to interact with the network.
Throws
FuelError
if the provider is not set.
A Provider instance.
Account.provider
packages/account/src/account.ts:76
• set
provider(provider
): void
Sets the provider for the account.
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
void
Account.provider
packages/account/src/account.ts:89
• get
publicKey(): string
Gets the public key of the wallet.
string
packages/account/src/wallet/base-wallet-unlocked.ts:59
▸ 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:99
▸ createTransfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionRequest
>
A helper that creates a transfer transaction request and returns it.
Name | Type | Default value | Description |
---|---|---|---|
destination | string | AbstractAddress | undefined | The address of the destination. |
amount | BigNumberish | undefined | The amount of coins to transfer. |
assetId | BytesLike | BaseAssetId | The asset ID of the coins to transfer. |
txParams | TxParamsType | {} | The transaction parameters (gasLimit, gasPrice, maturity). |
Promise
<TransactionRequest
>
A promise that resolves to the prepared transaction request.
packages/account/src/account.ts:319
▸ encrypt(password
): Promise
<string
>
Name | Type |
---|---|
password | string |
Promise
<string
>
packages/account/src/wallet/base-wallet-unlocked.ts:146
▸ fund<T
>(request
, coinQuantities
, fee
): Promise
<void
>
Adds resources to the transaction enough to fund it.
Name | Type |
---|---|
T | extends TransactionRequest |
Name | Type | Description |
---|---|---|
request | T | The transaction request. |
coinQuantities | CoinQuantity [] | The coin quantities required to execute the transaction. |
fee | BN | The estimated transaction fee. |
Promise
<void
>
A promise that resolves when the resources are added to the transaction.
packages/account/src/account.ts:240
▸ getBalance(assetId?
): Promise
<BN
>
Retrieves the balance of the account for the given asset.
Name | Type | Default value | Description |
---|---|---|---|
assetId | BytesLike | BaseAssetId | The asset ID to check the balance for. |
Promise
<BN
>
A promise that resolves to the balance amount.
packages/account/src/account.ts:193
▸ getBalances(): Promise
<CoinQuantity
[]>
Retrieves all the balances for the account.
Promise
<CoinQuantity
[]>
A promise that resolves to an array of Coins and their quantities.
packages/account/src/account.ts:203
▸ getCoins(assetId?
): Promise
<Coin
[]>
Retrieves coins owned by the account.
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID of the coins to retrieve. |
Promise
<Coin
[]>
A promise that resolves to an array of Coins.
packages/account/src/account.ts:124
▸ getMessages(): Promise
<Message
[]>
Retrieves messages owned by the account.
Promise
<Message
[]>
A promise that resolves to an array of Messages.
packages/account/src/account.ts:158
▸ getResourcesToSpend(quantities
, excludedIds?
): Promise
<Resource
[]>
Retrieves resources satisfying the spend query for the account.
Name | Type | Description |
---|---|---|
quantities | CoinQuantityLike [] | IDs of coins to exclude. |
excludedIds? | ExcludeResourcesOption | IDs of resources to be excluded from the query. |
Promise
<Resource
[]>
A promise that resolves to an array of Resources.
packages/account/src/account.ts:111
▸ populateTransactionWitnessesSignature(transactionRequestLike
): Promise
<TransactionRequest
>
Populates a transaction with the witnesses signature.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to populate. |
Promise
<TransactionRequest
>
The populated transaction request.
packages/account/src/wallet/base-wallet-unlocked.ts:94
▸ 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.
packages/account/src/wallet/base-wallet-unlocked.ts:109
▸ 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.
packages/account/src/wallet/base-wallet-unlocked.ts:69
▸ 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.
packages/account/src/wallet/base-wallet-unlocked.ts:80
▸ 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.
packages/account/src/wallet/base-wallet-unlocked.ts:129
▸ transfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a destination address.
Name | Type | Default value | Description |
---|---|---|---|
destination | string | AbstractAddress | undefined | The address of the destination. |
amount | BigNumberish | undefined | The amount of coins to transfer. |
assetId | BytesLike | BaseAssetId | The asset ID of the coins to transfer. |
txParams | TxParamsType | {} | The transaction parameters (gasLimit, gasPrice, maturity). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/account.ts:365
▸ transferToContract(contractId
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a contract address.
Name | Type | Default value | Description |
---|---|---|---|
contractId | string | AbstractAddress | undefined | The address of the contract. |
amount | BigNumberish | undefined | The amount of coins to transfer. |
assetId | BytesLike | BaseAssetId | The asset ID of the coins to transfer. |
txParams | TxParamsType | {} | The optional transaction parameters. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/account.ts:394
▸ 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 optional transaction parameters. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.