# Getting Started
In these steps you will be getting your first Agoric dapp up and running!
# Your First Agoric Dapp - Offer Up
The Offer Up Dapp allows users to view all listed items up for sale in a marketplace. The Dapp shows 3 items by default (maps, potions, and scrolls). As a user you are able to choose up to 3 total items (in any combination). You can then create an offer for an amount of at least 0.25 IST. Once you sign the transaction, you will see the 3 items in your wallet and your wallet amount deducted by the Offer amount.
# How to Get Help
Before getting started, there are some resources you might want to keep handy in case you get stuck, have questions, or are curious about any of the components. Getting in contact with us is easy!
- Join us for our Weekly Developer Office Hours (opens new window)
- Come chat with us and other developers on the Official Agoric Discord (opens new window)
- Search and post Q & A (opens new window) in agoric-sdk discussions (opens new window)
- Send us a message on X (opens new window)
- Send an Email to Developer Relations
Video Walkthrough
As you're going through this tutorial it may be helpful to watch this video walkthrough, showing you all the steps and the desired outcome of each.
# Platform Requirements
Currently Agoric supports macOS and Linux (including Windows Subsystem for Linux (opens new window)). This tutorial is based on an installation of Ubuntu 22.04 LTS (opens new window). If you're using a different operating system, some variation may be required.
# Installing Prerequisites
In this section you'll be installing prerequisite components into your environment. If you're working with your own environment rather than using a fresh Ubuntu install, you may already have some or all of these components already installed.
# Installing NVM and Node
Installing NVM and Node on Ubuntu
At this point the Node Version Manager (NVM) utility will be installed. nvm
makes it easy to select the specific version of Node (opens new window) that will be required for this tutorial (v18.16.0).
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
or
wget -O- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Next, run the command:
source ~/.bashrc
Finally, install Node with the command:
nvm install v18.16.0
# Installing Yarn
Installing Yarn on Ubuntu
Run the corepack enable
command.
corepack enable
Now run the yarn --version
command.
yarn --version
# Installing Docker
Installing Docker on Ubuntu
Now you'll install Docker using the two steps below. This first block of commands will add the Docker GPG keys to your system, then add the repository to Apt for installation.
# Install Docker
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Now you can install Docker!
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Now that Docker has been installed you'll need to add your user account to the Docker group.
sudo usermod -aG docker $USER
Since your user account was just added to the docker group, run the following command to re-evaluate group memberships.
exec su -l $USER
Now test that Docker works by running the hello-world
sample.
docker run hello-world
The output of the hello-world
example should be:
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
# Creating Your Dapp From a Template
Now you'll use yarn to pull down the sample dapp. The sample dapp will be placed in a subfolder named demo
.
yarn create @agoric/dapp --dapp-template dapp-offer-up demo
# Install Dapp Dependencies
Now navigate to the demo
directory and run the yarn install
command to install any solution dependencies.
Downloading all the required dependencies may take several minutes. The UI depends on the React framework, and the contract depends on the Agoric framework. The packages in this project also have development dependencies for testing, code formatting, and static analysis.
cd demo
yarn install
Troubleshooting yarn install
If you run into errors during yarn install
, check that you are on a supported platform and not native Windows.
Then make sure you have the relevant developer tools installed. For example, on Debian or Ubuntu Linux, run sudo apt get install build-essential
.
On macOS, be sure to install Xcode (opens new window).
# Starting a Local Agoric Blockchain
Now go ahead and start a local Agoric blockchain using the yarn start
command. Note: This container is several gigabytes in size and may take a few minutes to download.
yarn start:docker
Once the network has started you can check the logs. Once you see messages showing blocks with a status of commit
you can rest assured the network is running properly.
yarn docker:logs
Your output should resemble this:
demo-agd-1 | 2023-12-27T04:08:06.384Z block-manager: block 1003 begin
demo-agd-1 | 2023-12-27T04:08:06.386Z block-manager: block 1003 commit
demo-agd-1 | 2023-12-27T04:08:07.396Z block-manager: block 1004 begin
demo-agd-1 | 2023-12-27T04:08:07.398Z block-manager: block 1004 commit
demo-agd-1 | 2023-12-27T04:08:08.405Z block-manager: block 1005 begin
demo-agd-1 | 2023-12-27T04:08:08.407Z block-manager: block 1005 commit
Note: logs include benign error messages
You can disregard messages such as:
v5: TypeError: target has no method "getDisplayInfo"
These are artifacts of replaying historical events.
# Starting the Dapp Smart Contract
Use control-C to exit the logs, then start the smart contract. Starting the contract may take a minute or two, so after running this command proceed to the next step.
yarn start:contract
This start:contract
script will do a number of things that we will cover in more detail later (transaction commands, permissioned deployment):
- Bundle the contract with
agoric run ...
- Collect some ATOM with
agd tx bank send ...
. - Use the ATOM to open a vault to mint enough IST to pay to install the bundles on chain with
agops vaults open ...
. - Install the bundles on chain with
agd tx swingset install-bundle ...
. - Collect enough BLD to pay for a governance deposit with
agd tx bank send ...
- Make a governance proposal to start the contract with
agd tx gov submit-proposal swingset-core-eval ...
. - Vote for the proposal; wait for it to pass.
While it's doing all that...
# Installing Keplr Wallet
Next, you'll install the Keplr wallet plug-in. Open up your browser and navigate to https://www.keplr.app/download (opens new window). Select the version appropriate to your browser.
Once the plug-in has been installed, open Keplr and select the option to "Import an existing wallet". Then choose the option to "Use recovery phrase or private key".
To import your wallet, you'll need to copy your mnemonic phrase into Keplr. You can find this series of 24 words back on your terminal window. Copy from this window into your Keplr wallet, then hit the "Import" button.
Please note that your phrase might not be the same as the one shown in this guide! Remember, this is just a demo. In real-world scenarios ensuring proper security around mnemonic phrases is critical!
- For any mnemonic phrase you use to secure your own assets, take care to keep it strictly confidential! The mnemonic here is only for testing.
- Using a separate browser profile is a good way to avoid accidentally using the wrong account when testing vs. with real assets.
Note the mnemonic phrase in the output below:
waiting for block...
1
block produced
done
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Waiting for proposal to pass (status=PROPOSAL_STATUS_VOTING_PERIOD)
Import the following mnemonic into Keplr:
survey thank matrix joke trim more make gossip spread yellow unfold under cash beach harsh fire blush achieve oak swamp pluck clock rocket leg
The resulting address should be: agoric1xe269y3fhye8nrlduf826wgn499y6wmnv32tw5
make: Leaving directory '/workspace/contract'
Done in 34.95s.
Give your new wallet a name and a password.
Click "Save".
# Starting the Dapp
Start the UI for the sample dapp.
yarn start:ui
Note the localhost link that appears on your terminal window. Open this link in your browser.
From the browser UI, click the "Connect Wallet" button to connect your Keplr wallet. You will be asked to approve this connection.
# Making an Offer
Once your wallet is connected, click on the "Make Offer" button to purchase 3 properties. Approve the transaction in your Keplr wallet.
When the transaction is complete you will notice some IST has been debited from your wallet, and you are the owner of three new properties.
Congratulations! You got your first Agoric dapp up and running!