Creating Tokens on K2
The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime. One of the SPL programs is the Solana Token Program which defines a common implementation for Fungible and Non-Fungible tokens. Using the Solana Token Program simplifies token management.
To interact with a Solana node inside a JavaScript application, use the Solana-web3.js library, which gives a convenient interface for the RPC methods. Full documentation of the library can be found here.
Since K2 is a separate network from the core Solana system, it's necessary to use Koii's custom library, Koii-Web3.js.
Installation
Or
Token Contract
Fungible tokens are non-unique divisible tokens created on a blockchain. On Solana, fungible tokens are referred to as SPL-tokens. If you intend to build a token on K2 either for governance, staking, or as a reward system for node operators, the Solana Token Program can be used to create and manage SPL tokens.
To create a token, instructions are sent to the Token Program, including assigning which keypair has the authority to mint tokens. This creates a new data account (the Mint acct). Each different SPL token has only one mint account associated with it. The program owner of the mint account is set to the Solana token program. Data stored in the account includes:
Mint account's address
The current number of tokens that have been minted
The mint authority (i.e the public key of the keypair that is allowed to mint tokens)
The number of decimals for the smallest denomination of the token.
Tokens when initially created by spl-token
have no supply.
Learn more about creating SPL tokens on the SPL documentation.
NFT Contract
Non-fungible tokens (NFTs) are unique and non-divisible tokens created on a blockchain. Just like fungible tokens, NFTs can be created on K2. The main difference is that an NFT is simply a token type where only a single token has been minted.
Example contract for creating an NFT with spl-token
:
Learn more about creating NFTs on the SPL documentation
Last updated