Initial commit
This commit is contained in:
commit
f52d78da73
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,4 @@
|
|||
FROM node:7-onbuild
|
||||
|
||||
ENV PORT 8080
|
||||
EXPOSE 8080
|
|
@ -0,0 +1,45 @@
|
|||
const SignerProvider = require('ethjs-provider-signer');
|
||||
const sign = require('ethjs-signer').sign;
|
||||
const Eth = require('ethjs-query');
|
||||
|
||||
const address = process.env.ADDRESS
|
||||
|
||||
const provider = new SignerProvider(process.env.NODE, {
|
||||
signTransaction: (rawTx, cb) => cb(null, sign(rawTx, process.env.KEY)),
|
||||
accounts: (cb) => cb(null, [address]),
|
||||
});
|
||||
const eth = new Eth(provider);
|
||||
|
||||
var express = require('express')
|
||||
, cors = require('cors')
|
||||
, app = express();
|
||||
|
||||
var nonce = parseInt(process.env.NONCE || '1000')
|
||||
|
||||
app.use(cors());
|
||||
|
||||
app.get('/address/:address', function(req, res, next){
|
||||
nonce += 1;
|
||||
eth.sendTransaction({
|
||||
from: address,
|
||||
to: req.params.address,
|
||||
gas: 21500,
|
||||
value: 1e16,
|
||||
data: '0xde5f72fd', // sha3('faucet()')
|
||||
nonce,
|
||||
}, (err, txID) => {
|
||||
if (err) {
|
||||
console.log('Request failed', err)
|
||||
return res.status(500).json(err)
|
||||
}
|
||||
else {
|
||||
console.log('Successful request:', txID)
|
||||
res.json({ txID })
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const port = process.env.PORT || 8181
|
||||
app.listen(port, function(){
|
||||
console.log('Faucet listening on port', port);
|
||||
});
|
|
@ -0,0 +1,25 @@
|
|||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ '/usr/local/Cellar/node/7.4.0/bin/node',
|
||||
1 verbose cli '/usr/local/bin/npm',
|
||||
1 verbose cli 'start' ]
|
||||
2 info using npm@4.0.5
|
||||
3 info using node@v7.4.0
|
||||
4 verbose stack Error: missing script: start
|
||||
4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:151:19)
|
||||
4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:61:5
|
||||
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5
|
||||
4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45)
|
||||
4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3)
|
||||
4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5)
|
||||
4 verbose stack at ReadFileContext.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:295:20)
|
||||
4 verbose stack at ReadFileContext.callback (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16)
|
||||
4 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:336:13)
|
||||
5 verbose cwd /Users/jorge/provident/kovan-faucet
|
||||
6 error Darwin 16.4.0
|
||||
7 error argv "/usr/local/Cellar/node/7.4.0/bin/node" "/usr/local/bin/npm" "start"
|
||||
8 error node v7.4.0
|
||||
9 error npm v4.0.5
|
||||
10 error missing script: start
|
||||
11 error If you need help, you may report this error at:
|
||||
11 error <https://github.com/npm/npm/issues>
|
||||
12 verbose exit [ 1, true ]
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "kovan-faucet",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.1",
|
||||
"ethjs-provider-signer": "^0.1.4",
|
||||
"ethjs-query": "^0.2.4",
|
||||
"ethjs-signer": "^0.1.1",
|
||||
"express": "^4.15.2"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue