Kwil v2
Search…
⌃K

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);

Approve Funds

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"));

Deposit Funds

After funds are approved, they may be deposited into the Kwil funding pool.
// Deposit funds
const deposit = await funder.deposit(ethers.BigNumber.from("1000000000"));

Get Wallet Balance

To see the available funds in a user's wallet, use the .getBalance() method.
// Get wallet balance
const walletBalance = await funder.getBalance("wallet_address");

Get Allowance

To see the amount of funds that have been approved, use the .getAllowance() method.
// Return the current allowance
const allowance = funder.getAllowance("wallet_address");

Get Deposited Balance

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");

Get Token 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();