1
0

truffle.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 = 'local' // 'ubuntu' or 'centos' for remove disposition, 'local' for local test
  17. let ipAddr
  18. let keyPath
  19. if (env === 'local') {
  20. ipAddr = '127.0.0.1'
  21. keyPath = './private_key'
  22. } else if (env === 'ubuntu') {
  23. ipAddr = '10.108.39.133' // Lab
  24. keyPath = './private_key'
  25. } else if (env === 'centos') { // Problems remain
  26. ipAddr = '111.230.181.241' // Tencent cloud
  27. keyPath = './privateKey'
  28. }
  29. const chainId = 'default'
  30. const writeUrl = `http://${ipAddr}:46658/rpc`
  31. const readUrl = `http://${ipAddr}:46658/query`
  32. // ./privateKey file contains a base64 encoded key generated by the command:
  33. // loom genkey -a publicKey -k privateKey
  34. const privateKey = readFileSync(keyPath, 'utf-8')
  35. const loomTruffleProvider = new LoomTruffleProvider(chainId, writeUrl, readUrl, privateKey)
  36. // Create 10 extra accounts, useful for tests
  37. loomTruffleProvider.createExtraAccounts(10)
  38. module.exports = {
  39. // See <http://truffleframework.com/docs/advanced/configuration>
  40. // to customize your Truffle configuration!
  41. migrations_directory: './migrations',
  42. networks: {
  43. development: { // For windows only
  44. host: 'localhost',
  45. port: 7545,
  46. network_id: '*', // Match any network id
  47. gasPrice: 1,
  48. gas: 8000000,
  49. },
  50. loom: {
  51. host: ipAddr,
  52. provider: loomTruffleProvider,
  53. network_id: '*',
  54. },
  55. },
  56. }