Skip to content

f-o-a-m/sample-nft-project

Repository files navigation

sample-nft-project

Build Status

A sample NFT marketplace for buying and selling FOAM Signals.

Install Requirements

Requires npm, node and stack. This project uses chanterelle for deploying contracts and generating Purescript FFI bindings.

You'll also need libpq bindings. On Ubuntu run

apt-get install -y libpq-dev

Makefile

There is a Makefile with commands for building different stages of the project and setting default environment variables. You can do

make help

to see a help menu.

Rinkeby deployment

The app is deployed here

The contracts are deployed here:

Deploying

1. Install dependencies

make install

2. Compile smart contracts and generate bindings

make compile-contracts

This generates a Contracts directory in dapp/src, as specified in chanterelle.json.

3. Start services and run migrations

Note that both table creation and migration runs from within docker, to avoid having to install psql and flyway on the host machine.

docker-compose up -d
make migrate

4. Deploy contracts to ethereum

make deploy-contracts

5. Build the backend

make build-server build-indexer

6. Build the frontend

make build-purs build-dapp frontend-build

7. Start the app

In three separate terminals, run

make run-indexer
make run-server
make frontend-start

Detailed documentation

More detailed documentation are available for the following components:

Testing

The application comes with both a unit and an end-to-end test suite.

Unit tests

To run the unit-tests, make sure that the docker services are running:

docker-compose up -d

Then run:

make test-dapp

This will create an ephemeral deployment of the smart contracts and run tests against them.

End-to-end tests

The end-to-end tests demonstrate the full lifecycle of the different components of the stack. To run them, you should have a deployment already by following steps 1-7 above (you can skip make frontend-start). Once the contracts are deployed and the indexer and the server are running, run:

make test-e2e

The tests are written in PureScript and will set up listeners from Ethereum, the server as websockets (via the indexer) and will trigger contract interactions and test the pipeline by anticipating the correct response from the services. It can also compare the data from the services with that emitted as events from Ethereum itself.

Other

How to get some ETH locally?

  • To get some ETH and FOAM add your MetaMask address to FAUCET_ADDRESS and run
FAUCET_ADDRESS={YOUR_METAMASK_ACCOUNT} make faucet-locally
  • To get more FOAM, use FAUCET_VALUE to add any value you want, e.g.
FAUCET_ADDRESS={YOUR_METAMASK_ACCOUNT} FAUCET_VALUE=224455 make faucet-locally

How to create some Signals?

  • To create some Signals add your MetaMask address to FAUCET_ADDRESS and run
OWNER_ADDRESS={YOUR_METAMASK_ACCOUNT} make signal-locally
  • To create more Signals, use SIGNAL_COUNT to set custom amount of signals you want, e.g.
SIGNAL_COUNT=4 OWNER_ADDRESS={YOUR_METAMASK_ACCOUNT} make signal-locally