Giter Site home page Giter Site logo

ic-gp7-token's Introduction

GP7 Token

This project is an education example of a simple Token (called GP7) realized on IC Blockchain and UI inspired by classic version of Curve Finance.

To deploy locally ensure you installed dfx cli, then run

dfx start --clean

then open another terminal and run

dfx deploy

After the deploy, you principal will have 1000000000 GP7 tokens assigned.

You can get your principal running

dfx identity get-principal

At this point you can start playing with the faucet.

The first thing you have to do is to transfer an amount of GP7 from your principal wallet to the faucet canister. You can do this with

dfx canister call token transfer "(principal \"$( \dfx canister id token )\", 500_000_000)"

Now if you try to click "Gimme Gimme", 10000 GP7 will be moved from the faucet canister to the anonymous user who's running in the frontend (since you are not logged in).

You can check the balance of your principal, the faucet canister, and the anoymous user.

You can also try to transfer GP7s between these wallets.

Authentication with Internet Identity

The DApp is ready to use Dfinity's Internet Identity, but to effectively use this you have to deploy the DApp on live env.

To enable the authentication, uncomment the lines in

  • index.jsx
  • Faucet.jsx

TODOs

These are some errors in the code, I just wanted to learn basis of motoko language and never thinked to deploy this on live env, so I never worried to do this perfectly

  • If you try to run your frontend with npm run start, it won't load the css. I don't know why this is happening, probably because I migrated this project from dfinity 0.9.x to 0.12.1 and I missed some configurations.
  • Transfer function is not working with authentication, since I just wanted to learn basis of motoko language and never thinked to deploy this on live env
  • You need to manually move tokens from your principal wallet to the canister, this can be automated for sure

Original README

This is repository has been created following a course on Udemy, here below you can find the original README

Check your Balance

  1. Find out your principal id:
dfx identity get-principal
  1. Save it somewhere.

e.g. My principal id is: gbdev-tyqsv-hnvqv-7mgz4-4kcfl-wbv6x-6khez-y56gq-uohqs-quomc-uqe

  1. Format and store it in a command line variable:
OWNER_PUBLIC_KEY="principal \"$( \dfx identity get-principal )\""
  1. Check that step 3 worked by printing it out:
echo $OWNER_PUBLIC_KEY
  1. Check the owner's balance:
dfx canister call token balanceOf "( $OWNER_PUBLIC_KEY )"

Charge the Canister

  1. Check canister ID:
dfx canister id token
  1. Save canister ID into a command line variable:
CANISTER_PUBLIC_KEY="principal \"$( \dfx canister id token )\""
  1. Check canister ID has been successfully saved:
echo $CANISTER_PUBLIC_KEY
  1. Transfer half a billion tokens to the canister Principal ID:
dfx canister call token transfer "($CANISTER_PUBLIC_KEY, 500_000_000)"

Deploy the Project to the Live IC Network

  1. Create and deploy canisters:
dfx deploy --network ic
  1. Check the live canister ID:
dfx canister --network ic id token
  1. Save the live canister ID to a command line variable:
LIVE_CANISTER_KEY="principal \"$( \dfx canister --network ic id token )\""
  1. Check that it worked:
echo $LIVE_CANISTER_KEY
  1. Transfer some tokens to the live canister:
dfx canister --network ic call token transfer "($LIVE_CANISTER_KEY, 50_000_000)"
  1. Get live canister front-end id:
dfx canister --network ic id token_assets
  1. Copy the id from step 6 and add .raw.ic0.app to the end to form a URL. e.g. zdv65-7qaaa-aaaai-qibdq-cai.raw.ic0.app

ic-gp7-token's People

Contributors

giu7 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.