How to use exonum-client - 10 common examples

To help you get started, we’ve selected a few exonum-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
const buildMessage = (header, body, keyPair) => {
  const unsignedMessage = appendBuffer(new Uint8Array(header), body)

  // calculate payload and insert it into buffer
  Exonum.Uint32.serialize(unsignedMessage.length + SIGNATURE_LENGTH, unsignedMessage, PAYLOAD_SIZE_OFFSET)

  // calculate signature
  const signature = Exonum.sign(keyPair.secretKey, unsignedMessage)

  // append signature to the message
  return appendBuffer(unsignedMessage, Exonum.hexadecimalToUint8Array(signature))
}
github exonum / exonum-java-binding / exonum-java-binding / cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
transfer (keyPair, receiver, amountToTransfer, seed) {
        // Describe transaction
        const transaction = new TransferTransaction(keyPair.publicKey)

        // Transaction data
        const data = {
          seed: seed,
          toWallet: Exonum.hexadecimalToUint8Array(receiver),
          sum: amountToTransfer
        }

        // Send transaction into blockchain
        return transaction.send(TRANSACTION_URL, data, keyPair.secretKey)
      },
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
transfer (keyPair, receiver, amountToTransfer, seed) {
        // serialize and append message header
        const header = createHeader(TX_TRANSFER_ID)

        // serialize and append message body
        const data = {
          seed: seed,
          senderId: Exonum.hexadecimalToUint8Array(keyPair.publicKey),
          recipientId: Exonum.hexadecimalToUint8Array(receiver),
          amount: amountToTransfer
        }
        const body = TransferTransactionProtobuf.encode(data).finish()

        return axios.post(TX_URL, buildMessage(header, body, keyPair))
          .then(response => waitForAcceptance(keyPair.publicKey, response.data))
      },
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
transfer (keyPair, receiver, amountToTransfer, seed) {
        // serialize and append message header
        const header = createHeader(TX_TRANSFER_ID)

        // serialize and append message body
        const data = {
          seed: seed,
          senderId: Exonum.hexadecimalToUint8Array(keyPair.publicKey),
          recipientId: Exonum.hexadecimalToUint8Array(receiver),
          amount: amountToTransfer
        }
        const body = TransferTransactionProtobuf.encode(data).finish()

        return axios.post(TX_URL, buildMessage(header, body, keyPair))
          .then(response => waitForAcceptance(keyPair.publicKey, response.data))
      },
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
createWallet (keyPair, balance) {
        // serialize and append message header
        const header = createHeader(TX_WALLET_ID)

        // serialize and append message body
        const data = {
          ownerPublicKey: Exonum.hexadecimalToUint8Array(keyPair.publicKey),
          initialBalance: balance
        }
        const body = CreateTransactionProtobuf.encode(data).finish()

        return axios.post(TX_URL, buildMessage(header, body, keyPair))
      },
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
const buildMessage = (header, body, keyPair) => {
  const unsignedMessage = appendBuffer(new Uint8Array(header), body)

  // calculate payload and insert it into buffer
  Exonum.Uint32.serialize(unsignedMessage.length + SIGNATURE_LENGTH, unsignedMessage, PAYLOAD_SIZE_OFFSET)

  // calculate signature
  const signature = Exonum.sign(keyPair.secretKey, unsignedMessage)

  // append signature to the message
  return appendBuffer(unsignedMessage, Exonum.hexadecimalToUint8Array(signature))
}
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
const buildMessage = (header, body, keyPair) => {
  const unsignedMessage = appendBuffer(new Uint8Array(header), body)

  // calculate payload and insert it into buffer
  Exonum.Uint32.serialize(unsignedMessage.length + SIGNATURE_LENGTH, unsignedMessage, PAYLOAD_SIZE_OFFSET)

  // calculate signature
  const signature = Exonum.sign(keyPair.secretKey, unsignedMessage)

  // append signature to the message
  return appendBuffer(unsignedMessage, Exonum.hexadecimalToUint8Array(signature))
}
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
const ATTEMPT_TIMEOUT = 500
const PROTOCOL_VERSION = 0
const SERVICE_ID = 42
const TX_TRANSFER_ID = 2
const TX_WALLET_ID = 1
const SIGNATURE_LENGTH = 64
const PAYLOAD_SIZE_OFFSET = 6
const PER_PAGE = 10
const MAX_VALUE = 2147483647

const MessageHead = Exonum.newType({
  fields: [
    { name: 'network_id', type: Exonum.Uint8 },
    { name: 'protocol_version', type: Exonum.Uint8 },
    { name: 'message_id', type: Exonum.Uint16 },
    { name: 'service_id', type: Exonum.Uint16 },
    { name: 'payload', type: Exonum.Uint32 }
  ]
})

function getWallet (publicKey) {
  return axios.get(`/api/cryptocurrency-demo-service/wallet/${publicKey}`)
    .then(response => response.data)
    .then(data => {
      return {
        wallet: data,
        transactions: []
      }
    })
}

function waitForAcceptance (publicKey, hash) {
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
const ATTEMPTS = 10
const ATTEMPT_TIMEOUT = 500
const PROTOCOL_VERSION = 0
const SERVICE_ID = 42
const TX_TRANSFER_ID = 2
const TX_WALLET_ID = 1
const SIGNATURE_LENGTH = 64
const PAYLOAD_SIZE_OFFSET = 6
const PER_PAGE = 10
const MAX_VALUE = 2147483647

const MessageHead = Exonum.newType({
  fields: [
    { name: 'network_id', type: Exonum.Uint8 },
    { name: 'protocol_version', type: Exonum.Uint8 },
    { name: 'message_id', type: Exonum.Uint16 },
    { name: 'service_id', type: Exonum.Uint16 },
    { name: 'payload', type: Exonum.Uint32 }
  ]
})

function getWallet (publicKey) {
  return axios.get(`/api/cryptocurrency-demo-service/wallet/${publicKey}`)
    .then(response => response.data)
    .then(data => {
      return {
        wallet: data,
        transactions: []
      }
    })
}
github exonum / exonum-java-binding / exonum-java-binding-cryptocurrency-demo / frontend / src / plugins / blockchain.js View on Github external
const PROTOCOL_VERSION = 0
const SERVICE_ID = 42
const TX_TRANSFER_ID = 2
const TX_WALLET_ID = 1
const SIGNATURE_LENGTH = 64
const PAYLOAD_SIZE_OFFSET = 6
const PER_PAGE = 10
const MAX_VALUE = 2147483647

const MessageHead = Exonum.newType({
  fields: [
    { name: 'network_id', type: Exonum.Uint8 },
    { name: 'protocol_version', type: Exonum.Uint8 },
    { name: 'message_id', type: Exonum.Uint16 },
    { name: 'service_id', type: Exonum.Uint16 },
    { name: 'payload', type: Exonum.Uint32 }
  ]
})

function getWallet (publicKey) {
  return axios.get(`/api/cryptocurrency-demo-service/wallet/${publicKey}`)
    .then(response => response.data)
    .then(data => {
      return {
        wallet: data,
        transactions: []
      }
    })
}

function waitForAcceptance (publicKey, hash) {
  let attempt = ATTEMPTS