Skip to content

Instantly share code, notes, and snippets.

@nodeasy
Created March 28, 2022 02:15
Show Gist options
  • Save nodeasy/69b19d2fc648a5d1c4015e8c389fc4f5 to your computer and use it in GitHub Desktop.
Save nodeasy/69b19d2fc648a5d1c4015e8c389fc4f5 to your computer and use it in GitHub Desktop.

About this tutorial: Deploy and launch a local Web application based on the Agoric SDK. Deploy smart contracts and some basic operations on the application. Start the local Web application based on the Agoric SDK deployment.

Note that smart contract writing and testing are not covered. Join our Discord to learn more about that.

Some parts of the deployment process were difficult to describe in words. So some images were inserted to illustrate.

Official websites

Related websites and Docs are listed below for quick looking up.

# Docs
https://agoric.com/documentation
https://agoric.com/documentation/getting-started/beta.html
https://agoric.com/documentation/getting-started/deploying.html#how-it-works

# Websites
https://agoric.com/
https://commonwealth.im/agoric
https://agoric.com/discord

Preparation

Agoric uses the Agoric Zoe framework to write JavaScript smart contracts. Therefore the Nodejs package must be installed first.

# Download and install the latest stable version of nodejs
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs build-essential gcc g++ make

# yarn
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -  && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" |tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn

Install Agoric SDK

# Download the latest agoric-sdk source code
git clone https://github.com/Agoric/agoric-sdk
cd agoric-sdk
# Install NPM dependencies
yarn install
# build
yarn build
# Install the Agoric command line file in the common directory of $PATH (note that the agoric-sdk directory cannot be deleted).
yarn link-cli /usr/local/bin/agoric
# View the current Agoric SDK version
agoric --version

Example to start DAPP

Initialization and installation

Initialize DAPP. ‘demo’ is the name of the DAPP. It can be modified to your project name.

cd ~/ && agoric init demo

Install Agoric SDK in the Dapp, and the dependencies required will be installed for demo project.

cd ~/demo && agoric install

Input multiple commands to start different programs, and they are in a continues state. Therefore multiple terminals are required.

Start the program. It creates a local web application on which the contract will then be deployed. If the listening port appears, it indicates that the operation is normal.

It is normal for the Web page to display blank when you visit it. After starting the Dapp user, the application will be initialized and the content will be displayed when you refresh the page.

agoric start

Untitled

The screen below shows without depolyment, no application is displayed at the lower left corner on the page when you access local 127.0.0.1:8000

Untitled

Deploy smart contract and API

Deploy the contract onto the simulated blockchain and API to "solo" client

The CLI shows it is starting Dapp User Interface. Just wait until they are deployed.

agoric deploy ./contract/deploy.js ./api/deploy.js

Untitled

Start the Dapp User Interface

The web user interface communicates with the API in the solo client as well as the wallet (below).

Leave this running in its own shell window and visit http://localhost:3000 (opens new window) in a web browser.

cd ui && yarn start

Untitled

After finishing the start process, there will be some extra informations shown under each command.

Untitled

Untitled

And then the webpage shows corresponding contents.

Untitled

Visit the Dapp page, and the popup will ask to start the Dapp. Go back to http://127.0.0.1:8000/ and authorize the connection. You can view all the launched Dapps on the Dapp page later.

Untitled

Untitled

Now the Dapp is working. Click the bottom MINT FUNGIBLE TOKENS and the Dashboard on http://127.0.0.1:8000/ will show the Offer. Click Approve and 1000 Tokens will be added to the Pursessection, avaliable to be transfered.

Untitled

Untitled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment