Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports.createEscrowContract = function(req, res) {
- //Set variables
- var challenger = "0xE6...";
- var participant = "0x4Ef...";
- var arbiter = "0xe5C...";
- //Compile contract
- var compiled = solc.compile(escrow);
- const web3 = new Web3();
- web3.setProvider(new
- web3.providers.HttpProvider("https://mainnet.infura.io/XXXX"));
- //Store bytecode
- var bytecode = compiled.contracts[':Escrow'].bytecode;
- //Store abi
- var abi = JSON.parse(compiled.contracts[':Escrow'].interface);
- var escrowContract = web3.eth.contract(abi);
- console.log(escrowContract);
- //Prints something that looks contract-like.
- //Deploy contract
- var deployed = escrowContract.new(participant, arbiter, {
- from: challenger,
- data: bytecode,
- gas: 47000000,
- gasPrice: 50,
- value: 0
- }, (error, contract) => {
- console.log(error);
- //{{Invalid JSON RPC response: ""}}
- console.log(contract);
- //undefined
- });
Add Comment
Please, Sign In to add comment