Creates a new Wallet.
The public key for the account.
The private key used for signing transactions for the account.
(Optional) Options to initialize a Wallet.
OptionalmasterAddress?: stringInclude if a Wallet uses a Regular Key Pair. It must be the master address of the account.
Optionalseed?: stringThe seed used to derive the account keys.
ReadonlyclassicReadonlyprivateReadonlypublicOptional ReadonlyseedStaticfromDerives a wallet from a secret (AKA a seed).
Derives a wallet from a seed.
A string used to generate a keypair (publicKey/privateKey) to derive a wallet.
(Optional) Options to derive a Wallet.
Optionalalgorithm?: ECDSAThe digital signature algorithm to generate an address for.
OptionalmasterAddress?: stringInclude if a Wallet uses a Regular Key Pair. It must be the master address of the account.
A Wallet derived from a seed.
Alias for wallet.classicAddress.
The wallet's classic address.
Gets an X-address in Testnet/Mainnet format.
A tag to be included within the X-address.
A boolean to indicate if X-address should be in Testnet (true) or Mainnet (false) format.
An X-address.
Signs a transaction offline.
Wallet instance.
A transaction to be signed offline.
Optionalmultisign: string | booleanSpecify true/false to use multisign or actual address (classic/x-address) to make multisign tx request.
A signed transaction.
const { Client, Wallet } = require('xrpl')
const client = new Client('wss://s.altnet.rippletest.net:51233')
async function signTransaction() {
await client.connect()
const { balance: balance1, wallet: wallet1 } = client.fundWallet()
const { balance: balance2, wallet: wallet2 } = client.fundWallet()
const transaction = {
TransactionType: 'Payment',
Account: wallet1.address,
Destination: wallet2.address,
Amount: '10'
}
try {
await client.autofill(transaction)
const { tx_blob: signed_tx_blob, hash} = await wallet1.sign(transaction)
console.log(signed_tx_blob)
} catch (error) {
console.error(`Failed to sign transaction: ${error}`)
}
const result = await client.submit(signed_tx_blob)
await client.disconnect()
}
signTransaction()
In order for a transaction to be validated, it must be signed by the account sending the transaction to prove That the owner is actually the one deciding to take that action.
In this example, we created, signed, and then submitted a transaction to testnet. You may notice that the
Output of sign includes a tx_blob and a hash, both of which are needed to submit & verify the results.
Note: If you pass a Wallet to client.submit or client.submitAndWait it will do signing like this under the hood.
tx_blob is a binary representation of a transaction on the XRP Ledger. It's essentially a byte array
that encodes all of the data necessary to execute the transaction, including the source address, the destination
address, the amount, and any additional fields required for the specific transaction type.
hash is a unique identifier that's generated from the signed transaction data on the XRP Ledger. It's essentially
A cryptographic digest of the signed transaction blob, created using a hash function. The signed transaction hash is
Useful for identifying and tracking specific transactions on the XRP Ledger. It can be used to query transaction
Information, verify the authenticity of a transaction, and detect any tampering with the transaction data.
Verifies a signed transaction offline.
A signed transaction (hex string of signTransaction result) to be verified offline.
Returns true if a signedTransaction is valid.
StaticfromDerives a wallet from an entropy (array of random numbers).
An array of random numbers to generate a seed used to derive a wallet.
(Optional) Options to derive a Wallet.
Optionalalgorithm?: ECDSAThe digital signature algorithm to generate an address for.
OptionalmasterAddress?: stringInclude if a Wallet uses a Regular Key Pair. It must be the master address of the account.
A Wallet derived from an entropy.
StaticfromDerives a wallet from a bip39 or RFC1751 mnemonic (Defaults to bip39).
A string consisting of words (whitespace delimited) used to derive a wallet.
(Optional) Options to derive a Wallet.
Optionalalgorithm?: ECDSAOnly used if opts.mnemonicEncoding is 'rfc1751'. Allows the mnemonic to generate its
secp256k1 seed, or its ed25519 seed. By default, it will generate the secp256k1 seed
to match the rippled wallet_propose default algorithm.
OptionalderivationPath?: stringThe path to derive a keypair (publicKey/privateKey). Only used for bip39 conversions.
OptionalmasterAddress?: stringInclude if a Wallet uses a Regular Key Pair. It must be the master address of the account.
OptionalmnemonicEncoding?: "bip39" | "rfc1751"If set to 'rfc1751', this interprets the mnemonic as a rippled RFC1751 mnemonic like
wallet_propose generates in rippled. Otherwise the function defaults to bip39 decoding.
A Wallet derived from a mnemonic.
StaticfromDerives a wallet from a seed.
A string used to generate a keypair (publicKey/privateKey) to derive a wallet.
(Optional) Options to derive a Wallet.
Optionalalgorithm?: ECDSAThe digital signature algorithm to generate an address for.
OptionalmasterAddress?: stringInclude if a Wallet uses a Regular Key Pair. It must be the master address of the account.
A Wallet derived from a seed.
Staticgenerategenerate() creates a new random Wallet. In order to make this a valid account on ledger, you must
Send XRP to it. On test networks that can be done with "faucets" which send XRP to any account which asks
For it. You can call client.fundWallet() in order to generate credentials and fund the account on test networks.
The digital signature algorithm to generate an address for.
A new Wallet derived from a generated seed.
A utility for deriving a wallet composed of a keypair (publicKey/privateKey). A wallet can be derived from either a seed, mnemonic, or entropy (array of random numbers). It provides functionality to sign/verify transactions offline.
Example