Skip to content

mlabs-haskell/seabug

Repository files navigation

Seabug

Prerequisites

Usage

Clone repo

git clone --recurse-submodules [email protected]:mlabs-haskell/seabug.git
cd seabug

Enter nix shell

nix develop --extra-experimental-features nix-command --extra-experimental-features flakes

From now, execute every command in the devshell created by the above command.

Note: if you run into a permission error when executing the above command, you may need to run sudo chmod 777 -R /nix, then run the above command again. Be aware that more restrictive file permissions may be safer.

Setup nft.storage key

Replace NFT_STORAGE_KEY_HERE in arion-compose.nix with your key. You can obtain free API key from nft.storage.

Optional: Copy testnet node database

If you have node db you can copy it to data/cardano-node/cardano-node-data to save hours on initial sync.

mkdir -p data/cardano-node/cardano-node-data
cp -r /path/to/old/db data/cardano-node/cardano-node-data/.

Start services

./buildFrontend.sh
arion up

Please note that arion up will require a full cardano node to sync, which can take some time. At time of writing (April, 2022), the current tip is at slot 56000000 and counting.

Once the chain is synced, you should be able to view the dApp UI from localhost:8080

Ensure that Nami is set to Preview, that you have some Test Ada (see the faucet), and that you've set collateral in Nami.

Optional: Mint your own NFTs

See the minting section in seabug-contracts/README.md. The following section describes how to upload an image and get its IPFS CID.

Upload NFT image

If you have an image:

cd seabug
scripts/upload-image.sh
Arguments: <IMAGE_FILE> <TITLE> <DESCRIPTION>
scripts/upload-image.sh 'image.jpeg' 'Title' 'Description'

This will add the image to IPFS and the postgres database, and should print out something like:

IMAGE: image.jpeg
TITLE: Title
DESC: Description
> IMAGE_HASH: 4cefddfb4f62a3c68d08863cc299a2d6411174c8ff3325d21239ad3b5dcbf21c
> IPFS_HASH: bafkreicm57o7wt3cupdi2ceghtbjtiwwieixjsh7gms5eerzvu5v3s7sdq
> IPFS Base36 CID: k2cwueakfq42m0c5y33czg6ces3tj9b1xlv59krz88y2r8m18e2zxee4

The IPFS Base36 CID value can be used to continue the minting process.

Maintenance

Updating dependencies

  • CTL: see the docs
  • Submodules: assuming submodules have been setup locally (see docs), just change to the new commit in the submodule, then stage and commit in the main seabug repo.
  • Purescript/JavaScript dependencies: these are managed in the submodules through the standard package management systems for the languages. For submodules using CTL (seabug-contracts), just be sure to follow the CTL docs to avoid conflicts in dependencies
  • Haskell dependencies: managed in nix flakes
  • Runtime dependencies: also managed by flakes and Arion

Targeting different networks

See this PR as an example of switching to the preview network. The general steps are:

  • Update the network in arion-compose.nix
  • Make a blockfrost project pointing to the correct network, and update the blockfrost project ids throughout the project
  • Update the network ids throughout the project
  • Update the blockfrost api url in seabug-contracts

Adding new off-chain contracts

See the CTL docs. Off-chain contracts are stored in the seabug-contracts submodule.

Known errors

WebSocket connection to ws://localho.st:9999/ws failed: WebSocket is closed before the connection is established Error: [object Object] at push.../seabug-contracts/output.js.exports.error

Try waiting a bit and reloading the page. Likely just ODC needing some time to start up.

Components

nft-marketplace

Frontend for Seabug marketplace, interacts with Cardano blockchain using cardano-transaction-lib.

seabug-contract

NFT marketplace contracts in purescript. Onchain part was hardcoded as binary.

ogmios-datum-cache

Caches datums of NFTs that are on available marketplace.

ogmios

A lightweight interface for cardano-node. Used for cardano-transaction-lib and ogmios-datum-cache to interact with blockchain.

postgresql

Database used to store images data (in addition to IPFS), artists data and datums stored by ogmios-datum-cache.

nft-marketplace-server

Backend server used for storing storing image and artists data and uploading artworks to IPFS node.

cardano-transaction-lib-server

A small server used to provide services to the cardano-transaction-lib frontend that cannot be achieved using Purescript.

cardano-node

Relay node of Cardano blockchain.

Onchain SmartContracts

About

Combined components for Seabug deployment

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 6