@fuel-ts/wallet.WalletLocked
WalletLocked
provides the functionalities for a locked wallet.
↳ WalletLocked
• new WalletLocked(address
, provider?
)
Creates a new Account instance.
Name | Type | Default value | Description |
---|---|---|---|
address | string | AbstractAddress | undefined | The address of the account. |
provider | string | Provider | FUEL_NETWORK_URL | The provider URL or a Provider instance. |
• Readonly
address: AbstractAddress
The address associated with the account.
• provider: Provider
The provider used to interact with the network.
▸ connect(provider
): Provider
Changes the provider connection for the account.
Name | Type | Description |
---|---|---|
provider | string | Provider | The provider URL or a Provider instance. |
The updated Provider instance.
▸ fund<T
>(request
): Promise
<void
>
Adds resources to the transaction enough to fund it.
Name | Type |
---|---|
T | extends TransactionRequest |
Name | Type | Description |
---|---|---|
request | T | The transaction request. |
Promise
<void
>
A promise that resolves when the resources are added to the transaction.
▸ 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.
▸ getBalances(): Promise
<CoinQuantity
[]>
Retrieves all the balances for the account.
Promise
<CoinQuantity
[]>
A promise that resolves to an array of Coins and their quantities.
▸ 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.
▸ getMessages(): Promise
<Message
[]>
Retrieves messages owned by the account.
Promise
<Message
[]>
A promise that resolves to an array of Messages.
▸ 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.
▸ sendTransaction(transactionRequestLike
): Promise
<TransactionResponse
>
Sends a transaction to the network.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to be sent. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
▸ simulateTransaction(transactionRequestLike
): Promise
<CallResult
>
Simulates a transaction.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to be simulated. |
Promise
<CallResult
>
A promise that resolves to the call result.
▸ transfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a destination address.
Name | Type | Default value | Description |
---|---|---|---|
destination | 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.
▸ transferToContract(contractId
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a contract address.
Name | Type | Default value | Description |
---|---|---|---|
contractId | 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.
▸ unlock(privateKey
): WalletUnlocked
Unlocks the wallet using the provided private key and returns an instance of WalletUnlocked.
Name | Type | Description |
---|---|---|
privateKey | BytesLike | The private key used to unlock the wallet. |
An instance of WalletUnlocked.
▸ withdrawToBaseLayer(recipient
, amount
, txParams?
): Promise
<TransactionResponse
>
Withdraws an amount of the base asset to the base chain.
Name | Type | Description |
---|---|---|
recipient | 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.