Skip to content

Automatic top up - optional

As your relayers will be spending native tokens (which is the gas) and in some cases spending ERC20 tokens rrelayer has built in refill logic to make sure you keep topping up the relayers so they can keep doing their job.

The automatic_top_up field accepts an array of top-up configurations, allowing you to set up multiple funding sources and strategies for different relayers or token types on the same network.

Fields

from

This is where the funds are going to come from you have 2 options a safe or an relayer.

relayer

You can map the funds to come from a relayer which is on rrelayer itself you can do this by doing:

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from: 
          relayer:  
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"

You can also config if you want this relayer to be able to be used outside of the rrelayer server, we advise you do not do this as this rrelayer should really just be used internally (for security measures) so by default we set this to false but if you want to override you can.

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from: 
          relayer:  
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
            internal_only: false

safe

If you set this then the funds will be taken from the safe executed by the relayer address. This is important to understand rrelayer only knows how to execute and not sign so to use this the safe must be a 1 threshold and the relayer address must be one of the owners. We will explore more advanced multisig stuff with safe later on.

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from: 
          safe: '0xcfe267de230a234c5937f18f239617b7038ec271'
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"

relayers

This is the relayer addresses which will be topped up - it will only send to internal known relayer addresses if you put a random address in their rrelayer will throw and not process it.

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from:
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers: 
          - "0x1C09DF15FB12656420033EB58067EC9406EF0E26"
          - "0x6F3E343161C4B905342015AD20A5C492ADFB730E"
          - "0x68333AE8A21E1F768B20DB409486BE2D569A5258"

you can also use the * syntax to say fund every relayer, note it will not fund itself.

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from:
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers: "*"

native - optional (you should have this OR/AND erc20_tokens)

This is the mapping of how much you top up each time and also the trigger points of the min balance to send it. This should be in formatted style so if you want to send 2 ETH it should be "2", rrelayer will handle the formatting from decimals to send it.

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from:
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers: "*"
        native: 
          min_balance: "0.1"
          top_up_amount: "0.5"

By default it will assume your decimals are 18 but some native tokens do not have that decimal figure so you can set it:

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from:
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers: "*"
        native: 
          min_balance: "0.1"
          top_up_amount: "0.5"
          decimals: 6

erc20 tokens - optional (you should have this OR/AND native)

You can also map top up tokens say if you were using these relayers to send ERC20 tokens somewhere. It accepts an array of erc20_tokens.

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      - from:
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers: "*"
        native:
          min_balance: "0.1"
          top_up_amount: "0.5"
        erc20_tokens: 
          - address: "0x99bba657f2bbc93c02d617f8ba121cb8fc104acf"
            min_balance: "100"
            top_up_amount: "500"
            decimals: 18

Multiple Top-up Configurations

You can configure multiple top-up strategies on the same network. This is useful when you want different funding sources or strategies for different sets of relayers:

rrelayer.yaml
name: first-rrelayer
description: "my first rrelayer"
api_config:
  port: 3000
  authentication_username: ${RRELAYER_AUTH_USERNAME}
  authentication_password: ${RRELAYER_AUTH_PASSWORD}
signing_provider:
  aws_kms:
    region: "eu-west-1"
networks: 
  - name: local_anvil
    chain_id: 31337
    provider_urls:
      - http://127.0.0.1:8545
    block_explorer_url: http://localhost:8545
    max_gas_price_multiplier: 4
    gas_bump_blocks_every:
      slow: 10
      medium: 5
      fast: 4
      super_fast: 2
    automatic_top_up: 
      # First configuration - Native token top-up from relayer
      - from: 
          relayer:
            address: "0x33993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers: "*"
        native:
          min_balance: "0.1"
          top_up_amount: "0.5"
      # Second configuration - ERC20 token top-up 
      - from: 
          relayer:
            address: "0x44993A4F4AA617DA4558A0CFD0C39A7989B67720"
        relayers:
          - "0x1C09DF15FB12656420033EB58067EC9406EF0E26"
          - "0x6F3E343161C4B905342015AD20A5C492ADFB730E"
        erc20_tokens:
          - address: "0x99bba657f2bbc93c02d617f8ba121cb8fc104acf"
            min_balance: "100"
            top_up_amount: "500"
            decimals: 18