useFundWithWallet
Provides methods for programmatically funding your primary wallet from a connected wallet, as well as information on whether external wallet funding has been enabled.
In order to use these methods, you must have external wallet funding enabled under the “Funding” section of the dashboard.
In order to trigger the transaction, 3 pieces of information are required:
- A connected
fromWallet
- The
amount
to send - The
token
to send
Our methods allow you to get each one of these values from the user, and then pass them into the fund
method.
fund
method
Given a connected wallet, the amount and the token, the fund
method will trigger a transaction to the primary wallet.
This is the only method that is 100% headless, meaning it does not require any user interaction and shows no UI.
It takes a single object with the following properties:
Props
The wallet that will be used to send the transaction.
The token of the transaction. When undefined, uses the wallet’s connected chain’s native token.
The amount of the token to send.
Return value
The fund
method returns a Promise that resolves to the transaction hash.
Example
connectWalletForFunding
method
This method will prompt the user to connect a wallet by opening a wallet list modal.
It doesn’t add the connected wallet to userWallets
.
This method takes no arguments.
Return value
It returns a Promise that resolves to the wallet that the user connected.
Example
promptAmountAndFund
method
Given a connected wallet, the promptAmountAndFund
method will prompt the user to enter an amount and token,
and then trigger a transaction to the primary wallet.
This method takes a single object with the following properties:
Props
The wallet that will be used to send the transaction.
Allows you to specify the amount that the user will fund their wallet with. The options for rule are as follows:
exact
: The user will not be able to change the amount.recommended
: Set initial amount, but user will be able to change it.minimum
: Set initial amount, and user will be able to change it, but not below the minimum amount.
Default to 0 if not provided.
Allows you to specify the token that the user will fund their wallet with. The options for rule are as follows:
exact
: The user will not be able to change the selected token.recommended
: Set initial selected token, but user will be able to change it.exact-with-amount
: Same asexact
, and also treats theamount
param as relative to the selected token rather than USD.
Default to the wallet’s connected chain’s native token if not provided.
Allows you to define the initial quick suggestions that show up until first user interaction.
If an array is passed directly, uses $ (USD
) as the token.
If a token is provided, but doesn’t correspond to the selected token, quick suggestions will NOT be shown.
Return value
void
Example
externalWalletFundingEnabled
property
This property is a boolean indicating whether external wallet funding has been enabled.
Example
Full Example
Was this page helpful?