* Update Geth sync check in docker-compose.yaml * Update the guide * Geth check service name and container name updated
Codex Testnet Starter
Hit the ground running with Codex.
- Overview
- How to start
- How to get ready
- How to use
- How to stop
- How to stop and delete everything
- Troubleshooting
Overview
Using the Testnet Starter, you can run a (mostly preconfigured) Codex node on your machine. You always have the option to build and run Codex from sources Here.
Links
- Codex Website - codex.storage
- Codex Whitepaper - codex.storage
- Codex API - api.codex.storage
- Codex Discord - discord.gg/codex-storage
- Block explorer - explorer.testnet.codex.storage
- Web wallet - wallet.testnet.codex.storage
How to start
-
Clone this repo
git clone https://github.com/codex-storage/codex-testnet-starter && cd codex-testnet-starter
-
Create an Ethereum public/private key pair using web wallet or consider other local methods
Use Docker
# Generate keypair docker run --rm gochain/web3 account create
Use Python code
-
Create a venv
pip3 install virtualenv venv=codex-eth-key mkdir $venv && cd $venv python3 -m venv env source env/bin/activate
-
Install required packages
pip3 install web3
-
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)
-
Generate the keys
python3 eth-keys.py
-
Cleanup
deactivate cd .. && rm -rf $venv
# Example Private key: 0xacec4df7549199708a9f66b151aea7bf41b4d30bd325b96b26f017246226e1a3 Public address: 0x1C408C8572ce7d5E79a3a6D353e5FC2E8E2c49ce
-
-
Define variables
export PRIV_KEY=0xacec4df7549199708a9f66b151aea7bf41b4d30bd325b96b26f017246226e1a3 export CODEX_LISTEN_ADDRS=/ip4/0.0.0.0/tcp/8070 export CODEX_DISC_PORT=8090 # export CODEX_ETH_PROVIDER=https://rpc.testnet.codex.storage # export CODEX_LOG_LEVEL=TRACE # # export GETH_DISCOVERY_PORT=8547 # export GETH_PORT=8548 # export GETH_NAT=extip:1.1.1.1 # export GETH_VERBOSITY=3
-
Run local nodes
docker-compose up
-
Setup port forwarding on your router for Codex, based on defined values
TCP - CODEX_LISTEN_ADDRS=/ip4/0.0.0.0/tcp/8070 UDP - CODEX_DISC_PORT=8090
How to get ready
When starting the Testnet Starter for the first time, (or restarting after a long pause) please keep in mind:
- Your local Geth node will need time to sync.
- Geth checker will wait until Geth is in sync and only then Codex will start.
Before you can use the marketplace functionality of Codex, you will need to obtain some tokens in the testnet.
-
Join the Codex Discord server
-
Find the appropriate testnet channel.
-
Give your public key to the bot using
set
command. -
Ask it politely to mint some tokens for you using
mint
command.
(It may or may not happen in the future that testnet participation will be rewarded automatically with Discord server roles.)
How to use
Once running, Codex exposes a web-api at the API port. (default: 8080) To read more about how to use the API, go Here
How to stop
docker-compose down
How to stop and delete everything
docker-compose down --rmi all -v
Troubleshooting
Geth
# List peers
docker exec -it geth geth attach --exec net.peerCount /data/geth.ipc
# Connected peers
docker exec -it geth geth attach --exec admin.peers /data/geth.ipc
# Add a peer
docker exec -it geth geth attach --exec 'admin.addPeer("enode://cff0c44c62ecd6e00d72131f336bb4e4968f2c1c1abeca7d4be2d35f818608b6d8688b6b65a18f1d57796eaca32fd9d08f15908a88afe18c1748997235ea6fe7@159.223.243.50:40010")' /data/geth.ipc
# Sync status
docker exec -it geth geth attach --exec eth.syncing /data/geth.ipc
# Geth own enode
docker exec -it geth geth attach --exec admin.nodeInfo.enode /data/geth.ipc