How to use the @0x/web3-wrapper.Web3Wrapper.toWei function in @0x/web3-wrapper

To help you get started, we’ve selected a few @0x/web3-wrapper 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 0xProject / 0x-monorepo / packages / testnet-faucets / src / ts / dispense_asset_tasks.ts View on Github external
return async () => {
            logUtils.log(`Processing ETH ${recipientAddress}`);
            const userBalance = await web3Wrapper.getBalanceInWeiAsync(recipientAddress);
            const maxAmountInWei = Web3Wrapper.toWei(new BigNumber(DISPENSE_MAX_AMOUNT_ETHER));
            if (userBalance.isGreaterThanOrEqualTo(maxAmountInWei)) {
                logUtils.log(
                    `User exceeded ETH balance maximum (${maxAmountInWei}) ${recipientAddress} ${userBalance} `,
                );
                return;
            }
            const txHash = await web3Wrapper.sendTransactionAsync({
                from: configs.DISPENSER_ADDRESS,
                to: recipientAddress,
                value: Web3Wrapper.toWei(new BigNumber(DISPENSE_AMOUNT_ETHER)),
            });
            logUtils.log(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
        };
    },
github 0xProject / 0x-monorepo / packages / testnet-faucets / src / ts / dispense_asset_tasks.ts View on Github external
return async () => {
            logUtils.log(`Processing ETH ${recipientAddress}`);
            const userBalance = await web3Wrapper.getBalanceInWeiAsync(recipientAddress);
            const maxAmountInWei = Web3Wrapper.toWei(new BigNumber(DISPENSE_MAX_AMOUNT_ETHER));
            if (userBalance.isGreaterThanOrEqualTo(maxAmountInWei)) {
                logUtils.log(
                    `User exceeded ETH balance maximum (${maxAmountInWei}) ${recipientAddress} ${userBalance} `,
                );
                return;
            }
            const txHash = await web3Wrapper.sendTransactionAsync({
                from: configs.DISPENSER_ADDRESS,
                to: recipientAddress,
                value: Web3Wrapper.toWei(new BigNumber(DISPENSE_AMOUNT_ETHER)),
            });
            logUtils.log(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
        };
    },