Set Transaction Mode

Send transactions now or later.


By default, FunWallets execute transactions inline.

To generate the transaction and execute it later, toggle the sendTxLater parameter in the environment configuration. To execute the generated transaction, call the FunWallet.sendTx method with the previously generated transaction.

const options = {0x98e9cfb323863bc4bfc094482703f3d4ac0cd407e3af2351c00dde1a6732756a
sendTxLater: true
}
,
manual-transaction.js
const { FunWallet, configureEnvironment } = require("fun-wallet")
const { Eoa } = require("fun-wallet/auth")
const { fundWallet } = require("fun-wallet/utils")
const PRIVATE_KEY = "0x98e9cfb323863bc4bfc094482703f3d4ac0cd407e3af2351c00dde1a6732756a"
const API_KEY = "MYny3w7xJh6PRlRgkJ9604sHouY2MTke6lCPpSHq"
const TO_ADDR = "0x07Ac5A221e5b3263ad0E04aBa6076B795A91aef9"
async function sendManualTransaction() {
// Configure sendTxLater to true
await configureEnvironment({
apiKey: API_KEY,
sendTxLater: true
})
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 transactionToSend = await wallet.transfer(auth, {
to: TO_ADDR,
amount: 5,
token: "USDC"
})
// auth: an auth object (see Auth API)
// op: the transaction returned
await wallet.sendTx({ auth, op: transactionToSend })
}
sendManualTransaction()

See more information about configureEnvironment.