# Starting a Project

After you've installed the Agoric SDK (recall: use agoric --version to confirm.), you're ready for your first Agoric Dapp (decentralized application).

Beta Dapp Architecture

The Dapp architecture presented here is a beta preview of our eventual permissionless contract deployment model, extending our Distributed Computing Framework to a stateful peer on end-user machines.

The Mainnet-1 launch (opens new window) uses a "smart wallet" architecture with a lower client-side footprint.

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, and install the Agoric SDK into the Dapp template.

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 --dapp-template dapp-card-store demo # use `agoric init --dapp-template dapp-card-store $DIRNAME` with any name you like
cd demo
agoric install community-dev # will take a minute to install all dependencies

Learn more about the available Dapp templates.

# Start Agoric Solo Client and Simulated Blockchain

# Terminal 1
agoric start --verbose --reset # `agoric start --reset` to start over

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 http://127.0.0.1:8000 (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.

# Connect the Dapp to the Agoric Wallet

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

Dapp card store ui - needs approval

  1. Navigate back to http://127.0.0.1:8000 (opens new window) and accept the Dapp's request to connect to your wallet.

agoric wallet - Dapp approval prompt

  1. Navigate back to the Dapp (opens new window) and it should load the baseball cards to bid on

Dapp card store ui - loading cards

# Use the Dapp to bid on and buy a baseball card

  1. In the Dapp, you should be able to click on a baseball card to BID on it in an action. Enter Bid ammount to submit an offer to buy the card.

    Bid on Card

  2. In the wallet, Approve the Proposed offer to bid on a card.

    Proposed Offer

  3. In the wallet, the offer will be in a Pending state while the auction for the card to complete. The auction takes up to 300 seconds.

    Pending Offer

  4. In the wallet, your offer will transition to an Accepted state when the auction ends. Your cardStore.Card purse will now contain a card.

    Accepted Offer

Visit the wallet UI documentation for more information.