codex-storage / ethcc-demo

Demo app showing contract events from the codex testnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ethcc-demo

This demo app shows past and real-time Codex storage request events on the Codex testnet.

Running the demo

First, clone this repo

git clone https://github.com/codex-storage/ethcc-demo && cd ethcc-demo

Then, create a private key to run codex

Create an Ethereum public/private key pair using a web wallet or consider other local methods:

Use Docker
# Generate keypair
docker run --rm gochain/web3 account create
Use MetaMask
  1. Accounts and Addresses
  2. How to export an account's private key
Use Python code
  1. Create a venv

    pip3 install virtualenv
    
    venv=codex-eth-key
    mkdir $venv && cd $venv
    
    python3 -m venv env
    source env/bin/activate
  2. Install required packages

    pip3 install web3
  3. Create a script

    vi eth-keys.py
    from eth_account import Account
    
    def generate_ethereum_keypair():
        # Generate a new Ethereum account
        account = Account.create()
    
        # Get the private key
        private_key = account._private_key.hex()
    
        # Get the public key (Ethereum address)
        public_key = account.address
    
        return private_key, public_key
    
    # Generate the Ethereum key pair
    private_key, public_key = generate_ethereum_keypair()
    
    # Print the keys
    print("Private Key:", private_key)
    print("Public Key (Ethereum Address):", public_key)
  4. Generate the keys

    python3 eth-keys.py
  5. Cleanup

    deactivate
    cd .. && rm -rf $venv
# Example
Private key: 0xacec4df7549199708a9f66b151aea7bf41b4d30bd325b96b26f017246226e1a3
Public address: 0x1C408C8572ce7d5E79a3a6D353e5FC2E8E2c49ce

Mint testnet tokens

Before you can use the marketplace functionality of Codex, you will need to obtain some tokens in the testnet.

  1. Join the Codex Discord server
  2. Go to the #bot channel.
  3. Give your public key to the bot using set command. Bot-Set
  4. Ask it politely to mint some tokens for you using mint command. Bot-Mint

Copy private key to the setup directory

Before we run a codex instance, we need to ensure our private key is saved on disk for the Codex instance to use. Copy your private key to path/to/demo/codex-setup/eth.key:

# copy your private key to eth.key
echo 0xacec4df7549199708a9f66b151aea7bf41b4d30bd325b96b26f017246226e1a3 >> ./codex-setup/eth.key
chmod 0600 ./codex-setup/eth.key

Build codex and setup your environment

We need to build a Codex instance from source before running it. In a separate terminal, run:

cd .. && git clone https://github.com/codex-storage/nim-codex && cd nim-codex
export CODEX_PATH=$(pwd)
make -j12 update && make -j12

Note: the parameter -j12 specifies the number of logical cores your CPU has, change to match your CPU. If unknown, use -j2.

Run codex

In a new terminal, run codex:

chmod +x codex.sh
./codex.sh

Finally, run the demo app

Back in the original terminal, run the demo app:

yarn
yarn dev

Recommended IDE Setup

VSCode + Volar (and disable Vetur).

Customize configuration

See Vite Configuration Reference.

Project Setup

yarn

Compile and Hot-Reload for Development

yarn dev

Compile and Minify for Production

yarn build

Lint with ESLint

yarn lint

Known issues

  1. #1 When running with two tabs open, for example when running Moderation in one tab and the homepage in another tab, deleting events from the notification centre individually does not sync properly across tabs. The deleted event in one tab will not be deleted in the other tab. Clearing all events does still work, however.

About

Demo app showing contract events from the codex testnet


Languages

Language:Vue 52.7%Language:JavaScript 43.9%Language:Shell 1.6%Language:CSS 1.6%Language:HTML 0.2%