# Starting a Project

Before we begin, you should use agoric --version to double-check that you have installed the Agoric SDK.

If it is available, then you successfully installed the Agoric SDK. If not, then please do so before continuing.

After you've installed the Agoric SDK, then you're ready for your first Agoric Dapp (decentralized application) by continuing the instructions below.

We'll be running three terminal windows. See below:

  1. # Terminal 1: simulated blockchain and "solo" client
  2. # Terminal 2: contract interaction
  3. # Terminal 3: web user interface

Watch: Prepare Your Agoric Environment (November 2020)

This presentation includes starting a project, but note an outdated detail:

  • In the REPL x~.go() tildot support has been postponed; use E(x).go() instead.

# Initialize the Default Dapp Template

The following section will explain how to initialize the default dapp template, install the Agoric SDK into the dapp template, and then launch the Agoric Solo Client and Simulated Blockchain.

Use the Agoric CLI to fetch from a dapp template and put it in a directory not located in your agoric-sdk clone. We named the directory "demo", but you can name the folder whatever you like.

# Terminal 1
# Don't use your agoric-sdk as the parent of the demo directory.
cd $HOME
agoric init demo # use `agoric init $DIRNAME` with any name you like
cd demo
agoric install # will take a minute to install all dependencies
agoric start --verbose # `agoric start --reset` to start over

Learn more about the available dapp templates. Our default dapp template is the Fungible Faucet Dapp (opens new window).

Mac Dev Tools

On a Mac, you must first install Xcode (opens new window)

Leave this process and its logs running in its own terminal window.

# Open the Agoric Wallet and REPL

# Terminal 2
cd demo
agoric open --repl

This should automatically open (opens new window) in a new browser window or tab.

To begin using the wallet, click the "Connect Solo Wallet" button.

agoric wallet solo connection

After your solo wallet is connected, then you're ready to deploy the contract and API.

# Deploy the Contract and API

In our second terminal, deploy the contract to the simulated blockchain and the API to the solo client.

# Terminal 2
cd demo # if not already there
agoric deploy ./contract/deploy.js 
agoric deploy ./api/deploy.js

We'll cover deploying smart contracts in detail later.

# Start the Dapp User Interface

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

# Terminal 3
cd demo # if not already there
cd ui && yarn start

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

Once here, you will be asked to enable the dapp in your Agoric wallet.

dapp fungible faucet ui - needs approval

# Connect the Dapp to the Agoric Wallet

Navigate back to (opens new window) and accept the Dapp's request to connect to your wallet.

agoric wallet - dapp approval prompt

Navigating to the "Dapps" section of the Agoric Wallet should now show that you have successfully connected.

Agoric Wallet Dapps Section

# Use the Dapp to collect your (simulated) tokens

Once your wallet has been connected, return to http://localhost:3000 (opens new window) and click the "Mint Fungible Tokens" button.

agoric ui - accept offer in wallet

Navigate back to (opens new window) to approve the offer and collect the tokens.

agoric wallet - accept offer

Your wallet's FungibleFaucet purse will now hold 1000 FungibleFaucet tokens.

agoric wallet - accept offer

Visit the wallet UI documentation for more information.