Pay gas in base gas tokens

Pay for wallet deployments, transfers, or NFT mints in the network's base token.


FunWallets pay gas in the base gas token by default. No additional configuration is required.


Transfer ETH paying gas in the base gas token

The following example showcases how to transfer 0.00001 ETH to destAddr, paying for the transaction gas in the base gas token.

,
BaseGasToken.js
const { FunWallet, configureEnvironment } = require("fun-wallet")
const { Eoa } = require("fun-wallet/auth")
const { fundWallet } = require("fun-wallet/utils")
const PRIVATE_KEY = "0x98e9cfb323863bc4bfc094482703f3d4ac0cd407e3af2351c00dde1a6732756a"
const USER_TWITTER_HANDLE = "elonmusk"
const CHAIN_ID = "ethereum-goerli"
const API_KEY = "MYny3w7xJh6PRlRgkJ9604sHouY2MTke6lCPpSHq"
const transfer = async () => {
// No gas sponsor, so it is paying for gas in base tokens
await configureEnvironment({
apiKey: API_KEY
})
const uniqueTwitterId = "twitter###" + USER_TWITTER_HANDLE
const destAddr = await FunWallet.getAddress(uniqueTwitterId, index = 0, CHAIN_ID, API_KEY)
const auth = new Eoa({ privateKey: PRIVATE_KEY })
const uniqueId = await auth.getUniqueId()
const wallet = new FunWallet({ uniqueId })
// NOTE: Wallet must be prefunded if not using a sponsor
// await fundWallet(funder_auth, wallet, .005)
const receipt = await wallet.transfer(auth, {
to: destAddr,
amount: 0.00001,
token: "eth"
})
}
transfer()