Tips & Tricks
How to create your own token on Spicy Testnet
Developping an app on Chiliz Chain Mainnet requires first to test it on Spicy Testnet, in order to check that your code handles testCHZ tokens well without having to use tons of expensive CHZ tokens. For that purpose, you can obtain Testnet tokens for free through our Spicy Faucets:
Testnet FaucetsBut sometimes development requires a lot of test tokens, and the faucets are limited in how many tokens you can get each day.
In order to free yourself from this limitation, you can create your own token on Spicy Tesnet! Indeed, Chiliz Chain (Mainnet and Tesnet) are EVM-compataible chains, and the CHZ and testCHZ tokens are really ERC20 tokens.
You can therefore mint your own, quasi-unlimited ERC20 token on Spicy Tesnet, and test your code thoroughly with that token. Then, once you feel you're ready, test your dApp with test CHZ tokens on Spicy a few more times before going live on Chiliz Chain Mainnet.
Here are the steps to create your own token on Spicy Testnet:
Get test CHZ tokens from the Spicy Faucet. This is needed because you will need CHZ tokens to deploy your ERC20 contract.
Write the token's smart contract (we recommend relying on OpenZeppelin's ERC20). In your
constructor, set the token's name (e.g., "MyOwnToken"), symbol (e.g., "MOT"), and mint an initial supply that's enough for your needs.Compile the contract and deploy it to Spicy Testnet, then verify it through a block explorer.
View your new token in MetaMask:
Copy your token's contract address from your deployment toolset (e.g., Remix's "Deployed Contracts" menu).
In MetaMask, go to the "Tokens" tab and click "Import tokens".
Paste the contract address. The symbol and decimals should auto-fill.
Click "Add custom token" and then "Import tokens". You should now see your new token balance.
You're now ready to test your Chiliz Chain dApp on Spicy Testnet with your own token!
How to get the current gas price
To get the gas price on Chiliz Chain, you can use one of the public RPC nodes.
You can request the gas price like so:
curl --location 'https://rpc.ankr.com/chiliz' # For Spicy: https://spicy-rpc.chiliz.com/
--header 'Content-Type: application/json'
--data '{
"method": "eth_gasPrice",
"params": [],
"id": 1,
"jsonrpc": "2.0"
}'How to check why a transaction failed
A transaction might fail, and you don't always know why, especially since the block explorer doesn't display the error.
To ensure that your transaction doesn't remain in "pending" status for too long, you should include enough to cover the fees:
Minimum gas fee: 2,501 gwei.
Minimum priority fee: 1 gwei.
To check why your transaction failed, run the following script in the terminal with the correct transaction ID:
curl --location 'https://rpc.ankr.com/chiliz' # For Spicy: https://spicy-rpc.chiliz.com/
--header 'Content-Type: application/json'
--data '{
"method": "debug_traceTransaction",
"params": [
"[Transaction ID]",
{
"tracer": "callTracer"
}
],
"id": 1,
"jsonrpc": "2.0"
}'Last updated
Was this helpful?