Skip to content
On this page

setNonce โ€‹

Modifies (overrides) the nonce of an account.

Usage โ€‹

ts
import { testClient } from './client'

await testClient.setNonce({ 
  address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
  nonce: 420
})
ts
import { createTestClient, http } from 'viem'
import { foundry } from 'viem/chains'

export const testClient = createTestClient({
  chain: foundry,
  mode: 'anvil',
  transport: http(), 
})

Parameters โ€‹

address โ€‹

The address of the target account.

ts
await testClient.setNonce({
  address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', 
  nonce: 420
})

nonce (optional) โ€‹

  • Type: number

The nonce.

ts
await testClient.setNonce({
  address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
  nonce: 420 
})

Released under the MIT License.