How to use @waves/waves-transactions - 10 common examples

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 wavesplatform / WavesGUI / src / modules / fromBackup / controllers / FromBackupCtrl.js View on Github external
() => {
                            const fileData = libs.crypto
                                .bytesToString(libs.crypto.base64Decode(reader.result.split(',')[1]));

                            this.backup = FromBackupCtrl.parseUsers(fileData);
                            this.readError = null;
                        }
                    ).catch(() => {
github wavesplatform / WavesGUI / src / modules / utils / modals / exportAccounts / ExportAccounts.js View on Github external
onSubmit() {
                const users = Object.entries(this.checkedHash)
                    .filter(item => item[1])
                    .map(([address]) => this.userList.find(user => user.address === address));
                const stringifyUsers = JSON.stringify(users);
                const saveUsers = !this.needPassword ?
                    stringifyUsers :
                    encryptSeed(stringifyUsers, this.password, 10000);

                const saveData = {
                    encrypted: this.needPassword,
                    encryptionRounds: this.needPassword ? 10000 : undefined,
                    saveUsers
                };

                const dataToSaveInBytes = crypto.stringToBytes(JSON.stringify(saveData));

                saveData.hashSum = crypto.base58Encode(crypto.sha256(dataToSaveInBytes));

                const toSave = {
                    type: 'wavesBackup',
                    lastOpenVersion: this.settings.lastOpenVersion,
                    data: crypto.base64Encode(crypto.stringToBytes(JSON.stringify(saveData))),
                    checkSum: saveData.hashSum,
                    time: Date.now()
                };

                utils.downloadFile(`accountsBackup-${toSave.time}.json`, JSON.stringify(toSave, null, 4));
            }
github chainify / nolik / sponsor / server.js View on Github external
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});
    })
});
github wavesplatform / WavesGUI / src / modules / utils / modals / exportAccounts / ExportAccounts.js View on Github external
onSubmit() {
                const users = Object.entries(this.checkedHash)
                    .filter(item => item[1])
                    .map(([address]) => this.userList.find(user => user.address === address));
                const stringifyUsers = JSON.stringify(users);
                const saveUsers = !this.needPassword ?
                    stringifyUsers :
                    encryptSeed(stringifyUsers, this.password, 10000);

                const saveData = {
                    encrypted: this.needPassword,
                    encryptionRounds: this.needPassword ? 10000 : undefined,
                    saveUsers
                };

                const dataToSaveInBytes = crypto.stringToBytes(JSON.stringify(saveData));

                saveData.hashSum = crypto.base58Encode(crypto.sha256(dataToSaveInBytes));

                const toSave = {
                    type: 'wavesBackup',
                    lastOpenVersion: this.settings.lastOpenVersion,
                    data: crypto.base64Encode(crypto.stringToBytes(JSON.stringify(saveData))),
                    checkSum: saveData.hashSum,
github wavesplatform / WavesGUI / src / modules / utils / modals / exportAccounts / ExportAccounts.js View on Github external
const controller = function (Base, $scope, user, utils) {

        const { encryptSeed } = require('@waves/waves-transactions').seedUtils;
        const { crypto } = require('@waves/waves-transactions').libs;
        const { publicKey: getPublicKey, address: getAddress, base58Decode } = crypto;
        const checkAccount = (account) => {
            if (!account) {
                return false;
            }

            const { address, userType, networkByte } = account;

            let publicKey = '';


            switch (userType) {
                case 'seed':
                    try {
                        if (/^base58:/.test(account.seed)) {
                            publicKey = getPublicKey(base58Decode(account.seed.replace('base58:', '')));
github wavesplatform / WavesGUI / src / modules / utils / modals / exportAccounts / ExportAccounts.js View on Github external
const controller = function (Base, $scope, user, utils) {

        const { encryptSeed } = require('@waves/waves-transactions').seedUtils;
        const { crypto } = require('@waves/waves-transactions').libs;
        const { publicKey: getPublicKey, address: getAddress, base58Decode } = crypto;
        const checkAccount = (account) => {
            if (!account) {
                return false;
            }

            const { address, userType, networkByte } = account;

            let publicKey = '';


            switch (userType) {
                case 'seed':
                    try {
                        if (/^base58:/.test(account.seed)) {
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});
github wavesplatform / waveskeeper / src / controllers / Statistics.js View on Github external
static createUserId() {
        const date = Date.now();
        const random = Math.round(Math.random() * 1000000000);
        return libs.crypto.base58Encode(libs.crypto.sha256(libs.crypto.stringToBytes(`${date}-${random}`)));
    }
github wavesplatform / WavesGUI / src / modules / utils / modals / settings / SettingsCtrl.js View on Github external
]).then(([seed, privateKey, publicKey, encodedSeed]) => {

                    let canSeed = encodedSeed && seed && typeof seed === 'string';

                    try {
                        canSeed = canSeed && libs.crypto.stringToBytes(seed)
                            .join(',') === libs.crypto.base58Decode(encodedSeed).join(',');
                    } catch (e) {
                        canSeed = false;
                    }

                    this.phrase = canSeed ? seed : null;
                    this.encodedSeed = encodedSeed;
                    this.privateKey = privateKey;
                    this.publicKey = publicKey;
                    this.allowParing = canSeed;
                    $scope.$digest();
                });
            }
github wavesplatform / waveskeeper / src / ui / utils / waves.ts View on Github external
export function networkByteFromAddress(address: string): string {
    return String.fromCharCode(libs.crypto.base58Decode(address)[1]);
}