Skip to content

Latest commit

 

History

History
145 lines (102 loc) · 3.93 KB

README.md

File metadata and controls

145 lines (102 loc) · 3.93 KB

dtoken

Custom token creation.

On-chain UI: None yet.

Running the project locally

To test the project locally, use the following commands:

# Set rust backtrace to get more useful debug info when things go wrong
export RUST_BACKTRACE=full

# Starts the replica, running in the background
dfx start --clean --background

# Deploys the canisters to the replica and generates the candid interface
dfx deploy

Once the job completes, the application will be available at http://localhost:4943?canisterId={asset_canister_id}.

Additionally, if you are making frontend changes, you can start a development server with

npm start

Which will start a server at http://localhost:8080, proxying API requests to the replica at port 4943.

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

Should give somethine like: jxic7-kzwkr-4kcyk-2yql7-uqsrg-lvrzb-k7avx-e4nbh-nfmli-rddvs-mqe

  1. Check the owner's balance:
dfx canister call dtoken_backend balanceOf "( $OWNER_PUBLIC_KEY )"

Charge the Canister

  1. Check canister ID:
dfx canister id dtoken_backend
  1. Save canister ID into a command line variable:
CANISTER_PUBLIC_KEY="principal \"$( \dfx canister id dtoken_backend )\""
  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 dtoken_backend 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 dtoken_backend
  1. Save the live canister ID to a command line variable:
LIVE_CANISTER_KEY="principal \"$( \dfx canister --network ic id dtoken_backend )\""
  1. Check that it worked:
echo $LIVE_CANISTER_KEY
  1. Transfer some tokens to the live canister:
dfx canister --network ic call dtoken_backend transfer "($LIVE_CANISTER_KEY, 50_000_000)"
  1. Get live canister front-end id:
dfx canister --network ic id dtoken_frontend
  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

Note on frontend environment variables

If you are hosting frontend code somewhere without using DFX, you may need to make one of the following adjustments to ensure your project does not fetch the root key in production:

  • setNODE_ENV to production if you are using Webpack
  • use your own preferred method to replace process.env.NODE_ENV in the autogenerated declarations
  • Write your own createActor constructor

Useful commands

  • Check on-chain balance: dfx wallet --network=ic balance
  • Get principal ID: dfx identity get-principal
    • Format and store it in CLI: OWNER_PUBLIC_KEY="principal \"$( \dfx identity get-principal )\""
    • Check it worked: echo $OWNER_PUBLIC_KEY
    • Check owner balance: dfx canister call dtoken_backend balanceOf "( $OWNER_PUBLIC_KEY )"
  • Get ledger ID: dfx ledger account-id
  • Get on-chain wallet ID: dfx identity --network=ic get-wallet

Resources