This guide introduces modular blockchains such as Celestia, explains their benefits, and shows you how to build a full-stack modular dapp using React, Vite, RainbowKit, Celestia, Foundry, and Ethermint. For more information, please visit the modular blockchains page on Celestia's website.

This guide assumes that you are using an Ubuntu 20.04 system and the Celestia blockspacerare network.

This project will have the following features:

  1. Mint NFTs for 0.15 ETH
  2. Send NFTs to other wallets
  3. Stake/Unstake NFTs to receive a reward of 0.5 CEL tokens per minute on each NFT
  4. Claim rewards

You can find a live demo of the dapp at https://nft.suntzu.pro/.

Pre-requisites:

  1. Install Node.js

    curl <https://raw.githubusercontent.com/creationix/nvm/master/install.sh> | bash
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \\. "$NVM_DIR/bash_completion" 
    nvm install v14.20.0
    
    # Check the version to ensure successful installation of Node.js
    node -v
    
    #output : v14.20.0
    
    
  2. Install foundry

    # Install git because foundryup need it.
    apt install git
    
    # If you do not want to use the redirect, feel free to manually download the foundryup installation script from [here](<https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/install>).
    curl -L <https://foundry.paradigm.xyz> | bash
    
    # Then, run foundryup in a new terminal session or after reloading your PATH.
    source /root/.bashrc
    
    # Other ways to use foundryup, and other documentation, can be found [here](<https://github.com/foundry-rs/foundry/blob/master/foundryup>). Happy forging!
    foundryup
    

    Output like this then you’re good

    ...
    foundryup: installed - forge 0.2.0 (58645dd 2023-04-01T00:13:04.196327142Z)
    foundryup: installed - cast 0.2.0 (58645dd 2023-04-01T00:13:04.196327142Z)
    foundryup: installed - anvil 0.1.0 (58645dd 2023-04-01T00:13:37.166964655Z)
    foundryup: installed - chisel 0.1.1 (58645dd 2023-04-01T00:13:37.162127654Z)
    foundryup: done
    
  3. Install & Run Celestia Light node

    sudo apt update && sudo apt upgrade -y
    sudo apt install curl tar wget clang pkg-config libssl-dev jq build-essential git make ncdu -y
    
    # Install go
    wget <https://go.dev/dl/go1.19.1.linux-amd64.tar.gz>
    sudo rm -rf /usr/local/go &&sudo tar -C /usr/local -xzf go1.19.1.linux-amd64.tar.gz
    export PATH=$PATH:/usr/local/go/bin
    rm go1.19.1.linux-amd64.tar.gz
    
    # Clone celestia node and install , you should be check and use latest version
    git clone <https://github.com/celestiaorg/celestia-node.git> 
    cd celestia-node/ 
    git checkout tags/v0.8.1
    make build 
    make install
    
    # Check version to make sure install success
    celestia version
    
    *Semantic version: v0.8.1
    Commit: 2718b1dfb7ee4fbcc8614601dc7d58019bfb1437
    Build Date: Sat  1 Apr 07:30:59 UTC 2023
    System version: amd64/linux
    Golang version: go1.19.1*
    
    sudo echo "[Unit]
    Description=Celestia-light service
    After=network.target
    [Service]
    User=root
    #Group=root
    Type=simple
    ExecStart=celestia light start --core.ip <https://rpc-blockspacerace.suntzu.pro/> --gateway --gateway.addr localhost --gateway.port 26659 --p2p.network blockspacerace --metrics.tls=false --metrics --metrics.endpoint otel.celestia.tools:4318
    Restart=on-failure
    KillSignal=SIGTERM
    TimeoutStopSec=300
    [Install]
    WantedBy=default.target" >> /etc/systemd/system/celestia-light-node.service
    
    # Enable service
    sudo systemctl enable celestia-light-node
    
    #Init network , you will see your ADDRESS and MNEMONIC , save it. 
    **#Important : You also need to request faucet for your light node address from Celestia [discord](<https://discord.gg/celestiacommunity>).**
    
    celestia light init --p2p.network blockspacerace
    
    # Now we're ready to run light node.
    
    # To start 
    service celestia-light-node start
    
    # View logs
    
    journalctl -u celestia-light-node -f
    
    #If you can see logs like this then you're good :
    
    Mar 30 07:11:35 vultr celestia[52597]: /_____/  /_____/  /_____/  /_____/  /_____/
    Mar 30 07:11:35 vultr celestia[52597]: Started celestia DA node
    Mar 30 07:11:35 vultr celestia[52597]: node type:         light
    Mar 30 07:11:35 vultr celestia[52597]: network:         blockspacerace-0
    Mar 30 07:11:35 vultr celestia[52597]: /_____/  /_____/  /_____/  /_____/  /_____/
    Mar 30 07:11:35 vultr celestia[52597]: The p2p host is listening on:
    Mar 30 07:11:35 vultr celestia[52597]: *  /ip4/18.61.122.56/tcp/2121/p2p/12D3KooWEYqPjQBXyFBUTwseXMxNhybCMPqp9T22gMQZUDXQEbdo
    Mar 30 07:11:35 vultr celestia[52597]: *  /ip6/2401:c080:1000:1f6a:5400:4ff:fe5f:adbb/tcp/2121/p2p/12D3KooWEYqPjQBXyFBUTwseXMxNhybCMPqp9T22gMQZUDXQEbdo
    Mar 30 07:11:35 vultr celestia[52597]: *  /ip6/::1/tcp/2121/p2p/12D3KooWEYqPjQBXyFBUTwseXMxNhybCMPqp9T22gMQZUDXQEbdo
    Mar 30 07:11:35 vultr celestia[52597]: *  /ip4/18.61.122.56/udp/2121/quic-v1/p2p/12D3KooWEYqPjQBXyFBUTwseXMxNhybCMPqp9T22gMQZUDXQEbdo
    Mar 30 07:11:35 vultr celestia[52597]: *  /ip6/2401:c080:1000:1f6a:5400:4ff:fe5f:adbb/udp/2121/quic-v1/p2p/12D3KooWEYqPjQBXyFBUTwseXMxNhybCMPqp9T22gMQZUDXQEbdo
    Mar 30 07:11:35 vultr celestia[52597]: *  /ip6/::1/udp/2121/quic-v1/p2p/12D3KooWEYqPjQBXyFBUTwseXMxNhybCMPqp9T22gMQZUDXQEbdo
    
    

    Your light node rpc : http://127.0.0.1:26659 You can check more detail here

  4. Instantiating the Ethermint rollup

    With a Celestia Light Node running in one terminal session, we can proceed to generate the Ethermint rollup.

    If you are on macOS, you will need to install md5sha1sum before starting your rollup:

    brew install md5sha1sum
    
    cd ~
    git clone [<https://github.com/celestiaorg/ethermint.git>](<https://github.com/celestiaorg/ethermint.git>)
    cd ethermint
    make install
    
    #In the ethermint directory, we have a helpful bash script that allows you to instantiate a local Ethermint sovereign rollup on Celestia.
    
    bash init.sh
    

    This bash script does everything needed to initialize your Ethermint rollup. First, we need to setup some environment variables.

    The following commands are for use in Blockspace Race. If you are using another network, you must change the RPC.

    NAMESPACE_ID=$(echo $RANDOM | md5sum | head -c 16; echo;)
    DA_BLOCK_HEIGHT=$(curl <https://rpc-blockspacerace.suntzu.pro>[/block](<https://rpc-blockspacerace.pops.one/block>) | jq -r '.result.block.header.height')
    

    With this setup complete, we can now start our Ethermint Rollup:

    ethermintd start --rollkit.aggregator true --rollkit.da_layer celestia --rollkit.da_config='{"base_url":"[h](<https://light-node-blockspacerace.suntzu.pro/>)ttp://localhost:26659","timeout":60000000000,"gas_limit":6000000,"fee":60000}' --rollkit.namespace_id $NAMESPACE_ID --rollkit.da_start_height $DA_BLOCK_HEIGHT
    

    You should start seeing logs about the chain starting. They will look similar to below:

    1:27AM INF Unlocking keyring
    1:27AM INF starting ABCI with Tendermint
    1:27AM INF service start impl=EventBus module=events msg={}
    1:27AM INF service start impl=PubSub module=pubsub msg={}
    badger 2022/11/23 01:27:54 INFO: All 0 tables opened in 0s
    badger 2022/11/23 01:27:54 INFO: Discard stats nextEmptySlot: 0
    badger 2022/11/23 01:27:54 INFO: Set nextTxnTs to 0
    1:27AM INF service start impl=IndexerService module=txindex msg={}
    1:27AM INF WARNING: using default DA block time DABlockTime=30000 module=BlockManager
    ....
    1:27AM INF asserted all invariants duration=3.783918 height=0 module=x/crisis
    1:27AM INF service start impl=RPC msg={}
    1:27AM INF service start impl=Node msg={}
    1:27AM INF serving HTTP listen address={"IP":"127.0.0.1","Port":26657,"Zone":""}
    1:27AM INF starting P2P client
    1:27AM INF listening on address=/ip4/143.244.145.92/tcp/26656/p2p/12D3KooWCrCqYheUBURCzzUqgxWFVFvFYPJ6nonTPN9uVQ4cXK5H module=p2p
    1:27AM INF listening on address=/ip4/127.0.0.1/tcp/26656/p2p/12D3KooWCrCqYheUBURCzzUqgxWFVFvFYPJ6nonTPN9uVQ4cXK5H module=p2p
    1:27AM INF no seed nodes - only listening for connections module=p2p
    1:27AM INF starting Celestia Data Availability Layer Client baseURL=http://localhost:26659 module=da_client
    1:27AM INF working in aggregator mode block time=30000
    1:27AM INF Creating and publishing block height=1 module=BlockManager
    1:27AM INF minted coins from module account amount=2059726034250856481aphoton from=mint module=x/bank
    1:27AM INF submitting block to DA layer height=1 module=BlockManager
    1:28AM INF Starting JSON-RPC server address=0.0.0.0:8545
    1:28AM INF Starting JSON WebSocket server address=0.0.0.0:8546
    1:28AM INF successfully submitted rollkit block to DA layer daHeight=25422 module=BlockManager rollkitHeight=1
    1:28AM INF commit synced commit=436F6D6D697449447B5B323130203138352031373920362035322031333820373020313032203135322038302032323920313232203132342036332031382032313920313039203337203832203631203334203139302031323520393020323133203835203232382032323420323232203134203739203131305D3A317D
    1:28AM INF indexed block height=1 module=txindex
    1:28AM INF Creating and publishing block height=2 module=BlockManager
    1:28AM INF minted coins from module account amount=2059726403014551280aphoton from=mint module=x/bank
    1:28AM INF submitting block to DA layer height=2 module=BlockManager
    1:28AM INF successfully submitted rollkit block to DA layer daHeight=25423 module=BlockManager rollkitHeight=2
    1:28AM INF commit synced commit=436F6D6D697449447B5B3630203231332038372032313820383920313920323034203230322031363320383120323235203235352036352032323820313530203232392032333320323139203233322032343420313334203337203134342031303320313634203138382031393720323339203230342032303120323138203130325D3A327D
    1:28AM INF indexed block height=2 module=txindex
    1:28AM INF Creating and publishing block height=3 module=BlockManager
    1:28AM INF minted coins from module account amount=2059726771778267119aphoton from=mint module=x/bank
    

    We have kickstarted our ethermintd network!

    **Your endpoint : <http://localhost:8545>**
    

    If you see this error in your logs, it means that your Light node address has not been funded yet. Please request faucet funding in Celestia's Discord.

    **ERR** DA layer submission failed error="rpc error: code = NotFound desc = account celestia1jxxxxxxxxx not found" attempt=1 module=BlockManager
    

Now we will start deploying the contract and coding the frontend.