Running the Wallet Daemon

Along with running the Platform natively on your own cloud service, you can also build and run the wallet daemon natively too. This requires just a few steps to configure and build the app which can then be run from the same server as the platform or on a completely different server. It would be highly recommended to run the wallet daemon app on a separate server, and ideally one which is is configured to only allow connections to and from your platform server, or at least not generally accessible directly from the internet. Please note that 2GB of ram would be recommended when building the wallet daemon from source locally.

  1. Start by installing or updating cargo:

    apt install cargo
    
  2. Install or update the openssl dev libs:

    apt-get install libssl-dev pkg-config
    
  3. Next add the KEY_PASS and PLATFORM_KEY env vars to your environment variable list so they start on login, to do this create a new wallet-daemon.sh file in /etc/profile.d/:

    nano /etc/profile.d/wallet-daemon.sh
    

    And then add the variables, choose a strong password for your KEY_PASS and set your platform's auth token in the PLATFORM_KEY, save the file with ctrl-x followed by y:

    export KEY_PASS="MySuperSecurePassword01"
    export PLATFORM_KEY="Your_Platform_Token_Here"
    
  4. Once saved you'll need to log off from your server and log back in so they get loaded.

  5. Next, create a new folder to hold the Wallet Daemon repo and build:

    cd ~/enjin/
    mkdir wallet-daemon
    
  6. Pull the wallet-daemon repo from GitHub:

    cd ~/enjin/wallet-daemon/
    git clone https://github.com/enjin/wallet-daemon.git .
    
  7. Edit the config.json file in nano to set which blockchain node and platform to connect to and also set where it can find the wallet private key, typically ./store, then save with ctrl-x y:

    nano config.json
    
    {
      "node": "wss://rpc.matrix.canary.enjin.io:443",
      "api": "https://your-platform-url.com/graphql",
      "master_key": "./store"
    }
    
    

    📘

    Using Platform on mainnet?

    If you are using the Enjin Platform on mainnet, make sure to use a mainnet RPC (such as wss://rpc.matrix.blockchain.enjin.io)

  8. Build the Wallet Daemon app:

    cargo build --release
    
  9. Remove the demo Wallet key:

    rm store/73723235547f46358c6a32dd1ffb28ee537313a674dc3dc882beb3246e03aa4dc246022f
    
  10. Attach to your tmux workers session and create a new pane for the wallet daemon, use ctrl-b " to create a new pane and ctrl-b up-arrow or down-arrow to navigate to it if not already selected:

    tmux a -t workers
    
  11. Navigate to the wallet-daemon folder in your new pane and then run the wallet build:

    cd ~/enjin/wallet-daemon
    ./target/release/wallet
    
  12. Note down the account addresses that will be displayed, these are for your new Wallet Daemon account and will be used to sign transactions.

From here on you simply need to update the DAEMON_ACCOUNT variable in your .ENV with the new wallet account address and fund the account. The wallet daemon will then poll for transactions every 6 seconds and process anything new that you create.

Updating the Wallet Daemon

If you're using Supervisor to keep the wallet running (Keeping the Platform Running) , stop it using:

sudo supervisorctl stop platform-wallet:*

Login as your platform user (or from root use su - platform and change to the wallet daemon directory:

cd ~/enjin/wallet-daemon/

Pull the latest version from git and build:

git pull
cargo build --release

To test, you can run directly (omit if using supervisor):

./target/release/wallet

Start the wallet using supervisor:

sudo supervisorctl start platform-wallet:*