hashAuthorization
Calculates an Authorization hash in EIP-7702 format: keccak256('0x05' || rlp([chain_id, address, nonce])).
Import
import { hashAuthorization } from 'viem/experimental'Usage
import { hashAuthorization } from 'viem/experimental'
 
hashAuthorization({
  contractAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
  chainId: 1,
  nonce: 0,
})
// 0xd428ed36e6098e46b40a4cb99b83b930b0ca1f054f40b5996589eda33c295663Returns
The hashed Authorization.
Parameters
address
- Type: Address
Address of the contract to set as code for the Authority.
import { hashAuthorization } from 'viem/experimental'
 
hashAuthorization({
  contractAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 
  chainId: 1,
  nonce: 0,
}) chainId
- Type: number
Chain ID to authorize.
import { hashAuthorization } from 'viem/experimental'
 
hashAuthorization({
  contractAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
  chainId: 1, 
  nonce: 0,
}) nonce
- Type: number
Nonce of the Authority to authorize.
import { hashAuthorization } from 'viem/experimental'
 
hashAuthorization({
  contractAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
  chainId: 1,
  nonce: 0, 
}) to
- Type: "hex" | "bytes"
- Default: "hex"
Output format.
import { hashAuthorization } from 'viem/experimental'
 
hashAuthorization({
  contractAddress: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
  chainId: 1,
  nonce: 0, 
  to: 'bytes', 
}) 
