Funding
How to approve and deposit funds for Kwil databases.
Before a user can create a database and execute insert/update/delete queries, they must fund their database.
All funding interactions begin by calling the
.getFunder()
method on the Kwil class. .getFunder()
accepts to arguments: a Kwil funding pool address and an ethereum provider.// get funder
const funder = await kwil.getFunder(ethereum_signer);
Before depositing funds to the funding pool, the user must approve funds to be spent on their behalf.
// approve funds
const approve = await funder.approve(ethers.BigNumber.from("1000000000"));
After funds are approved, they may be deposited into the Kwil funding pool.
// Deposit funds
const deposit = await funder.deposit(ethers.BigNumber.from("1000000000"));
To see the available funds in a user's wallet, use the
.getBalance()
method.// Get wallet balance
const walletBalance = await funder.getBalance("wallet_address");
// Return the current allowance
const allowance = funder.getAllowance("wallet_address");
To see the total amount of funds that have been deposited by an individual wallet, use the
.getDepositedBalance()
method.// Return the deposited balance
const depositedFunds = funder.getDepositedBalance("wallet_address");
To view the token address in the selected funding pool, use the
.getTokenAddress()
method.// Get token address in funding pool
const tokenAddress = funder.getTokenAddress();
Last modified 1mo ago