Skip to content
LogoLogo

Fund Account

faucet.fund

Funds an account with testnet tokens.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
})
 
.('Receipts:', )
Receipts: [{ status: 'success', transactionHash: '0x1234...' }]

Asynchronous Usage

The examples above use a *Sync variant of the action, that will wait for the transactions to be included before returning.

import {  } from './viem.config'
 
const  = await ..({
  : '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
})

Recipes

Fund a Fresh Account for Each Test Run

Create a throwaway account with Account.fromSecp256k1 and fund it, giving each CI run an isolated, prefunded identity.

import {  } from 'viem/tempo'
import {  } from 'viem/utils'
import {  } from './viem.config'
 
const  = .(.())
 
await ..({ :  })
 
const {  } = await ..({
  : ,
  : { : '10' },
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  : '0x20c0000000000000000000000000000000000000',
})

Top Up a Test Runner When It Runs Low

Check the balance with token.getBalance and only hit the faucet when a long-lived runner drops below a threshold.

import {  } from './viem.config'
 
const  = await ..({
  : '0x20c0000000000000000000000000000000000000',
})
 
if ((.) < 100)
  await ..({ : . })

Return Value

type ReturnType = readonly TransactionReceipt[]

The transaction receipts.

Parameters

account

  • Type: Account | Address

Account to fund.

timeout

  • Type: number

Timeout in milliseconds.