Hive Multisig SDK
  • Welcome!
  • Quick Start
  • WebSocket flow
    • 1 - Users connect to the Websocket
    • 2 - User A requests a transaction
    • 3 - User B receives the signature request
    • 4 - User B signs the transaction
    • 5 - User B broadcasts the transaction
    • 6 - Users both receive a successful broadcast notification
  • API
  • Utils
    • Encode Transaction
    • Decode Transaction
  • Static helpers
    • Get/Reset HiveMultisig instance
    • Get Signers
    • Get Authorities
    • Validate Initiator
  • Demo
Powered by GitBook
On this page
  • Encode Transaction
  • IEncodeTransaction object
  1. Utils

Encode Transaction

PreviousUtilsNextDecode Transaction

Last updated 1 year ago

All multisig requests must be encrypted through Keychain to ensure that only the valid initiator and potential signers have access to them. Therefore we provided a utility function to encode as follows:

Encode Transaction

Begin by encapsulating the operation using , then integrate it into the 'IEncodeTransaction' object.

const multisig = HiveMultisig.getInstance(window: Window,options?:MultisigOptions); 

const op: Hive.TransferOperation = [
      'transfer',
      {
        from: 'joe',
        to: 'jane',
        amount: 1,
        memo: 'payment',
      },
    ];

const _hiveTx = new hiveTx.Transaction();
const transaction  _hiveTx.create([op], getSeconds(expiration))
const txEncode: IEncodeTransaction = {
          transaction: transaction,
          method: 'posting',
          expirationDate: expiration,
          initiator: 'joe',
        };

const encodedTx = await multisig.utils.encodeTransaction(txEncode)

The multisig.utils.encodeTransaction() function will automatically assign the encoded message to all potential signers. This process encodes the transaction through Keychain and returns the 'RequestSignatureMessage' object.

IEncodeTransaction object

Property
Description
Type

transaction

The transaction that is being initiated. Contains the operation and expiration wrapped using hive-tx.Transaction()

hive-tx Transaction

method

The type of key subscribing to the WebSocket. Can be "Active" or "Posting"

KeychainKeyTypes enum

expirationDate

The expiration date of the multisig request. Must be minimum of 10 minutes and maximum of 1 hour from the time of creatio

Date or string

initiator object

Initiator details corresponding to the method. Including username, public key, and weight.

username: string publicKey: string weight: number

hive-tx Transaction()