# Agoric Dapp

This is a generic guide to Agoric Dapp projects

A dapp is a decentralized application which typically has a browser-based user interface, a public API server, and a contract running on the Agoric blockchain.

# Using a Dapp

If you have installed the Agoric CLI and you just want to try running a dapp locally (on a simulated Agoric VM, not an actual public chain), you can...

Checkout the latest beta release of the sdk:

cd agoric-sdk
git checkout beta
yarn && yarn build

Use agoric init to make a new local copy of a dapp template:

# Here we chose the Fungible Faucet Dapp.
# You can replace `my-fungible-faucet` with a name of your choice.
agoric init --dapp-template dapp-fungible-faucet --dapp-branch beta my-fungible-faucet
cd my-fungible-faucet
# Install the project dependencies
agoric install
# Start the Agoric VM
agoric start --reset

Leave this command running (it is your simulated environment). Then, in a separate terminal, deploy the contract and API to the VM.

# Deploy a new instance of the contract to the VM
agoric deploy contract/deploy.js
# Reset the VM's API server
agoric deploy api/deploy.js

Then in a third terminal:

# Start the user interface
cd ui && yarn start

You can then navigate to http://localhost:3000 (opens new window) to view your dapp.

# Modifying this Dapp

In the Agoric system, components are written in Javascript.

# Components

The following are the important directories in an Agoric Dapp project:

  • contract/ defines the on-chain smart contract.
  • api/ defines the chain-connected server's /api HTTP endpoint.
  • ui/ defines the browser user interface connecting users' personal wallets and the API server.

Other files and directories in this top-level folder should not typically be modified.

# Contract directory

In the contract directory, you can find the following files to edit:

  • src/ contract source code, starting with src/contract.js

Other files and folders that you don't typically need to edit:

  • deploy.js generic Agoric contract deployment script

# API

In the api directory, you can find the following files to edit:

  • src/ handler for /api HTTP endpoints, starting with src/handler.js

Other files and folders that you don't typically need to edit:

  • deploy.js generic Agoric API handler deployment script

# UI

The ui directory is almost completely under your control. The only files and folders that you don't typically need to edit:

  • public/lib Agoric UI library
  • public/conf configuration files that are generated by the contract/deploy.js script

# More information

You can learn more about the Agoric smart contract platform (opens new window) and how to create Agoric Dapps.