@fuel-ts/wallet .WalletUnlocked
WalletUnlocked
provides the functionalities for an unlocked wallet.
↳ WalletUnlocked
• new WalletUnlocked(privateKey
, provider?
)
Creates a new BaseWalletUnlocked instance.
Name | Type | Default value | Description |
---|---|---|---|
privateKey | BytesLike | undefined | The private key of the wallet. |
provider | string | Provider | FUEL_NETWORK_URL | The provider URL or a Provider instance. |
BaseWalletUnlocked .constructor
• Readonly
address: AbstractAddress
The address associated with the account.
• provider: Provider
The provider used to interact with the Fuel network.
• signer: () => Signer
▸ (): Signer
A function that returns the wallet's signer.
Signer
▪ Static
defaultPath: string
= "m/44'/1179993420'/0'/0/0"
Default HDWallet path.
BaseWalletUnlocked .defaultPath
• get
privateKey(): string
Gets the private key of the wallet.
string
The private key of the wallet.
BaseWalletUnlocked.privateKey
• get
publicKey(): string
Gets the public key of the wallet.
string
BaseWalletUnlocked.publicKey
▸ 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.
▸ encrypt(password
): Promise
<string
>
Name | Type |
---|---|
password | string |
Promise
<string
>
▸ 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.
BaseWalletUnlocked .getBalance
▸ 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
▸ 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.
BaseWalletUnlocked .getMessages
▸ 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.
BaseWalletUnlocked .getResourcesToSpend
▸ lock(): WalletLocked
Locks the wallet and returns an instance of WalletLocked.
An instance of WalletLocked.
▸ 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.
BaseWalletUnlocked .populateTransactionWitnessesSignature
▸ sendTransaction(transactionRequestLike
): 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. |
Promise
<TransactionResponse
>
A promise that resolves to the TransactionResponse object.
BaseWalletUnlocked .sendTransaction
▸ 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
▸ 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
▸ simulateTransaction(transactionRequestLike
): 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. |
Promise
<CallResult
>
A promise that resolves to the CallResult object.
BaseWalletUnlocked .simulateTransaction
▸ 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.
BaseWalletUnlocked .transferToContract
▸ 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.
BaseWalletUnlocked .withdrawToBaseLayer
▸ Static
fromEncryptedJson(jsonWallet
, password
): Promise
<WalletUnlocked
>
Name | Type |
---|---|
jsonWallet | string |
password | string |
Promise
<WalletUnlocked
>
▸ Static
fromExtendedKey(extendedKey
, provider?
): WalletUnlocked
Create a Wallet Unlocked from an extended key.
Name | Type | Description |
---|---|---|
extendedKey | string | The extended key. |
provider? | Provider | The provider URL or a Provider instance (optional). |
An instance of WalletUnlocked.
▸ Static
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 | The provider URL or a Provider instance (optional). |
An instance of WalletUnlocked.
▸ Static
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 | The provider URL or a Provider instance (optional). |
An instance of WalletUnlocked.
▸ Static
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.
Was this page helpful?