Giter Site home page Giter Site logo

seahorse_create_token's Introduction

create_token

This project was created by Seahorse 0.2.7.

To get started, just add your code to programs_py/create_token.py and run seahorse build.

Prerequisites

We need to install some command line tools for this project to build. We need Solana, Anchor, NodeJS and Seahorse. The links provided contain the step-by-step guide on installing these tools and the dependencies required for them like Rust.

You can check if package got installed correctly by running command like :

solana -V anchor -V seahorse -V

For this project, the version used are :

  • anchor 0.28.0

  • seahorse v0.2.7

  • node 18.17.0

Getting started with Seahorse

We initialize Seahorse Project using command seahorse init token_program. This will create a project directory with multiple files which is mostly similar to anchor projects, just will write our seahorse program in token_program/programs_py/token_program.py

Involved Accounts

Under the hood, the Toke Program in Solana Program Library (SPL) is used. It contains instructions for creating and interacting with SPL-Tokens. These tokens represent all non-native (i.e. not SOL) tokens on the Solana network.

The 3 parties involved in this token programms are :

  • The Token Program contains instructions for creating and interacting with SPL-Tokens
  • Token Mints are accounts which hold data about a specific Token, but do not hold Tokens
  • Token Accounts are used to hold Tokens of a specific Token Mint

Alt text

Program Instructions

We have 3 functions/instructions in this Program. Let's understand all the different Program instructions one by one.

1. initTokenMint

When someone wants to create a new token, we have to use something create-token function to initialize a new Mint Account. initTokenMint is the function where we create our TokenMint Accounts. TokenMint account contains the following informations:

  • mint-authority which is a public-key (pubkey) authorized to mint this token
  • the number of decimals of the token etc. This account stores general information about the token and who has permissions over it.

Alt text

2. initTokenAccount

A Token Account holds tokens of a specific "mint" and has a specified "owner" of the account. The token account itself is owned by the Token program and it is the Token program who controls access to these tokens using the owner, and delegate fields within the account. The owner is the pubkey who can spend/transfer the tokens, and the owner can give rights to a delegate pubkey to spend up to a delegatedAmount of tokens.

The TokenAccount has number of fields like:

  • mint - this is the mint whose tokens this this account will hold
  • authority - the account that has authority over this account

We have created below 2 TokenAccounts containing 0 token now.

Alt text

3. useTokenMint

Minting tokens is the process of issuing new tokens into circulation. When you mint tokens, you increase the supply of the token mint and deposit the newly minted tokens into a token account. Only the mint authority of a token mint is allowed to mint new tokens.

The user's token balance has been updated to 3000 now.

Alt text

seahorse_create_token's People

Contributors

akshaydhayal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.