Options
All
  • Public
  • Public/Protected
  • All
Menu

HancockProtocolService

Introduction

We can use this interface to manage Hancock's protocol operations

Encode transaction with Hancock's protocol

  const hancockEthClient = new HancockEthereumClient(config);

  const result = await hancockEthClient.protocol.encode(
    'transfer',
    10000000000000000000,
    '0xf01b3c2131fb5bd8d1d1e5d44f8ad14a2728ec91',
    '',
    'ethereum'
  );
  console.log(result.data.qrEncode);

Console output:

hancock://qr?code=%7B%22action%22%3A%22transfer%22%2C%22body%22%3A%7B%22value%22%3A%2210000000000000000000%22%2C%22to%22%3A%220xf01b3c2131fb5bd8d1d1e5d44f8ad14a2728ec91%22%7D%2C%22dlt%22%3A%22ethereum%22%7D

Decode transaction with Hancock's protocol

  const hancockEthClient = new HancockEthereumClient(config);

  const result = await hancockEthClient.protocol.decode('code=%7B%22action%22%3A%22transfer%22%2C%22body%22%3A%7B%22value%22%3A%2210000000000000000000%22%2C%22to%22%3A%220xf01b3c2131fb5bd8d1d1e5d44f8ad14a2728ec91%22%7D%2C%22dlt%22%3A%22ethereum%22%7D');
  console.log(result.data);

Console output:

{
  "action": "transfer",
  "body": {
    "to": "0xf01b3c2131fb5bd8d1d1e5d44f8ad14a2728ec91",
    "value": "10000000000000000000",
    "data": ""
  },
  "dlt": "ethereum"
}

Hierarchy

  • HancockProtocolService

Index

Constructors

Methods

Constructors

constructor

Methods

decode

  • Decode content (a static predefined transaction for example) encoded Hancock's protocol

    Parameters

    • code: string

      The encoded content

    Returns Promise<HancockProtocolDecodeResponse>

    The encoded content successfully decoded

encode

  • Encode an operation over the blockchain (a static predefined transaction for example) using Hancock's protocol

    Parameters

    Returns Promise<HancockProtocolEncodeResponse>

    The content successfully encoded

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