Skip to content

Commit

Permalink
finish project
Browse files Browse the repository at this point in the history
  • Loading branch information
shreymehta91 committed May 13, 2018
1 parent 9a3622f commit a3588b4
Show file tree
Hide file tree
Showing 4 changed files with 906 additions and 50 deletions.
28 changes: 28 additions & 0 deletions deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const HDWAlletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const {interface, bytecode} = require('./compile');

const provider = new HDWAlletProvider(
'will local problem govern armor risk icon pioneer hospital clock beef dust',
'https://rinkeby.infura.io/ncPX8dwwzFDA8pywepNB'
)

const web3 = new Web3(provider);

const deploy = async() => {
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account', accounts[0])

const result = await new web3.eth.Contract(JSON.parse(interface))
.deploy({ data: '0x' + bytecode, arguments: ['Hi there']})
.send({
gas: '1000000',
from: accounts[0],
gasPrice: web3.utils.toWei('2', 'gwei')
});

console.log('contract deployed to ', result.options.address);

};

deploy();
2 changes: 2 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
* `deploy` function on contract object tells web3 to deploy the copy of contract on the network. It takes in an object such as.
```{data: bytecode, arguments: [arg1, arg2]}```
* `deploy` function doesnot actually deploy contract. It creates an object to deploy after using `send` function

* Inbox contract deployed at `0x73A22D84906c6074593388744bc8C95289f67833`
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"test": "mocha"
"test": "mocha"
},
"dependencies": {
"ganache-cli": "^6.1.0",
"mocha": "^5.1.1",
"solc": "^0.4.23",
"truffle-hdwallet-provider": "^0.0.5",
"web3": "1.0.0-beta.26"
}
}
Loading

0 comments on commit a3588b4

Please sign in to comment.