How to use the web3-core-helpers.formatters.toWei function in web3-core-helpers

To help you get started, we’ve selected a few web3-core-helpers 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 ubiq / shokku / test / jsonrpc.e2e-spec.ts View on Github external
async setupBlockchain() {
    // Connect to Ganache
    const domain = `${process.env.API_TESTS_GANACHE_HOST}:${process.env.API_TESTS_GANACHE_PORT}`
    this.web3 = new Web3(new Web3.providers.HttpProvider(domain))

    const accounts = this.opts.accounts

    // Generate fake transactions of money to create at least three blocks
    const tx1 = {
      from: accounts[0].address,
      to: accounts[1].address,
      value: formatters.toWei('1', 'ether')
    }
    await this.web3.eth.sendTransaction(tx1).catch(e => e)

    const tx2 = {
      from: accounts[2].address,
      to: accounts[1].address,
      value: formatters.toWei('50', 'ether')
    }
    await this.web3.eth.sendTransaction(tx2).catch(e => e)

    const tx3 = {
      from: accounts[2].address,
      to: accounts[0].address,
      value: formatters.toWei('200', 'ether')
    }
    await this.web3.eth.sendTransaction(tx3).catch(e => e)
github ubiq / shokku / test / jsonrpc.e2e-spec.ts View on Github external
this.web3 = new Web3(new Web3.providers.HttpProvider(domain))

    const accounts = this.opts.accounts

    // Generate fake transactions of money to create at least three blocks
    const tx1 = {
      from: accounts[0].address,
      to: accounts[1].address,
      value: formatters.toWei('1', 'ether')
    }
    await this.web3.eth.sendTransaction(tx1).catch(e => e)

    const tx2 = {
      from: accounts[2].address,
      to: accounts[1].address,
      value: formatters.toWei('50', 'ether')
    }
    await this.web3.eth.sendTransaction(tx2).catch(e => e)

    const tx3 = {
      from: accounts[2].address,
      to: accounts[0].address,
      value: formatters.toWei('200', 'ether')
    }
    await this.web3.eth.sendTransaction(tx3).catch(e => e)

    if (process.env.API_TESTS_GANACHE_COMPILE_SC === 'true') {
      // Compile BeerToken smart contract
      const inputs = {}
      const contracts = ['BeerToken.sol', 'SafeMath.sol', 'StandardToken.sol', 'ERC20.sol', 'ERC20Basic.sol', 'BasicToken.sol']
      contracts.forEach(contract => {
        inputs[contract] = fs.readFileSync(`${__dirname}/contracts/${contract}`, 'utf8')
github ubiq / shokku / test / jsonrpc.e2e-spec.ts View on Github external
to: accounts[1].address,
      value: formatters.toWei('1', 'ether')
    }
    await this.web3.eth.sendTransaction(tx1).catch(e => e)

    const tx2 = {
      from: accounts[2].address,
      to: accounts[1].address,
      value: formatters.toWei('50', 'ether')
    }
    await this.web3.eth.sendTransaction(tx2).catch(e => e)

    const tx3 = {
      from: accounts[2].address,
      to: accounts[0].address,
      value: formatters.toWei('200', 'ether')
    }
    await this.web3.eth.sendTransaction(tx3).catch(e => e)

    if (process.env.API_TESTS_GANACHE_COMPILE_SC === 'true') {
      // Compile BeerToken smart contract
      const inputs = {}
      const contracts = ['BeerToken.sol', 'SafeMath.sol', 'StandardToken.sol', 'ERC20.sol', 'ERC20Basic.sol', 'BasicToken.sol']
      contracts.forEach(contract => {
        inputs[contract] = fs.readFileSync(`${__dirname}/contracts/${contract}`, 'utf8')
      })
      const out = solc.compile({
        sources: inputs
      }, 1)

      const bytecode = out.contracts['BeerToken.sol:BeerToken'].bytecode
      const abi = JSON.parse(out.contracts['BeerToken.sol:BeerToken'].interface)
github ubiq / shokku / test / jsonrpc.e2e-spec.ts View on Github external
constructor() {
    this.opts = {
      network_id: 88,
      hdPath: "m/44'/108'/0'/0/",
      nmemonic: 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat',
      locked: false,
      gasPrice: '0x4A817C800',
      accounts: [{
        address: '0x627306090abaB3A6e1400e9345bC60c78a8BEf57',
        secretKey: '0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',
        balance: formatters.toWei('100000', 'ether')
      },
      {
        address: '0xf17f52151EbEF6C7334FAD080c5704D77216b732',
        secretKey: '0xf9b2d466cfe82a6e9209bb87dd0de7e63fe893d7625160c9fc663452b52eaa06',
        balance: formatters.toWei('10000', 'ether')
      },
      {
        address: '0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef',
        secretKey: '0x109d8195d7a1b7e00d3538bafc0f23af2c6e6482b8cc780a10264284779a7adb',
        balance: formatters.toWei('1000', 'ether')
      }
      ]
    }
    this.server = Ganache.server(this.opts)
    this.contracts = {}
    this.blocks = {}
  }
github ubiq / shokku / test / jsonrpc.e2e-spec.ts View on Github external
locked: false,
      gasPrice: '0x4A817C800',
      accounts: [{
        address: '0x627306090abaB3A6e1400e9345bC60c78a8BEf57',
        secretKey: '0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',
        balance: formatters.toWei('100000', 'ether')
      },
      {
        address: '0xf17f52151EbEF6C7334FAD080c5704D77216b732',
        secretKey: '0xf9b2d466cfe82a6e9209bb87dd0de7e63fe893d7625160c9fc663452b52eaa06',
        balance: formatters.toWei('10000', 'ether')
      },
      {
        address: '0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef',
        secretKey: '0x109d8195d7a1b7e00d3538bafc0f23af2c6e6482b8cc780a10264284779a7adb',
        balance: formatters.toWei('1000', 'ether')
      }
      ]
    }
    this.server = Ganache.server(this.opts)
    this.contracts = {}
    this.blocks = {}
  }
github ubiq / shokku / test / jsonrpc.e2e-spec.ts View on Github external
constructor() {
    this.opts = {
      network_id: 88,
      hdPath: "m/44'/108'/0'/0/",
      nmemonic: 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat',
      locked: false,
      gasPrice: '0x4A817C800',
      accounts: [{
        address: '0x627306090abaB3A6e1400e9345bC60c78a8BEf57',
        secretKey: '0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3',
        balance: formatters.toWei('100000', 'ether')
      },
      {
        address: '0xf17f52151EbEF6C7334FAD080c5704D77216b732',
        secretKey: '0xf9b2d466cfe82a6e9209bb87dd0de7e63fe893d7625160c9fc663452b52eaa06',
        balance: formatters.toWei('10000', 'ether')
      },
      {
        address: '0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef',
        secretKey: '0x109d8195d7a1b7e00d3538bafc0f23af2c6e6482b8cc780a10264284779a7adb',
        balance: formatters.toWei('1000', 'ether')
      }
      ]
    }
    this.server = Ganache.server(this.opts)
    this.contracts = {}
    this.blocks = {}