Skip to content

dsyengo/blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blockchain

Canister Deployment and Testing Guide

This guide outlines the steps to deploy and test a canister using the provided code with DFINITY SDK. Follow these instructions to set up and interact with your canister on the Internet Computer.

Prerequisites

  1. Install DFINITY SDK: Ensure that you have the DFINITY SDK installed. Follow the installation instructions on the DFINITY GitHub repository.

Setting Up Your Canister Project

  1. Create a Canister Project: Organize your code in a project structure. For example:

    my-canister-project/
    ├── src/
    │   ├── main.mo
    │   └── ...
    ├── dfx.json
    └── ...
    • main.mo: The entry file for your Motoko code.
  2. Define the Canister in dfx.json: Create a dfx.json file in the root of your project to define your canister. Here's a minimal example:

    {
      "canisters": {
        "my_canister": {
          "main": "src/main.mo",
          "type": "motoko"
        }
      },
      "defaults": {
        "build": {
          "packtool": "@dfinity/candid"
        }
      }
    }

    Replace "my_canister" with the desired name for your canister.

Deploying the Canister

  1. Deploy the Canister: Open a terminal in your project's root directory and run:

    dfx deploy

    This command compiles your Motoko code, creates a canister, and deploys it to the Internet Computer.

Interacting with the Canister

  1. Interact with the Canister: After deployment, obtain the canister ID. Interact with your canister using this ID. For example, if you have a function called getMessages:

    dfx canister call my_canister getMessages

    Adjust the canister name and function based on your actual implementation.

Testing

  1. Testing: Write test cases for your functions using a testing framework compatible with Motoko or JavaScript. Ensure coverage for various scenarios, including adding, updating, deleting messages, and retrieving messages.

Note: These are general instructions, and specifics may vary depending on your project structure and requirements. Follow the latest documentation and best practices from DFINITY for canister deployment and testing.

Happy coding on the Internet Computer! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published