Guest User

Untitled

a guest
Jan 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. module.exports.createEscrowContract = function(req, res) {
  2. //Set variables
  3. var challenger = "0xE6...";
  4. var participant = "0x4Ef...";
  5. var arbiter = "0xe5C...";
  6.  
  7. //Compile contract
  8. var compiled = solc.compile(escrow);
  9.  
  10. const web3 = new Web3();
  11. web3.setProvider(new
  12. web3.providers.HttpProvider("https://mainnet.infura.io/XXXX"));
  13.  
  14. //Store bytecode
  15. var bytecode = compiled.contracts[':Escrow'].bytecode;
  16.  
  17. //Store abi
  18. var abi = JSON.parse(compiled.contracts[':Escrow'].interface);
  19.  
  20. var escrowContract = web3.eth.contract(abi);
  21.  
  22. console.log(escrowContract);
  23.  
  24. //Prints something that looks contract-like.
  25.  
  26. //Deploy contract
  27. var deployed = escrowContract.new(participant, arbiter, {
  28. from: challenger,
  29. data: bytecode,
  30. gas: 47000000,
  31. gasPrice: 50,
  32. value: 0
  33. }, (error, contract) => {
  34. console.log(error);
  35. //{{Invalid JSON RPC response: ""}}
  36. console.log(contract);
  37. //undefined
  38. });
Add Comment
Please, Sign In to add comment