Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EthereumHelpers

Ethereum Util class for Ethereum related Atomex helper functions

Hierarchy

Index

Constructors

  • new EthereumHelpers(web3: default, jsonInterface: AbiItem[], contractAddress: string, timeBetweenBlocks: number, gasLimit: number): EthereumHelpers

Methods

  • buildActivateTransaction(secretHash: string): PartialTransactionBody
  • Get the tx data for Atomex Contract Activate Swap call

    Parameters

    • secretHash: string

    Returns PartialTransactionBody

    contract address and tx data that can be used to make a contract call

  • buildAddTransaction(secretHash: string, amount: number): PartialTransactionBody
  • buildInitiateTransaction(initiateParameters: InitiateParameters): PartialTransactionBody
  • buildRedeemTransaction(secret: string, hashedSecret: string): PartialTransactionBody
  • buildRefundTransaction(secretHash: string): PartialTransactionBody
  • encodePublicKey(pubKey: string): string
  • encodeSignature(signature: string): string
  • estimateInitiateFees(source: string): Promise<number>
  • estimateRedeemFees(recipient: string): Promise<RedeemFees>
  • getAuthMessage(message: string, address?: string): AuthMessage
  • Get the details needed for getAuthToken request

    remarks

    the msgToSign value needs to be signed before being used for Auth

    Parameters

    • message: string
    • Optional address: string

    Returns AuthMessage

  • isValidAddress(address: string): boolean
  • parseInitiateParameters(transaction: Transaction): InitiateParameters
  • Parameters

    • transaction: Transaction

    Returns InitiateParameters

  • recoverPublicKey(msg: string, signature: string): string
  • Recover Ethereum Account Public Key from RLC signature

    Parameters

    • msg: string

      original message, msgToSign parameter generated using getAuthMessage

    • signature: string

      signed message

    Returns string

    ethereum public key

  • validateInitiateTransaction(_blockHeight: number, txID: string, secretHash: string, receivingAddress: string, amount: number, payoff: number, minRefundTimestamp: number, minConfirmations?: number): Promise<SwapTransactionStatus>
  • Validate the Swap Details on chain using the tx detail from Atomex [does not check tx status, use status provided by atomex]

    Parameters

    • _blockHeight: number
    • txID: string
    • secretHash: string
    • receivingAddress: string
    • amount: number
    • payoff: number
    • minRefundTimestamp: number
    • minConfirmations: number = 2

    Returns Promise<SwapTransactionStatus>

  • create(network: "testnet" | "mainnet", rpcUri?: string): Promise<EthereumHelpers>
  • Connects to the supported ethereum chain

    Parameters

    • network: "testnet" | "mainnet"
    • Optional rpcUri: string

    Returns Promise<EthereumHelpers>

    chain id of the connected chain

Generated using TypeDoc