Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FIOSDK

Hierarchy

  • FIOSDK

Index

Constructors

constructor

  • new FIOSDK(privateKey: string, publicKey: string, baseUrl: string, fetchjson: FetchJson, registerMockUrl?: string, technologyProviderId?: string): FIOSDK
  • // how to instantiate fetchJson parameter i.e. fetch = require('node-fetch')

    const fetchJson = async (uri, opts = {}) => { return fetch(uri, opts) }

    Parameters

    • privateKey: string

      the fio private key of the client sending requests to FIO API.

    • publicKey: string

      the fio public key of the client sending requests to FIO API.

    • baseUrl: string

      the url to the FIO API.

    • fetchjson: FetchJson

      the module to use for HTTP Post/Get calls (see above for example)

    • Default value registerMockUrl: string = ""

      the url to the mock server

    • Default value technologyProviderId: string = ""

      Default FIO Address of the wallet which generates transactions.

    Returns FIOSDK

Properties

privateKey

privateKey: string

the fio private key of the client sending requests to FIO API.

publicKey

publicKey: string

the fio public key of the client sending requests to FIO API.

technologyProviderId

technologyProviderId: string

Default FIO Address of the wallet which generates transactions.

transactions

transactions: Transactions

Static SUFUnit

SUFUnit: number = 1000000000

SUFs = Smallest Units of FIO

Methods

addPublicAddress

  • addPublicAddress(fioAddress: string, chainCode: string, tokenCode: string, publicAddress: string, maxFee: number, technologyProviderId?: string | null): Promise<AddPublicAddressResponse>
  • This call allows a public address of the specific blockchain type to be added to the FIO Address.

    Parameters

    • fioAddress: string

      FIO Address which will be mapped to public address.

    • chainCode: string

      Blockchain code for blockchain hosting this token.

    • tokenCode: string

      Token code to be used with that public address.

    • publicAddress: string

      The public address to be added to the FIO Address for the specified token.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<AddPublicAddressResponse>

addPublicAddresses

  • addPublicAddresses(fioAddress: string, publicAddresses: PublicAddress[], maxFee: number, technologyProviderId?: string | null): Promise<AddPublicAddressResponse>
  • This call allows a public addresses of the specific blockchain type to be added to the FIO Address.

    Parameters

    • fioAddress: string

      FIO Address which will be mapped to public addresses.

    • publicAddresses: PublicAddress[]

      Array of public addresses to be added to the FIO Address for the specified token.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<AddPublicAddressResponse>

getFee

  • getFee(endPoint: EndPoint, fioAddress?: string): Promise<FioFeeResponse>
  • Compute and return fee amount for specific call and specific user

    Parameters

    • endPoint: EndPoint

      Name of API call end point, e.g. add_pub_address.

    • Default value fioAddress: string = ""
         if endPointName is RenewFioAddress, FIO Address incurring the fee and owned by signer.
         if endPointName is RenewFioDomain, FIO Domain incurring the fee and owned by signer.
         if endPointName is RecordObtData, Payer FIO Address incurring the fee and owned by signer.
      
         Omit for:
         - register_fio_domain
         - register_fio_address
         - transfer_tokens_pub_key

    Returns Promise<FioFeeResponse>

getFeeForAddPublicAddress

  • getFeeForAddPublicAddress(fioAddress: string): Promise<FioFeeResponse>
  • Compute and return fee amount for specific call and specific user

    Parameters

    • fioAddress: string

      FIO Address incurring the fee and owned by signer.

    Returns Promise<FioFeeResponse>

getFeeForNewFundsRequest

  • getFeeForNewFundsRequest(payeeFioAddress: string): Promise<FioFeeResponse>
  • Compute and return fee amount for specific call and specific user

    Parameters

    • payeeFioAddress: string

      Payee FIO Address incurring the fee and owned by signer.

    Returns Promise<FioFeeResponse>

getFeeForRecordObtData

  • getFeeForRecordObtData(payerFioAddress: string): Promise<FioFeeResponse>
  • Compute and return fee amount for specific call and specific user

    Parameters

    • payerFioAddress: string

    Returns Promise<FioFeeResponse>

getFeeForRejectFundsRequest

  • getFeeForRejectFundsRequest(payerFioAddress: string): Promise<FioFeeResponse>
  • Compute and return fee amount for specific call and specific user

    Parameters

    • payerFioAddress: string

      Payer FIO Address incurring the fee and owned by signer.

    Returns Promise<FioFeeResponse>

getFioBalance

  • getFioBalance(fioPublicKey?: undefined | string): Promise<BalanceResponse>
  • Retrieves balance of FIO tokens

    Parameters

    • Optional fioPublicKey: undefined | string

      FIO public key.

    Returns Promise<BalanceResponse>

getFioNames

  • getFioNames(fioPublicKey: string): Promise<FioNamesResponse>
  • Returns FIO Addresses and FIO Domains owned by this public key.

    Parameters

    • fioPublicKey: string

      FIO public key of owner.

    Returns Promise<FioNamesResponse>

getFioPublicAddress

  • getFioPublicAddress(fioAddress: string): Promise<PublicAddressResponse>
  • Returns the FIO token public address for specified FIO Address.

    Parameters

    • fioAddress: string

      FIO Address for which fio token public address is to be returned.

    Returns Promise<PublicAddressResponse>

getFioPublicKey

  • getFioPublicKey(): string
  • Retrieves the FIO public key assigned to the FIOSDK instance.

    Returns string

getObtData

  • getObtData(limit?: undefined | number, offset?: undefined | number, tokenCode?: undefined | string): Promise<GetObtDataResponse>
  • Retrives OBT metadata data stored using record send.

    Parameters

    • Optional limit: undefined | number

      Number of request to return. If omitted, all requests will be returned.

    • Optional offset: undefined | number

      First request from list to return. If omitted, 0 is assumed.

    • Optional tokenCode: undefined | string

      Code of the token to filter results

    Returns Promise<GetObtDataResponse>

getPendingFioRequests

  • getPendingFioRequests(limit?: undefined | number, offset?: undefined | number): Promise<PendingFioRequestsResponse>
  • Polls for any pending requests sent to public key associated with the FIO SDK instance.

    Parameters

    • Optional limit: undefined | number

      Number of request to return. If omitted, all requests will be returned.

    • Optional offset: undefined | number

      First request from list to return. If omitted, 0 is assumed.

    Returns Promise<PendingFioRequestsResponse>

getPublicAddress

  • getPublicAddress(fioAddress: string, chainCode: string, tokenCode: string): Promise<PublicAddressResponse>
  • Returns a token public address for specified token code and FIO Address.

    Parameters

    • fioAddress: string

      FIO Address for which the token public address is to be returned.

    • chainCode: string

      Blockchain code for which public address is to be returned.

    • tokenCode: string

      Token code for which public address is to be returned.

    Returns Promise<PublicAddressResponse>

getSentFioRequests

  • getSentFioRequests(limit?: undefined | number, offset?: undefined | number): Promise<SentFioRequestResponse>
  • Polls for any sent requests sent by public key associated with the FIO SDK instance.

    Parameters

    • Optional limit: undefined | number

      Number of request to return. If omitted, all requests will be returned.

    • Optional offset: undefined | number

      First request from list to return. If omitted, 0 is assumed.

    Returns Promise<SentFioRequestResponse>

getTechnologyProviderId

  • getTechnologyProviderId(technologyProviderId: string | null): string
  • Returns technologyProviderId or default

    Parameters

    • technologyProviderId: string | null

    Returns string

isAvailable

  • isAvailable(fioName: string): Promise<AvailabilityResponse>
  • Checks if a FIO Address or FIO Domain is available for registration.

    Parameters

    • fioName: string

      FIO Address or FIO Domain to check.

    Returns Promise<AvailabilityResponse>

pushTransaction

  • pushTransaction(account: string, action: string, data: any): Promise<any>
  • Allows advance user to send their own content directly to FIO contracts

    Parameters

    • account: string

      Account name

    • action: string

      Name of action

    • data: any

      JSON object with params for action

    Returns Promise<any>

recordObtData

  • recordObtData(fioRequestId: number | null, payerFioAddress: string, payeeFioAddress: string, payerTokenPublicAddress: string, payeeTokenPublicAddress: string, amount: number, chainCode: string, tokenCode: string, status: string, obtId: string, maxFee: number, technologyProviderId?: string | null, payeeFioPublicKey?: string | null, memo?: string | null, hash?: string | null, offLineUrl?: string | null): Promise<RecordObtDataResponse>
  • Records information on the FIO blockchain about a transaction that occurred on other blockchain, i.e. 1 BTC was sent on Bitcoin Blockchain, and both sender and receiver have FIO Addresses. OBT stands for Other Blockchain Transaction

    Parameters

    • fioRequestId: number | null

      ID of funds request, if this Record Send transaction is in response to a previously received funds request. Send empty if no FIO Request ID

    • payerFioAddress: string

      FIO Address of the payer. This address initiated payment.

    • payeeFioAddress: string

      FIO Address of the payee. This address is receiving payment.

    • payerTokenPublicAddress: string

      Public address on other blockchain of user sending funds.

    • payeeTokenPublicAddress: string

      Public address on other blockchain of user receiving funds.

    • amount: number

      Amount sent.

    • chainCode: string

      Blockchain code for blockchain hosting this token.

    • tokenCode: string

      Code of the token represented in Amount requested, i.e. BTC.

    • status: string

      Status of this OBT. Allowed statuses are: sent_to_blockchain.

    • obtId: string

      Other Blockchain Transaction ID (OBT ID), i.e Bitcoin transaction ID.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    • Default value payeeFioPublicKey: string | null = null

      Public address on other blockchain of user receiving funds.

    • Default value memo: string | null = null
    • Default value hash: string | null = null
    • Default value offLineUrl: string | null = null

    Returns Promise<RecordObtDataResponse>

registerFioAddress

  • registerFioAddress(fioAddress: string, maxFee: number, technologyProviderId?: string | null): Promise<RegisterFioAddressResponse>
  • Registers a FIO Address on the FIO blockchain. The owner will be the public key associated with the FIO SDK instance.

    Parameters

    • fioAddress: string

      FIO Address to register.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by @ [getFee] for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<RegisterFioAddressResponse>

registerFioDomain

  • registerFioDomain(fioDomain: string, maxFee: number, technologyProviderId?: string | null): Promise<RegisterFioDomainResponse>
  • Registers a FIO Domain on the FIO blockchain.

    Parameters

    • fioDomain: string

      FIO Domain to register. The owner will be the public key associated with the FIO SDK instance.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by @ [getFee] for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<RegisterFioDomainResponse>

registerOwnerFioAddress

  • registerOwnerFioAddress(fioAddress: string, ownerPublicKey: string, maxFee: number, technologyProviderId?: string | null): Promise<RegisterFioAddressResponse>
  • Registers a Fio Address on behalf of the owner FIO Public key parameter. Owner FIO Public key owns the FIO address

    Parameters

    • fioAddress: string

      FIO Address to register.

    • ownerPublicKey: string

      Owner FIO Public Key.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by @ [getFee] for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<RegisterFioAddressResponse>

rejectFundsRequest

  • rejectFundsRequest(fioRequestId: number, maxFee: number, technologyProviderId?: string | null): Promise<RejectFundsResponse>
  • Reject funds request.

    Parameters

    • fioRequestId: number

      Existing funds request Id

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by [getFee] for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<RejectFundsResponse>

renewFioAddress

  • renewFioAddress(fioAddress: string, maxFee: number, technologyProviderId?: string | null): Promise<RenewFioAddressResponse>
  • Renew a FIO Address on the FIO blockchain.

    Parameters

    • fioAddress: string

      FIO Address to renew.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by @ [getFee] for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<RenewFioAddressResponse>

renewFioDomain

  • renewFioDomain(fioDomain: string, maxFee: number, technologyProviderId?: string | null): Promise<RenewFioDomainResponse>
  • Renew a FIO Domain on the FIO blockchain.

    Parameters

    • fioDomain: string

      FIO Domain to renew.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by @ [getFee] for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<RenewFioDomainResponse>

requestFunds

  • requestFunds(payerFioAddress: string, payeeFioAddress: string, payeeTokenPublicAddress: string, amount: number, chainCode: string, tokenCode: string, memo: string, maxFee: number, payerFioPublicKey?: string | null, technologyProviderId?: string | null, hash?: undefined | string, offlineUrl?: undefined | string): Promise<RequestFundsResponse>
  • Create a new funds request on the FIO chain.

    Parameters

    • payerFioAddress: string

      FIO Address of the payer. This address will receive the request and will initiate payment.

    • payeeFioAddress: string

      FIO Address of the payee. This address is sending the request and will receive payment.

    • payeeTokenPublicAddress: string

      Payee's public address where they want funds sent.

    • amount: number

      Amount requested.

    • chainCode: string

      Blockchain code for blockchain hosting this token.

    • tokenCode: string

      Code of the token represented in amount requested.

    • memo: string
    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by [getFee] for correct value.

    • Default value payerFioPublicKey: string | null = null

      Public address on other blockchain of user sending funds.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    • Optional hash: undefined | string
    • Optional offlineUrl: undefined | string

    Returns Promise<RequestFundsResponse>

setFioDomainVisibility

  • setFioDomainVisibility(fioDomain: string, isPublic: boolean, maxFee: number, technologyProviderId?: string | null): Promise<SetFioDomainVisibilityResponse>
  • By default all FIO Domains are non-public, meaning only the owner can register FIO Addresses on that domain. Setting them to public allows anyone to register a FIO Address on that domain.

    Parameters

    • fioDomain: string

      FIO Domain to change visibility.

    • isPublic: boolean

      1 - allows anyone to register FIO Address, 0 - only owner of domain can register FIO Address.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<SetFioDomainVisibilityResponse>

transferTokens

  • transferTokens(payeeFioPublicKey: string, amount: number, maxFee: number, technologyProviderId?: string | null): Promise<TransferTokensResponse>
  • Transfers FIO tokens from public key associated with the FIO SDK instance to the payeePublicKey.

    Parameters

    • payeeFioPublicKey: string

      FIO public Address of the one receiving the tokens.

    • amount: number

      Amount sent in SUFs.

    • maxFee: number

      Maximum amount of SUFs the user is willing to pay for fee. Should be preceded by /get_fee for correct value.

    • Default value technologyProviderId: string | null = null

      FIO Address of the wallet which generates this transaction.

    Returns Promise<TransferTokensResponse>

Static SUFToAmount

  • SUFToAmount(suf: number): number
  • Convert FIO SUFs to a FIO Token amount

    Parameters

    • suf: number

    Returns number

    FIO Token amount

Static amountToSUF

  • amountToSUF(amount: number): number
  • Convert a FIO Token Amount to FIO SUFs

    Parameters

    • amount: number

      2.568 FIO should be 2568000000 SUFs

    Returns number

    FIO SUFs

Static createPrivateKeyMnemonic

  • createPrivateKeyMnemonic(mnemonic: string): Promise<{ fioKey: any; mnemonic: string }>
  • Create a FIO private key.

    example

    real flame win provide layer trigger soda erode upset rate beef wrist fame design merit

    Parameters

    • mnemonic: string

      mnemonic used to generate a random unique private key.

    Returns Promise<{ fioKey: any; mnemonic: string }>

    New FIO private key

Static derivedPublicKey

  • derivedPublicKey(fioPrivateKey: string): { publicKey: any }
  • Create a FIO public key.

    Parameters

    • fioPrivateKey: string

      FIO private key.

    Returns { publicKey: any }

    FIO public key derived from the FIO private key.

    • publicKey: any

Static isChainCodeValid

  • isChainCodeValid(chainCode: string): boolean
  • Is the Chain Code Valid?

    Parameters

    • chainCode: string

    Returns boolean

    Chain Code is Valid

Static isFioAddressValid

  • isFioAddressValid(fioAddress: string): boolean
  • Is the FIO Address Valid?

    Parameters

    • fioAddress: string

    Returns boolean

    Fio Address is Valid

Static isFioDomainValid

  • isFioDomainValid(fioDomain: string): boolean
  • Is the FIO Domain Valid?

    Parameters

    • fioDomain: string

    Returns boolean

    FIO Domain is Valid

Static isFioPublicKeyValid

  • isFioPublicKeyValid(fioPublicKey: string): boolean
  • Is the FIO Public Key Valid?

    Parameters

    • fioPublicKey: string

    Returns boolean

    FIO Public Key is Valid

Static isPublicAddressValid

  • isPublicAddressValid(publicAddress: string): boolean
  • Is the Public Address Valid?

    Parameters

    • publicAddress: string

    Returns boolean

    Public Address is Valid

Static isTokenCodeValid

  • isTokenCodeValid(tokenCode: string): boolean
  • Is the Token Code Valid?

    Parameters

    • tokenCode: string

    Returns boolean

    Token Code is Valid

Generated using TypeDoc