Skip to main content
Version: Next

Balances

This part of the cookbook contains everything related to Keypom balances. This balance acts like a debit card, where you deposit $NEAR up front and create drop and interact with Keypom without needing to attach deposits to everything you do. For more on balances, see here.

Getting Started

For the cookbook, you will need the following installed.

  1. Node JS
  2. Keypom JS SDK
note

Ensure that you have initialized Keypom using the initKeypom function prior to running any of the SDK examples. For more info on this, see the introduction page

Viewing User Keypom Balances

To view your Keypom balance, you can use the following. This will allow you to decipher if you need to add more $NEAR to your balance before creating a drop.

// Query for the drop information for a specific drop
const userBal = await getUserBalance({
accountId: "benjiman.testnet",
})

console.log('userBal: ', userBal)

Adding to Keypom Balances

If you don't have sufficient funds to create your drop, you may add more $NEAR to your balance using the following. When specifying the amount to add, you can use amountNear or amountYocto to add in NEAR or yoctoNEAR respectively.

await addToBalance({
account: fundingAccount,
amountNear: "5"
});

Withdrawing from Keypom Balance

If you are confident you no longer need Keypom or simply wish to withdraw your Keypom balance back into your NEAR wallet, you can use the following:

await withdrawBalance({
account: fundingAccount
})