Skip to content

Instantly share code, notes, and snippets.

@Validatrium
Last active April 26, 2022 16:28
Show Gist options
  • Save Validatrium/ace4abfd3e5dadf35a9f622f779baa7c to your computer and use it in GitHub Desktop.
Save Validatrium/ace4abfd3e5dadf35a9f622f779baa7c to your computer and use it in GitHub Desktop.

Request Approve

Currently it's closed testnet. if you want to join, request approve. After your node is configured send your scanner id

Links

Check your MATIC balance: https://polygonscan.com/address/your-address

Prerequires

  • 64-bit Linux distribution
  • CPU with 4+ cores
  • 16GB RAM
  • Docker v20.10+
  • Recommended: Full node (any chain)

Install

# install docker
curl -sL get.docker.com | sudo bash

# configure docker:
echo "
{
   "default-address-pools": [
        {
            "base":"172.17.0.0/12",
            "size":16
        },
        {
            "base":"192.168.0.0/16",
            "size":20
        },
        {
            "base":"10.99.0.0/16",
            "size":24
        }
    ]
}
" > /etc/docker/daemon.json
systemctl restart docker

# install forta
curl https://dist.forta.network/pgp.public -o /usr/share/keyrings/forta-keyring.asc -s
echo 'deb [signed-by=/usr/share/keyrings/forta-keyring.asc] https://dist.forta.network/repositories/apt stable main' | sudo tee -a /etc/apt/sources.list.d/forta.list
apt update && apt install forta


# create user 
useradd forta  -mU -G sudo,docker -s /usr/bin/bash
# set password for user
passwd forta 

su - forta

Init

Select which network will scan your node. There is no options to run 1 node for scaning multiple networks. If you want to scan multiple networks you will need to create and register different nodes for selected networks. ; There are few examples choose one of them.

init forta home directory

# replace <your-password> with your value
forta init --passphrase <your-password>

select network forta will scan

BSC

echo "
chainId: 56
scan:
  jsonRpc:
    url: https://bsc-dataseed.binance.org/
trace:
  enabled: false
" > $HOME/.forta/config.yml

Polygon

echo "
chainId: 137
scan:
  jsonRpc:
    url: https://polygon-rpc.com/

trace:
  enabled: false
" > $HOME/.forta/config.yml

Avalanche

echo "
chainId: 43114
scan:
  jsonRpc:
    url: https://api.avax.network/ext/bc/C/rpc
trace:
  enabled: false
" > $HOME/.forta/config.yml

Arbitrum

echo "
chainId: 42161
scan:
  jsonRpc:
    url: https://arb1.arbitrum.io/rpc
trace:
  enabled: false
" > $HOME/.forta/config.yml

Optimism

echo "
chainId: 10
scan:
  jsonRpc:
    url: https://mainnet.optimism.io
trace:
  enabled: false
" > $HOME/.forta/config.yml

Ethereum Mainnet

If you want to use alchemy, it's requires Alchemy Growth plan

echo "
chainId: 1 
scan:
  jsonRpc: 
    url: https://eth-mainnet.alchemyapi.io/v2/KEY
trace:
  jsonRpc: 
    url: https://eth-mainnet.alchemyapi.io/v2/KEY
" > $HOME/.forta/config.yml

You can get scanner address just by running forta account address command

Register your scanner

  1. You need metamask wallet. After registration the node will be minted as NFT to this wallet
  2. Charge your scanner address (forta account address) on few Polygon (Mainnet) MATIC. I used 0.5 MATIC (~1$) it's enough, maybe you can use even less. Need to confirm registration transaction
  3. Register you scanner:
    forta register --owner-address <your-metamask-wallet-id> --passphrase <your-password>
    

Save your passphrase and keyfile ($HOME/.forta/.keys/....json) in a safe place

Run node

  1. Manual run forta run --passphrase <your-password>
  2. Systemd
# override variables
sudo mkdir /etc/systemd/system/forta.service.d
sudo tee /etc/systemd/system/forta.service.d/env.conf > /dev/null <<EOF 
[Service]
User=forta
Environment="FORTA_DIR=/home/forta/.forta"
Environment="FORTA_PASSPHRASE=<your-password>"
EOF
# start service
systemctl daemon-reload
systemctl enable forta
sysetmctl start forta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment