Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Location

The following high level steps need to be taken to update hotspot location

  1. Construct an AssertLocationV2 txn
  2. Deep link to hotspot app for signing
  3. If the assertion is to be paid for by the maker, send to onboarding server
  4. Submit to helium api

Use this module to assist asserting gateway locations on the Helium Network. You will be able to both change the location of the hotspot, and update its antenna gain and elevation.

For example creating and signing an assert location transaction with assertLocationTxn and calculating its fees with calculateAssertLocFee.

Import the module

import { Location } from '@helium/react-native-sdk';

Create the Assert Location Transaction

const assertLocationTxn = await Location.createLocationTxn({
  gateway: hotspotAddress,
  lat,
  lng,
  decimalGain: params.gain,
  elevation: params.elevation,
  dataOnly: false,
  owner: ownerAddress,
  // currentLocation: '', // If reasserting location, put previous location here
  makerAddress: onboardingRecord.maker.address,
  location,
});

Calculate Assert Location Fees

There are two fees associated with asserting hotspot location. These fees are paid by either the maker, or the hotspot owner depending on how many free asserts the maker provides. If the payer account has no DC, HNT will be implicitly burned to cover the transaction fees.

There are currently two fees that occur, if changing hotspot location a staking fee of 1,000,000 DC ($10) is added to the base transaction fee of 55,000 DC ($0.55).

You can use the calculateAssertLocFee function to determine what fees the transaction will charge. The nonce should be provided from the hotspot's nonce.

You can read more about transaction fees on the Helium Docs.

Index

Functions

Const calculateAssertLocFee

  • calculateAssertLocFee(ownerB58: undefined | string, payerB58: undefined | string, nonce: undefined | number): { fee: number; stakingFee: number }
  • Parameters

    • ownerB58: undefined | string
    • payerB58: undefined | string
    • nonce: undefined | number

    Returns { fee: number; stakingFee: number }

    • fee: number
    • stakingFee: number

Const createAndSignAssertLocationTxn

  • createAndSignAssertLocationTxn(__namedParameters: { currentLocation?: string; dataOnly?: boolean; decimalGain?: number; elevation?: number; gateway: string; lat: number; lng: number; locationNonceLimit: number; makerAddress: string; owner: string; ownerKeypairRaw: SodiumKeyPair }): Promise<{ isFree: boolean; signedTxn: AssertLocationV2 }>
  • Create a signed AddGatewayV1 transaction string which can be submit to the blockchain using heliumHttpClient

    Parameters

    • __namedParameters: { currentLocation?: string; dataOnly?: boolean; decimalGain?: number; elevation?: number; gateway: string; lat: number; lng: number; locationNonceLimit: number; makerAddress: string; owner: string; ownerKeypairRaw: SodiumKeyPair }
      • Optional currentLocation?: string
      • Optional dataOnly?: boolean
      • Optional decimalGain?: number
      • Optional elevation?: number
      • gateway: string
      • lat: number
      • lng: number
      • locationNonceLimit: number
      • makerAddress: string
      • owner: string
      • ownerKeypairRaw: SodiumKeyPair

    Returns Promise<{ isFree: boolean; signedTxn: AssertLocationV2 }>

Const createLocationTxn

  • createLocationTxn(__namedParameters: { currentLocation?: string; dataOnly?: boolean; decimalGain?: number; elevation?: number; gateway: string; lat: number; lng: number; locationNonceLimit: number; makerAddress: string; owner: string }): Promise<AssertLocationV2>
  • Parameters

    • __namedParameters: { currentLocation?: string; dataOnly?: boolean; decimalGain?: number; elevation?: number; gateway: string; lat: number; lng: number; locationNonceLimit: number; makerAddress: string; owner: string }
      • Optional currentLocation?: string
      • Optional dataOnly?: boolean
      • Optional decimalGain?: number
      • Optional elevation?: number
      • gateway: string
      • lat: number
      • lng: number
      • locationNonceLimit: number
      • makerAddress: string
      • owner: string

    Returns Promise<AssertLocationV2>

Const getH3Location

  • getH3Location(lat: number, lng: number, res?: number): string
  • Returns the H3 Hex of a lat lng location at a specific resolution. The default resolution is 12. See Uber H3 for more info.

    Parameters

    • lat: number
    • lng: number
    • res: number = ...

    Returns string

Const hasFreeLocationAssert

  • hasFreeLocationAssert(nonce: number, locationNonceLimit: number): boolean
  • Determine if a hotspot still has a location assert paid for by its maker.

    Parameters

    • nonce: number
    • locationNonceLimit: number

    Returns boolean

Const loadLocationFeeData

  • loadLocationFeeData(__namedParameters: { accountIntegerBalance: number; dataOnly?: boolean; locationNonceLimit: number; makerAddress: string; nonce?: number; owner: string }): Promise<{ hasSufficientBalance: boolean; isFree: boolean; remainingFreeAsserts: number; totalStakingAmount: Balance<NetworkTokens>; totalStakingAmountDC: Balance<DataCredits>; totalStakingAmountUsd: Balance<USDollars> }>
  • Get all required fee information for a Hotspot Assert Location transaction.

    Parameters

    • __namedParameters: { accountIntegerBalance: number; dataOnly?: boolean; locationNonceLimit: number; makerAddress: string; nonce?: number; owner: string }
      • accountIntegerBalance: number
      • Optional dataOnly?: boolean
      • locationNonceLimit: number
      • makerAddress: string
      • Optional nonce?: number
      • owner: string

    Returns Promise<{ hasSufficientBalance: boolean; isFree: boolean; remainingFreeAsserts: number; totalStakingAmount: Balance<NetworkTokens>; totalStakingAmountDC: Balance<DataCredits>; totalStakingAmountUsd: Balance<USDollars> }>

Const makeAssertLocTxn

  • makeAssertLocTxn(__namedParameters: { elevation: number; gain: number; gatewayB58: string; location: string; nonce: number; ownerB58: string; payerB58: string; stakingFee: number }): AssertLocationV2
  • Parameters

    • __namedParameters: { elevation: number; gain: number; gatewayB58: string; location: string; nonce: number; ownerB58: string; payerB58: string; stakingFee: number }
      • elevation: number
      • gain: number
      • gatewayB58: string
      • location: string
      • nonce: number
      • ownerB58: string
      • payerB58: string
      • stakingFee: number

    Returns AssertLocationV2

Const signAssertLocTxn

  • signAssertLocTxn(__namedParameters: { elevation: number; gain: number; gatewayB58: string; location: string; nonce: number; ownerB58: string; ownerKeypairRaw: SodiumKeyPair; payerB58: string; stakingFee: number }): Promise<AssertLocationV2>
  • Parameters

    • __namedParameters: { elevation: number; gain: number; gatewayB58: string; location: string; nonce: number; ownerB58: string; ownerKeypairRaw: SodiumKeyPair; payerB58: string; stakingFee: number }
      • elevation: number
      • gain: number
      • gatewayB58: string
      • location: string
      • nonce: number
      • ownerB58: string
      • ownerKeypairRaw: SodiumKeyPair
      • payerB58: string
      • stakingFee: number

    Returns Promise<AssertLocationV2>

Const txnFromString

Generated using TypeDoc