Testing on a Fun Testnet

Testing via Fun's remote fork reproduces Ethereum's mainnet environment on Fun's servers & provides an EOA prefunded with an unlimited amount of ETH so developers can test without worrying about how to procure gas resources. Additionally, unlike testing on a local fork, testing on Fun's remote fork does not require a developer to spin up Bundler & Hardhat services.

The details of the fork's prefunded EOA are given below:

Public Key

0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

 
Private Key

0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

 

Additionally, to test on a remote fork, the Environment Config's chain variable must be set to "fun-testnet".

The chainID of our remote fork is 36864.

Full Example

The following example flow showcases how to create a new FunWallet on a remote fork of Ethereum's mainnet & perform a swap between ETH & USDC:

,
swap.js
const { FunWallet, configureEnvironment } = require("fun-wallet")
const { Eoa } = require("fun-wallet/auth")
const { fundWallet } = require("fun-wallet/utils")
const PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
const API_KEY = "MYny3w7xJh6PRlRgkJ9604sHouY2MTke6lCPpSHq"
const swap = async () => {
await configureEnvironment({
apiKey: API_KEY,
chain: "fun-testnet"
})
const auth = new Eoa({ privateKey: PRIVATE_KEY })
const uniqueId = await auth.getUniqueId()
const wallet = new FunWallet({ uniqueId })
await fundWallet(auth, wallet, 1)
const receipt = await wallet.swap(auth, {
in: "eth",
amount: .001,
out: "dai",
});
}
swap()