Skip to content

pinax-network/eos-evm-miner

Repository files navigation

EOS EVM Miner

GitHub release (latest by date) Build Status

Accepts Ethereum transactions and relays them to EOS EVM network.

References

$ wget https://github.com/pinax-network/eos-evm-miner/releases/download/v0.5.0/eos-evm-miner
$ chmod +x ./eos-evm-miner
  • Ubuntu
  • MacOS
  • Windows

Build from source

Install Bun

curl -fsSL https://bun.sh/install | bash

Generate a standalone Bun executable

$ git clone https://github.com/pinax-network/eos-evm-miner.git
$ cd eos-evm-miner
$ bun build --compile ./bin/cli.ts --outfile eos-evm-miner

Quickstart

$ eos-evm-miner start --verbose


        ███████╗ ██████╗ ███████╗    ███████╗██╗   ██╗███╗   ███╗
        ██╔════╝██╔═══██╗██╔════╝    ██╔════╝██║   ██║████╗ ████║
        █████╗  ██║   ██║███████╗    █████╗  ██║   ██║██╔████╔██║
        ██╔══╝  ██║   ██║╚════██║    ██╔══╝  ╚██╗ ██╔╝██║╚██╔╝██║
        ███████╗╚██████╔╝███████║    ███████╗ ╚████╔╝ ██║ ╚═╝ ██║
        ╚══════╝ ╚═════╝ ╚══════╝    ╚══════╝  ╚═══╝  ╚═╝     ╚═╝
                EOS EVM Miner listening @ 127.0.0.1:50305
              Prometheus metrics listening @ 127.0.0.1:9102
                   Your miner account is miner.enf
        PUB_K1_8bxdSx2gET6suSZxz6dWoxux2ysNG3ADJu3n5nWvMEQ6vvRXtS

Help

$ eos-evm-miner start --help

Usage: @enf/eos-evm-miner start [options]

Start JSON RPC Server

Options:
  --private-key <string>       Miner private key (ex: "PVT_K1_...")
  --account <string>           Miner account name (ex: "miner.evm")
  --permission <string>        Miner permission (default: "active")
  -p --port <int>              JSON RPC listens on port number, listen for
                               incoming Ethereum transactions. (default:
                               "50305")
  --hostname <string>          JSON RPC listens on hostname, listen for
                               incoming Ethereum transactions (ex: "127.0.0.1)"
  --metrics-listen-port <int>  The process will listen on this port for
                               Prometheus metrics requests (default: "9102")
  --metrics-disabled           If set, will not send metrics to Prometheus
  --verbose                    Enable verbose logging
  --lock-gas-price             Lock gas price as hex value (ex: "0x22ecb25c00")
  -h, --help                   display help for command

Docker environment

docker build -t eos-evm-miner .
docker run -it --rm -p 50305:50305 --env-file .env eos-evm-miner start

Deploy to Cloud Run

https://console.cloud.google.com/run

gcloud run deploy

Environment Variables

.env

# miner (required)
PRIVATE_KEY=PVT_K1_...
MINER_ACCOUNT=miner.enf

# miner (optional)
MINER_PERMISSION=active

# RPC EOS (optional)
RPC_ENDPOINT=https://eos.api.eosnation.io
CHAIN_ID=aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906

# RPC EVM (optional)
RPC_EVM_ENDPOINT=https://api.evm.eosnetwork.com

# JSON RPC (optional)
PORT=50305
HOSTNAME=127.0.0.1
LOCK_GAS_PRICE=0x22ecb25c00
LOCK_CHAIN_ID=0x4571
LOCK_GENESIS_TIME="2023-04-05T02:18:09"

# Prometheus Metrics
PROMETHEUS_PORT=9102
METRICS_DISABLED=false

# CLI (optional)
VERBOSE=true

Testing

$ bun test
bun test v0.6.7 (59d7c47e)
[0.28ms] ".env"

src/eth_sendRawTransaction.spec.ts:
✓ eth_sendRawTransaction [1.45ms]

src/eth_gasPrice.spec.ts:
✓ eth_gasPrice [226.88ms]

Features

  • JSON RPC methods (Request to EOS RPC)

    • eth_gasPrice - Returns the current gas price on the network in wei.
    • eth_sendRawTransaction - Creates new message call transaction or a contract creation for signed transactions.
    • eth_chainId - Returns the current network/chain ID, used to sign replay-protected transaction introduced in EIP-155.
    • eth_blockNumber - Returns the latest block number of the blockchain.
    • eth_getBalance - Returns the balance of given account address in wei.
    • net_version - Returns the current network id.
    • eth_getCode - Returns the compiled bytecode of a smart contract.
  • JSON RPC methods (Proxy to EVM RPC)

    • eth_estimateGas - Returns an estimation of gas for a given transaction.
    • eth_getTransactionCount - Returns the number of transactions sent from an address.
    • eth_getTransactionReceipt - Returns the receipt of a transaction by transaction hash.
    • eth_getBlockByHash - Returns information of the block matching the given block hash.
    • eth_getBlockByNumber - Returns information of the block matching the given block number.
    • eth_call - Executes a new message call immediately without creating a transaction on the block chain.
    • ... and all other supported EVM method calls
  • CLI commands

    • start - start miner JSON RPC server
    • claim - claim miner rewards
    • open - open miner balance
    • powerup - powerup miner CPU & NET
  • Bun binary builds

  • Docker Container

    • Alpine Docker image
    • "Distroless" Docker image
  • Prometheus metrics

    • total eth_gasPrice requests & success
    • total eth_sendRawTransaction requests & success