Options
All
  • Public
  • Public/Protected
  • All
Menu

HancockEthereumTransferService

Introduction

We can use this interface to manage transfers of ether over blockchain

Send transfer

  const hancockEthClient = new HancockEthereumClient(config);

  const result = await hancockEthClient.transfers.send(
    '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF',
    '0x28a0686efb7dd9b625288a08649a6278cc4fd154',
    1000000000000000000,
    {
      privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83'
    }
  );
  console.log(result);

Console output:

{
  success: true
}

Subscribe to transfers

  const hancockEthClient = new HancockEthereumClient(config);

  const subscription = hancockEthClient.transfers.subscribe([
    '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF'
  ]);
  subscription.on('tx', (data) => { console.log(data) });
  subscription.on('error', (error) => { console.error(error) });

Hierarchy

  • HancockEthereumTransferService

Index

Constructors

Methods

Constructors

constructor

Methods

send

  • Send ethers between two accounts

    Parameters

    • from: string

      The sender address

    • to: string

      The receiver address

    • value: string

      The amount of ether to transfer (in weis)

    • Default value options: HancockInvokeOptions = {}

      Configuration of how the transaction will be send to the network

    • Default value data: string = ""

      Extra information that will be sent with the transfer (a remark for example)

    Returns Promise<HancockSignResponse>

    An event emmiter that will fire the watched "transfers" events

subscribe

  • Create a websocket subscription to watch transactions of type "transfers" in the network

    Parameters

    • Default value addresses: string[] = []

      An array of address that will be added to the watch list

    • Default value consumer: string = ""

      A consumer plugin previously configured in hancock that will handle each received event

    Returns HancockEthereumSocket

    An event emmiter that will fire the watched "transfers" events

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc