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