Now that your helloWorld project is created, the next step is to deploy it locally. To deploy locally, dfx can start a local instance of the execution environment. This environment is not a full IC replica, nor does it download any of the state of an IC replica. It is a lightweight environment designed exclusively for deploying dapps.
First, you’ll want to use the cd command to travel to the corresponding Hello_World directory.
cd hello_world
Once there, begin running a local instance of the Internet Computer on your machine by using:
dfx start
In the root directory of Hello_World, install the necessary node modules by running:
npm install
Then you can register, build, and deploy the hello canister to the local execution environment all by running the command:
dfx deploy
This will create the two canisters needed for the frontend and backend of your application.
Once the canister is deployed to the local execution environment, we can interact with the canister by sending and receiving messages. Using a function called greet, send it a message using the command:
dfx canister call hello_world_backend greet everyone
The dfx canister call command requires you to specify a canister name and function to call.
hello_world_backend specifies the name of the canister you call.
greet specifies the function name.
everyone is the argument that you pass to the greet function.
You can also test the dapp via a browser; to do so, first open the development server by running:
npm start
In your preferred browser head to http://localhost:8080/
If your canister is live, you should be able to see and interact with a page that looks similar to this:
After confirming that your canister is live, you can end the local execution environment by running
Dfx stop
Updated