Agoric: Create a DeFi dApp Using Agoric That’s Stored on Filebase

Learn how to create a DeFi dApp using Agoric that is stored on Filebase.

What is Agoric?

Agoric is a proof of stake blockchain that utilizes JavaScript smart contracts that enable developers to create and deploy DeFI dApps rapidly. Agoric offers a variety of dApp templates, including a DeFi Faucet dApp and an NFT Trading Card marketplace application.

Read below to learn how to create a dApp using Agoric that is stored on Filebase.

Prerequisites:

1. First, we need a Filebase IPFS bucket.

To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.

2. Select ‘Buckets’ from the left sidebar menu, or navigate to console.filebase.com/buckets.

Select ‘Create Bucket’ in the top right corner to create a new bucket.

3. Enter a bucket name and choose the IPFS storage network to create the bucket.

Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.

4. Next, download and install S3FS-FUSE on a Linux or macOS system.

5. Set up an Access Key file for use with S3FS-FUSE.

Set up a credentials file for S3FS at ${HOME}/.passwd-s3fs. You will need to save your Filebase Access and Secret keys to this file and give it owner permissions. You can do so with the following commands:

echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ${HOME}/.passwd-s3fs

chmod 600 ${HOME}/.passwd-s3fs

ACCESS_KEY_ID is your Filebase Access key, and SECRET_ACCESS_KEY is your Filebase Secret key. For more information on Filebase access keys, see here.

6. Mount your bucket.

You can mount a Filebase IPFS bucket with the command:

s3fs mybucket /path/to/mountpoint -o passwd_file=${HOME}/.passwd-s3fs -o url=https://s3.filebase.com

  • mybucket: name of your Filebase bucket

  • /path/to/mountpoint

7. Now, navigate into the mounted Filebase bucket.

cd /path/to/mountpoint/

8. Download and install the Agoric SDK:

git clone https://github.com/Agoric/agoric-sdk

cd agoric-sdk

yarn install

yarn build

yarn link-cli ~/bin/agoric

9. Confirm Agoric has been installed:

agoric --version

10. Open 3 terminal windows. In the first terminal window, run the following command to initialize an Agoric dApp using the dApp demo template:

agoric init demo

This installs the demo Agoric dApp template, which is a Fungible Faucet dApp. This dApp allows users to send tokens to different crypto wallets.

11. Install the Agoric SDK in the project’s directory:

cd demo

agoric install

12. In your second terminal window, run the following command:

agoric start

13. Back in the first terminal window, run the following command to deploy the smart contracts for the dApp:

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

14. Then, in the first terminal window, run the following command to open an Agoric wallet:

agoric open --repl

Your wallet will open in a browser tab at 127.0.0.1:8001.

15. In the third terminal window, run the following command to navigate into the ui directory and start the dApp User Interface:

cd ui && yarn start

The dApp will be available at http://localhost:3000/.

From here, you can expand and develop a dApp that utilizes this demo template, which features wallet connection, and token sending or receiving functionality.

If you have any questions, please join our Discord server, or send us an email at hello@filebase.com

Last updated