Skip to content
On this page

setBalance โ€‹

Modifies the balance of an account.

Usage โ€‹

ts
import { parseEther } from 'viem'
import { testClient } from './client'
 
await testClient.setBalance({ 
  address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
  value: parseEther('1')
})
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.setBalance({
  address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', 
  value: parseEther('1')
})

value (optional) โ€‹

  • Type: bigint

The value (in wei) to set.

ts
await testClient.setBalance({
  address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
  value: 1000000000000000000n 
})

Released under the MIT License.