How to use the @waves/waves-transactions.transfer function in @waves/waves-transactions

To help you get started, we’ve selected a few @waves/waves-transactions 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 chainify / nolik / sponsor / server.js View on Github external
if (!ipfsHash) {
    res.status(400);
    res.json({ message: 'IPFS Hash is not provided' })
  }

  const bytes = Uint8Array.from(publicKey);
  const verified = verifySignature(publicKey, bytes, signature);

  if (verified === false) {
    res.status(403);
    res.json({ message: 'Signature is not valid' });
  }

  const recipient = process.env.NETWORK === 'testnet' ? address(process.env.SPONSOR_SEED, 'T') : address(process.env.SPONSOR_SEED);
  const signedTranserTx = transfer({ 
    amount: 1,
    recipient: recipient,
    assetId: process.env.ASSET_ID,
    feeAssetId: process.env.ASSET_ID,
    chainId: process.env.NETWORK === 'testnet' ? 'T' : 'W',
    attachment: Base58.encode(Buffer.from(ipfsHash))
  }, process.env.SPONSOR_SEED);

  broadcast(signedTranserTx, process.env.NODE_URL)
    .then(tx => {
      res.json({tx: tx});
    })
    .catch(e => {
      console.log('Error', e);
      res.status(400)
      res.json({'error': e.message});