How to use the web3-utils.randomHex function in web3-utils

To help you get started, we’ve selected a few web3-utils 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 iExecBlockchainComputing / PoCo / test-old / 07_workerContribute.sgx.js View on Github external
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
		txMined = await aIexecHubInstance.createApp("R Clifford Attractors", 0, constants.DAPP_PARAMS_EXAMPLE, {
			from: appProvider
		});
		appAddress = await aAppHubInstance.getApp(appProvider, 1);
		aAppInstance = await App.at(appAddress);

		//Create ask Marker Orders
		// ==================================================================
		commonOrder.category = 1;
		commonOrder.trust    = 0;
		commonOrder.value    = 100;
		// ==================================================================
		poolOrder.volume     = 1
		poolOrder.workerpool = aWorkerPoolInstance.address;
		poolOrder.salt       = web3utils.randomHex(32);
		// ------------------------------------------------------------------
		poolOrder.hash = Extensions.poolOrderHashing(
			aMarketplaceInstance.address,
			commonOrder.category,
			commonOrder.trust,
			commonOrder.value,
			poolOrder.volume,
			poolOrder.workerpool,
			poolOrder.salt
		);
		poolOrder.sig = Extensions.signHash(scheduleProvider, poolOrder.hash)
		// ==================================================================
		userOrder.app         = aAppInstance.address;
		userOrder.dataset     = '0x0000000000000000000000000000000000000000';
		userOrder.callback    = '0x0000000000000000000000000000000000000000';
		userOrder.beneficiary = iExecCloudUser;
github iExecBlockchainComputing / PoCo / test-old / 09_revealContribution.js View on Github external
assert.isBelow(txMined.receipt.gasUsed, constants.AMOUNT_GAS_PROVIDED, "should not use all gas");
		txMined = await aIexecHubInstance.createApp("R Clifford Attractors", 0, constants.DAPP_PARAMS_EXAMPLE, {
			from: appProvider
		});
		appAddress = await aAppHubInstance.getApp(appProvider, 1);
		aAppInstance = await App.at(appAddress);

		//Create ask Marker Orders
		// ==================================================================
		commonOrder.category = 1;
		commonOrder.trust    = 0;
		commonOrder.value    = 100;
		// ==================================================================
		poolOrder.volume     = 1
		poolOrder.workerpool = aWorkerPoolInstance.address;
		poolOrder.salt       = web3utils.randomHex(32);
		// ------------------------------------------------------------------
		poolOrder.hash = Extensions.poolOrderHashing(
			aMarketplaceInstance.address,
			commonOrder.category,
			commonOrder.trust,
			commonOrder.value,
			poolOrder.volume,
			poolOrder.workerpool,
			poolOrder.salt
		);
		poolOrder.sig = Extensions.signHash(scheduleProvider, poolOrder.hash)
		// ==================================================================
		userOrder.app         = aAppInstance.address;
		userOrder.dataset     = '0x0000000000000000000000000000000000000000';
		userOrder.callback    = '0x0000000000000000000000000000000000000000';
		userOrder.beneficiary = iExecCloudUser;
github urbit / bridge / src / views / Admin / AdminNetworkingKeys.js View on Github external
const newNetworkRevision = networkRevision + 1;
        console.log(`deriving seed with revision ${newNetworkRevision}`);

        const networkSeed = await attemptNetworkSeedDerivation({
          urbitWallet,
          wallet,
          authMnemonic,
          details: _details,
          revision: newNetworkRevision,
        });

        if (Just.hasInstance(networkSeed)) {
          return networkSeed.value;
        }

        randomSeed.current = randomSeed.current || randomHex(32); // 32 bytes
        setNdNetworkSeed(randomSeed.current);

        return randomSeed.current;
      }
    },
    [_details, authMnemonic, networkRevision, urbitWallet, wallet]
github likecoin / likecoin-contracts / test / gas.js View on Github external
from, addrs, values, maxReward, claimedReward,
      nonce, signature, { from: accounts[1] },
    );
    console.log(`transferMultipleDelegated, count = ${addrs.length}, first time gas used = ${callResult.receipt.gasUsed}`);
    nonce = web3Utils.randomHex(32);
    signature =
      signTransferMultipleDelegated(like.address, addrs, values, maxReward, nonce, privKey);
    callResult = await like.transferMultipleDelegated(
      from, addrs, values, maxReward, claimedReward,
      nonce, signature, { from: accounts[1] },
    );
    console.log(`transferMultipleDelegated, count = ${addrs.length}, second time gas used = ${callResult.receipt.gasUsed}`);

    addrs = [9].map(i => accounts[i]);
    values = [9].map(n => coinsToCoinUnits(n * 100));
    nonce = web3Utils.randomHex(32);
    signature =
      signTransferMultipleDelegated(like.address, addrs, values, maxReward, nonce, privKey);
    callResult = await like.transferMultipleDelegated(
      from, addrs, values, maxReward, claimedReward,
      nonce, signature, { from: accounts[1] },
    );
    console.log(`transferMultipleDelegated, count = ${addrs.length}, first time gas used = ${callResult.receipt.gasUsed}`);
    nonce = web3Utils.randomHex(32);
    signature =
      signTransferMultipleDelegated(like.address, addrs, values, maxReward, nonce, privKey);
    callResult = await like.transferMultipleDelegated(
      from, addrs, values, maxReward, claimedReward,
      nonce, signature, { from: accounts[1] },
    );
    console.log(`transferMultipleDelegated, count = ${addrs.length}, second time gas used = ${callResult.receipt.gasUsed}`);
  });
github likecoin / likecoin-contracts / test / likecoin.js View on Github external
from, to, value, data, maxReward, claimedReward,
        nonce, signature, { from: caller },
      );
    }, 'should forbid transferring with different data from signature');

    nonce = web3Utils.randomHex(32);
    signature =
      signTransferAndCallDelegated(like.address, to, value, data, maxReward.add(1), nonce, privKey);
    await utils.assertSolidityThrow(async () => {
      await like.transferAndCallDelegated(
        from, to, value, data, maxReward, claimedReward,
        nonce, signature, { from: caller },
      );
    }, 'should forbid transferring with different maxReward from signature');

    nonce = web3Utils.randomHex(32);
    signature =
      signTransferAndCallDelegated(like.address, to, value, data, maxReward, nonce, privKey);
    await utils.assertSolidityThrow(async () => {
      await like.transferAndCallDelegated(
        from, to, value, data, maxReward, claimedReward,
        web3Utils.randomHex(32), signature, { from: caller },
      );
    }, 'should forbid transferring with different nonce from signature');

    nonce = web3Utils.randomHex(32);
    signature = signTransferAndCallDelegated(
      like.address, to, value, data, maxReward,
      nonce, Accounts[1].secretKey,
    );
    await utils.assertSolidityThrow(async () => {
      await like.transferAndCallDelegated(
github likecoin / likecoin-contracts / test / likecoin.js View on Github external
);
    }, 'should forbid transferring with different nonce from signature');

    nonce = web3Utils.randomHex(32);
    signature = signTransferAndCallDelegated(
      like.address, to, value, data, maxReward,
      nonce, Accounts[1].secretKey,
    );
    await utils.assertSolidityThrow(async () => {
      await like.transferAndCallDelegated(
        from, to, value, data, maxReward, claimedReward,
        nonce, signature, { from: caller },
      );
    }, 'should forbid transferring with wrong signing key');

    signature = web3Utils.randomHex(65);
    await utils.assertSolidityThrow(async () => {
      await like.transferAndCallDelegated(
        from, to, value, data, maxReward, claimedReward,
        nonce, signature, { from: caller },
      );
    }, 'should forbid transferring with random signature');

    nonce = web3Utils.randomHex(32);
    signature =
      signTransferAndCallDelegated(like.address, to, value, data, maxReward, nonce, privKey);
    await like.transferAndCallDelegated(
      from, to, value, data, maxReward, claimedReward,
      nonce, signature, { from: caller },
    );
  });
github embark-framework / embark / packages / embark-profiler / src / fuzzer.js View on Github external
generateRandomInt(size) {
    return utils.toBN(utils.randomHex(parseInt(size, 10) / 8)).toString();
  }
github 0xbitcoin / tokenpool / lib / token-interface.js View on Github external
var minPayoutWalletBalance = poolConfig.payoutWalletMinimum; //this is in token-satoshis

      if(minPayoutWalletBalance == null)
      {
        minPayoutWalletBalance = 1000*100000000;
      }

      var payoutWalletAddress =  this.getPaymentAccount().address;
      var mintingWalletAddress =  this.getMintingAccount().address;

      var payoutWalletBalance = await this.getTokenBalanceOf(payoutWalletAddress)
      var mintingWalletBalance = await this.getTokenBalanceOf(mintingWalletAddress)

      var balancePaymentId = web3Utils.randomHex(32);


      if( payoutWalletBalance < minPayoutWalletBalance
      && mintingWalletBalance >= minPayoutWalletBalance )
      {


        //queue a new transfer from the minting wallet to the payout wallet
          await this.queueTokenTransfer('minting', payoutWalletAddress, minPayoutWalletBalance, balancePaymentId)

      }


      var self = this;
      setTimeout(function(){ self.transferMinimumTokensToPayoutWallet()}, 5*60*1000) //every five minutes
github embark-framework / embark / src / lib / modules / profiler / fuzzer.js View on Github external
generateRandomAddress() {
    return utils.randomHex(20);
  }
}