1.6 KiB
1.6 KiB
description
| description |
|---|
| Recovers the signing address from a transaction & signature. |
recoverTransactionAddress
Recovers the original signing address from a transaction & signature.
Usage
:::code-group
import { recoverTransactionAddress } from 'viem'
import { walletClient } from './client'
const request = await walletClient.prepareTransactionRequest({
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
const serializedTransaction = await walletClient.signTransaction(request)
const address = await recoverTransactionAddress({ // [!code focus:99]
serializedTransaction,
})
import { createWalletClient, custom } from 'viem'
// Retrieve Account from an EIP-1193 Provider.
const [account] = await window.ethereum.request({
method: 'eth_requestAccounts'
})
export const walletClient = createWalletClient({
account,
transport: custom(window.ethereum!)
})
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
export const walletClient = createWalletClient({
account: privateKeyToAccount('0x...'),
transport: http()
})
:::
Returns
The signing address.
Parameters
serializedTransaction
- Type:
TransactionSerialized
The RLP serialized transaction.
signature (optional)
- Type:
Signature | Hex | ByteArray - Default: Signature inferred on
serializedTransaction(if exists)
The signature.