1
0

truffle.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a
  3. * function when declaring them. Failure to do so will cause commands to hang. ex:
  4. * ```
  5. * mainnet: {
  6. * provider: function() {
  7. * return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>')
  8. * },
  9. * network_id: '1',
  10. * gas: 4500000,
  11. * gasPrice: 10000000000,
  12. * },
  13. */
  14. const { readFileSync } = require('fs')
  15. const LoomTruffleProvider = require('loom-truffle-provider')
  16. const env = 'remote' // 'remote' for remove disposition, 'local' for local test
  17. let ipAddr
  18. if (env === 'local') {
  19. ipAddr = '127.0.0.1'
  20. } else if (env === 'remote') {
  21. ipAddr = '10.108.39.133'
  22. }
  23. const chainId = 'default'
  24. const writeUrl = `http://${ipAddr}:46658/rpc`
  25. const readUrl = `http://${ipAddr}:46658/query`
  26. // ./privateKey file contains a base64 encoded key generated by the command:
  27. // loom genkey -a publicKey -k privateKey
  28. // const privateKey = readFileSync('./privateKey', 'utf-8') // For Tencent cloud
  29. const privateKey = readFileSync('./private_key', 'utf-8') // For Ubuntu
  30. const loomTruffleProvider = new LoomTruffleProvider(chainId, writeUrl, readUrl, privateKey)
  31. // Create 10 extra accounts, useful for tests
  32. loomTruffleProvider.createExtraAccounts(10)
  33. module.exports = {
  34. // See <http://truffleframework.com/docs/advanced/configuration>
  35. // to customize your Truffle configuration!
  36. migrations_directory: './migrations',
  37. networks: {
  38. development: {
  39. host: 'localhost',
  40. port: 7545,
  41. network_id: '*', // Match any network id
  42. gasPrice: 1,
  43. gas: 8000000,
  44. },
  45. loom_dapp_chain: {
  46. host: ipAddr,
  47. provider: loomTruffleProvider,
  48. network_id: '*',
  49. },
  50. },
  51. }