Environment Management

Methods to set default environment variables

Overview

Environment Management allows developers to set default variables to be used when calling FunWallet methods. Currently, a developer can specify the following default environment variables:

Config PropertyDefault Value
API KeyN/A
Target Blockchaingoerli
Gas Payment ModeBase Gas Token
Developer FeeNo fee
Skip DB Actionfalse

Methods


configureEnvironment

Configure and set default environment variables
await configureEnvironment({
apiKey: "nbiQS2Ut932ewF5TqiCpl2ZTUqPWb1P29N8GcJjy",
chain: "goerli",
gasSponsor: {
token: "usdc",
sponsorAddress: "0x8aF2c6E3C6E3C9a8A0cA2Bc4B5f5Bb8d2b8BbDd2",
usePermit: true
},
fee: {
token: "usdc",
amount: 1,
recipient: "0x8aF2c6E3C6E3C9a8A0cA2Bc4B5f5Bb8d2b8BbDd2"
}
})

Parameters

options
object

Default environment configuration variables. It has the following properties:

options properties
apiKey
string
Required

An API key is required to use the FunWallet SDK. You can get one by at the Fun dashboard.

nbiQS2Ut932ewF5TqiCpl2ZTUqPWb1P29N8GcJjy
chain
string || Chain || number

The network the SDK will be configured to. Used for operations, querying information, etc. Defaults to Goerli

goerli || 5
gasSponsor
object
gasSponsor properties
token
address || string

When used, the sponsor becomes a token sponsor, while its absence defaults to a gasless sponsor.

usdc
sponsorAddress
address

Uses the given sponsor address to pay for operations in ETH. If not provided, uses the Fun Owned token sponsor.

0x8aF2c6E3C6E3C9a8A0cA2Bc4B5f5Bb8d2b8BbDd2
usePermit
bool

When true, paying for paymaster for tokens will avoid having to give approval for each token transfer. Defaults to true.

true
fee
object
fee properties
token
string

The token users will pay the fee in.

usdc
amount
number

The amount per operation a user will pay in the token.

1
gasPercent
number

The amount (in percent terms, so 10 = 10%) as a percentage of gas per operation a user will pay in the token.

10
recipient
Address
Required

If the recipient address refers to a contract that is unable to receive ETH via receive() or fallback(), the Funwallet transactions will be reverted

0x8aF2c6E3C6E3C9a8A0cA2Bc4B5f5Bb8d2b8BbDd2
skipDBAction
bool

If set to true all actions will not be stored in our DB by default. Used to maintain privacy or to run your own storage.