Skip to main content

Gateway & Application (~30 min)

🖨 🍝 with Scripted Abstractions 🍝 🖨

Stake an onchain Application, delegate to an onchain Gateway, and run an offchain PATH Gateway in less than an hour, without deep explanations.

Table of Contents

High Level Architecture Diagram

30 Minute Video Walkthrough

Coming soon...

Prerequisites

Optional Vultr Setup

The instructions on this page assume you have experience maintaining backend services.

You can reference the Vultr Playbook for a quick guide on how to set up a server with Vultr.

What will you do in this cheatsheet?

  1. Stake an Application (i.e. onchain record)
  2. Stake a Gateway (i.e. onchain record)
  3. Deploy a PATH Gateway (i.e. offchain coprocessor)
  4. Send relays
  5. Pay for onchain services

Account Setup

1. Create Application account

pocketd keys add application

2. Create Gateway account

pocketd keys add gateway

3. Prepare your environment

Create the following environment variables:

cat > ~/.pocketrc << EOF
export APP_ADDR=$(pocketd keys show application -a)
export GATEWAY_ADDR=$(pocketd keys show gateway -a)
export TX_PARAM_FLAGS="--gas=auto --gas-prices=1upokt --gas-adjustment=1.5 --yes"
export BETA_NODE_FLAGS="--network=beta"
export BETA_RPC_URL="https://shannon-testnet-grove-rpc.beta.poktroll.com"
export BETA_GRPC_URL="https://shannon-testnet-grove-grpc.beta.poktroll.com:443"
export BETA_GRPC_URL_RAW="shannon-testnet-grove-grpc.beta.poktroll.com:443"
EOF

And source them in your shell:

echo "source ~/.pocketrc" >> ~/.profile
source ~/.profile

4. Fund the Gateway and Application accounts

  1. Retrieve your Gateway and Application addresses:

    echo "Gateway address: $GATEWAY_ADDR"
    echo "Application address: $APP_ADDR"
  2. Fund your account by going to Shannon Beta TestNet faucet.

  3. Check balance:

    pocketd query bank balances $GATEWAY_ADDR $BETA_NODE_FLAGS
    pocketd query bank balances $APP_ADDR $BETA_NODE_FLAGS
🌿 Grove employees only
pkd helpers
# Fund your account
pkd_beta_fund $GATEWAY_ADDR
pkd_beta_fund $APP_ADDR

# Check balance
pkd_beta_query bank balances $GATEWAY_ADDR
pkd_beta_query bank balances $APP_ADDR

Gateway and Application Configurations

1. Stake the Gateway

Create a Gateway staking config:

cat <<🚀 > /tmp/stake_gateway_config.yaml
stake_amount: 1000000upokt
🚀

And run the following command to stake the Gateway:

pocketd tx gateway stake-gateway \
--config=/tmp/stake_gateway_config.yaml \
--from=$GATEWAY_ADDR $TX_PARAM_FLAGS $NODE_FLAGS

After the next block settles, you can check the Gateway's status like so:

pocketd query gateway show-gateway $GATEWAY_ADDR $NODE_FLAGS

2. Stake the Application

Create an Application staking config:

cat <<🚀 > /tmp/stake_app_config.yaml
stake_amount: 100000000upokt
service_ids:
- "anvil"
🚀

And run the following command to stake the Application:

pocketd tx application stake-application \
--config=/tmp/stake_app_config.yaml \
--from=$APP_ADDR $TX_PARAM_FLAGS $NODE_FLAGS

After the next block settles, you can check the Application's status like so:

pocketd query application show-application $APP_ADDR $NODE_FLAGS

3. Delegate the Application to the Gateway

pocketd tx application delegate-to-gateway $GATEWAY_ADDR --from=$APP_ADDR $TX_PARAM_FLAGS $NODE_FLAGS

After about a minute, you can check the Application's status like so:

pocketd query application show-application $APP_ADDR $NODE_FLAGS

Send a test relay

You can run pocketd relayminer relay --help to use a helper utility to send a test relay from your staked application.

EVM Example

pocketd relayminer relay \
--app=${APP_ADDR} \
--node=${BETA_RPC_URL} \
--grpc-addr=${BETA_GRPC_URL_RAW} \
--grpc-insecure=false \
--keyring-backend="$POCKET_TEST_KEYRING_BACKEND" --home="$POCKET_HOME_PROD" \
--payload="{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"eth_blockNumber\", \"params\": []}"
Optional: Specify a supplier

You can specify a supplier by using the --supplier=<SUPPLIER_ADDR> flag.

Note that it will fail if the specified supplier is not in the session at the time of the relay.

PATH Gateway Setup

The documentation for everything related to PATH can be found at path.grove.city.

In particular, now that you have an Application and Gateway staked, you can follow the Configure PATH for Shannon sections of the PATH documentation.