Docs
Submit an issue
Smart Contracts
Smart Contracts
  • WELCOME
    • Smart Contracts
    • Installing Pop CLI
    • How to contribute
  • GUIDES
    • Get tokens on Pop (Testnet)
    • Set up your development environment
    • Create a new contract
    • Build your contract
    • Run your unit tests
    • Deploy your contract locally
      • Deploy locally on a Solochain
      • Deploy locally on Pop
    • Call your contract
    • Running E2E tests
    • Deploy on Pop
    • Securely Sign Transactions from CLI
    • Getting Started with ink! v6
  • TUTORIALS
    • Your first ink! smart contract
    • Mint a PSP22 token on Pop
  • POP CLI
    • welcome
    • install
    • new
    • build
    • call
    • up
    • test
    • clean
Powered by GitBook
On this page
  • Introduction
  • Get Started
  • Create the PSP22 token

Was this helpful?

Edit on GitHub
  1. TUTORIALS

Mint a PSP22 token on Pop

This tutorial will teach you how to mint a PSP22 token on Pop

PreviousYour first ink! smart contractNextwelcome

Last updated 2 months ago

Was this helpful?

Introduction

PSP stands for Polkadot Smart Contract Proposal. These are specifications for Polkadot smart contracts. More info can be found .

In this tutorial, we will use an ink! smart contract that implements the fungible token standard for Polkadot.

Get Started

Let's start!

pop new contract
┌   Pop CLI : Generate a contract
│
◇  Select a template type: 
│  PSP 
│
◇  Select the contract:
│  Psp22 
│
◆  Where should your project be created?
│  ./my_psp22_token 
└  
cd my_psp22_token
pop build

Create the PSP22 token

In the next command, we will deploy and create a PSP22 token with the following params:

Name: AWESOME

Symbol: AWE

Decimals: 10

Supply: 10_000_000

The following command will spin up a local blockchain, deploy the PSP22 smart contract to the blockchain, and instantiate it with the above parameters.

pop up --constructor new --args 10000000, 'Some("AWESOME")', 'Some("AWE")', 10
┌   Pop CLI : Deploy a smart contract
│
◇  Gas limit estimate: Weight { ref_time: 742850263, proof_size: 24819 }
│
◇  Contract deployed and instantiated: The Contract Address is "5EmcjhRR4MznE9quijW4vvNZXzhgYNWVE4BiT2M5jTxjcfdt"
│
└  🚀 Deployment complete

Awesome! The contract has been deployed. This means your token has been created!

Let's check by doing a few RPC calls.

Check the token name:

pop call contract --contract 5EmcjhRR4MznE9quijW4vvNZXzhgYNWVE4BiT2M5jTxjcfdt --message PSP22Metadata::token_name

The above call should return "AWESOME" as the token name.

Check the total supply:

pop call contract --contract 5EmcjhRR4MznE9quijW4vvNZXzhgYNWVE4BiT2M5jTxjcfdt --message PSP22::total_supply

The above should return a total supply of 10_000_000

Let's transfer 1_000 AWE tokens from the owner (Alice) to Bob:

pop call contract --contract 5EmcjhRR4MznE9quijW4vvNZXzhgYNWVE4BiT2M5jTxjcfdt --message PSP22::transfer --args 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty 1000 '[]' --execute

Let's confirm that Bob now has 1_000 AWE tokens:

pop call contract --contract 5EmcjhRR4MznE9quijW4vvNZXzhgYNWVE4BiT2M5jTxjcfdt --message PSP22::balance_of --args 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty

Congrats! You have successfully used a PSP22 contract to mint a token and call its transfer message.

here
PSP22