Solana Tokens (SPL)
In order to create a currency on top of the Solana blockchain, we must use the token program provided by the Solana Program Library (which is why they are called SPL tokens). The program source code can be found here, although previous knowledge of how it works is not necessary to proceed with this guide.
Differences Between ERC-20 and SPL Tokens
For currencies to be created on the Ethereum blockchain, you must deploy a smart contract containing the workings of the token you wish to create – usually following a standard such as the ERC-20 one. For Solana, however, there is already a “coin factory” program provided by the official team and all we have to do is pass the correct instructions to this program.
Creating a New Token
Step 1
The first prerequisite you will need is the creation of an account and a Project (API Key) on Cryptum Dashboard.
PS: Our dashboard is almost ready! To generate an API Key, contact [email protected]
Step 2
Supposing you already installed our SDK available on GitHub here, all we need to do is create instantiate it like this:
const CryptumSdk = require('cryptum-sdk')
const sdk = new CryptumSdk({
environment: 'testnet', // 'testnet', 'mainnet'
apiKey: "YOUR-API-KEY-HERE",
})
Step 3
Then you must instantiate the wallet that will be used to create the tokens:
const wallet = await sdk.wallet.generateWallet({
protocol: 'SOLANA',
mnemonic: 'lorem ipsum dolor sit amet consectetur adipiscing ....',
derivation: { account: 0, address: 0 }
})
Step 4
The fourth step consists of creating the token passing the wallet variable you just created alongside some other arguments:
const { hash } = await sdk.token.create({
protocol: 'SOLANA',
wallet: wallets.solana,
symbol: 'TEST',
name: 'TEST',
amount: '1000000',
fixedSupply: false,
decimals: 9
})
The wallet now holds all the new tokens and the hash
variable contain the token address, which can be inspected in an explorer such as this one or this other one.
Other Functionalities
Besides deploying a token, you can also mint or burn existing tokens.
Minting Tokens
If you’re the token’s Mint Authority, then you can mint extra tokens like this:
const { hash } = await sdk.token.mint({
wallet:,
protocol: 'SOLANA',
token: 'TOKEN_ADDRESS_FROM_PREVIOUS_STEP',
amount: 20,
destination: 'DohbPo7UFV6....wLQxEj94hmj2ohr'
})
Burning Tokens
Unlike minting, anybody can burn the tokens they own.
const { hash } = await sdk.token.burn({
wallet,
protocol: 'SOLANA',
token: 'TOKEN_ADDRESS_FROM_PREVIOUS_STEP',
amount: '5',
})
Transfer Tokens
To transfer tokens between accounts, use this function:
const { hash } = await sdk.token.transfer({
wallet,
protocol: 'SOLANA',
token: 'TOKEN_ADDRESS_FROM_PREVIOUS_STEP',
amount: '0.019',
destination: 'DohbPo7UFV6p.....xEj94hmj2ohr'
})
Note that the ‘amount’ field takes decimal units into account. For example: the token we created in this guide has two decimal units, so to transfer 20 tokens the amount variable is 20.
Last updated