SDK
Typescript SDK for HotKeys
Installation
npm i hotkeys-sdk
To install the SDK, developers need to run the command "npm i hotkeys-sdk" in the terminal.
Generate a key
import * as hotkeys from "hotkeys-sdk";
const [txId, mintId] = await hotkeys.generateKey(
connection,
owner,
"HK: Plugin",
"https://raw.githubusercontent.com/HotKeysInc/programs/main/assets/test_metadata.json"
);
console.log("txId: ", txId);
console.log("mintId: ", mintId);
The "generateKey" function generates a new key with a specified name and metadata. The function takes four parameters: connection, owner, name, and metadata. Upon successful execution, the function returns an array of two values: a transaction ID (txId) and a mint ID (mintId).
Resell a key
import * as hotkeys from "hotkeys-sdk";
const token = new PublicKey("4eepA7KT2ZzyA8Gih94AxVb5uNPXy7d2mPZR6HF2TtZF");
const txId = await hotkeys.sellKey(connection, owner, buyer, token, 0.1);
console.log("txId: ", txId);
The "sellKey" function resells a key from one owner to another. The function takes five parameters: connection, owner, buyer, token, and price. Upon successful execution, the function returns a transaction ID (txId).
Check access
import * as hotkeys from "hotkeys-sdk";
const tokenExpected = new PublicKey(
"4eepA7KT2ZzyA8Gih94AxVb5uNPXy7d2mPZR6HF2TtZF"
);
if (await hotkeys.checkAccess(connection, owner, tokenExpected)) {
console.log("Access granted");
} else {
console.log("Access denied");
}
The "checkAccess" function checks if a given owner has access to a particular token. The function takes three parameters: connection, owner, and tokenExpected. If the owner has access to the token, the function returns true. If not, the function returns false.
Delete / Burn a key
import * as hotkeys from "hotkeys-sdk";
const tokenToDestroy = new PublicKey(
"61F6P86LKaztWmYyjiPTjf1oqdkhBEYy6Y8FcYVq9o2w"
);
const response = await destroyKey(connection, owner, tokenToDestroy);
console.log("response: ", response);
The "destroyKey" function deletes or burns a key owned by the specified owner. The function takes three parameters: connection, owner, and tokenToDestroy. Upon successful execution, the function returns a response.
Developers can import the hotkeys-sdk module to access these functions and use them to integrate HotKeys into their TypeScript applications.
Last updated