Drop Configurations
This part of the cookbook contains everything related to drop configurations, including multi-use drops, and creating custom subaccounts.
Getting Started
For the cookbook, you will need the following installed.
These scripts will not run without the proper setup shown in the introduction page.
Creating a Multi-Use Simple Drop
To make all the keys in the drop multi-use, you can specify usesPerKey in the dropConfig parameter config. In this example, each of the 2 keys created will have 5 uses.
- 🔑 Keypom SDK
- 🦀 Rust Function Prototypes
// Creating drop with 2 keys with 5 uses each
const {keys} = await createDrop({
account: fundingAccount,
numKeys: 2,
config:{
usesPerKey: 5
},
depositPerUseNEAR: "0.1",
});
console.log(keys)
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
config:{
uses_per_key: u64
}
) -> Option<DropIdJson>
pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
createDrop is limited to adding 50 password protected keys or 100 non-protected keys at a time. To add more keys, see the large drops example.
Creating Custom Subaccounts
By specifying a custom dropRoot, all new accounts created using your drop will be a subaccount of the specified account. For example, all accounts created with the drop below will follow the form of ${YOUR_USERNAME}.moonpom.near.
- 🔑 Keypom SDK
- 🦀 Rust Function Prototypes
// Creating drop with 2 keys with 5 uses each
const {keys} = await createDrop({
account: fundingAccount,
numKeys: 2,
config:{
dropRoot: "mint-brigade.testnet"
},
depositPerUseNEAR: "0.1",
});
console.log(keys)
pub fn create_drop(
&mut self,
// How much $NEAR should be transferred everytime a key is used? Can be 0.
deposit_per_use: U128,
config:{
usage:{
root_account_id: "mint-brigade.testnet"
}
}
) -> Option<DropIdJson>
pub fn add_keys(
&mut self,
// Public keys to add
public_keys: Vec<PublicKey>,
// Overload the specific drop ID
drop_id: DropIdJson,
) -> Option<DropIdJson>
the dropRoot account must have a contract deployed to it that exposes a method create_account to create the sub-account. A sample contract can be found here
In addition, it is wise to gatekeep account creation to ensure that not anyone can create subaccounts of your account.
For this reason, the above code will not work out of the box.