Skip to content
Snippets Groups Projects
Commit 8be23093 authored by Renzo Mauro Ontivero's avatar Renzo Mauro Ontivero
Browse files

Habilitando red Rinkeby

parent eb660627
No related branches found
No related tags found
No related merge requests found
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
const Web3 = require('web3'); const Web3 = require('web3');
const Tx = require('ethereumjs-tx'); const Tx = require('ethereumjs-tx');
const url = sails.config.custom.urlRpc; const url = sails.config.custom.urlRpcRopsten;
const web3 = new Web3(url); const web3 = new Web3(url);
const accountAddress = sails.config.custom.accountAddress; const accountAddressRopsten = sails.config.custom.accountAddressRopsten;
const contractABI = sails.config.custom.contractABI; const contractABIRopsten = sails.config.custom.contractABIRopsten;
const contractAddress = sails.config.custom.contractAddress; const contractAddressRopsten = sails.config.custom.contractAddressRopsten;
const privateKey = Buffer.from( const privateKeyRopsten = Buffer.from(
sails.config.custom.privateKey, sails.config.custom.privateKeyRopsten,
'hex', 'hex',
); );
const contract = new web3.eth.Contract(contractABI, contractAddress); const contract = new web3.eth.Contract(contractABIRopsten, contractAddressRopsten);
module.exports = { module.exports = {
create : async function (req, res){ create : async function (req, res){
......
/**
* BfaController
*
* @description :: Server-side actions for handling incoming requests.
* @help :: See https://sailsjs.com/docs/concepts/actions
*/
const Web3 = require('web3');
const Tx = require('ethereumjs-tx');
const base64 = require('nodejs-base64-encode');
const url = sails.config.custom.urlRpcRopsten;
const web3 = new Web3(url);
const accountAddress = sails.config.custom.accountAddressRopsten;
const contractABI = sails.config.custom.contractABIRopsten;
const contractAddress = sails.config.custom.contractAddressRopsten;
const privateKey = Buffer.from(
sails.config.custom.privateKeyRopsten,
'hex',
);
const contract = new web3.eth.Contract(contractABI, contractAddress);
module.exports = {
verify : async function (req, res){
sails.log("Verify("+req.params.ots+", "+req.params.file_hash+")");
const file_hash = req.params.file_hash;
const base64_ots = req.params.ots;
// Transformo datos
const aux_ots = base64.decode(base64_ots.toString(), 'base64');
var array_ots = aux_ots.split('-');
// OTS definitivo
var permanent_ots;
if(array_ots.length != 2){
return res.json('El OTS enviado es inválido');
}
const ots = array_ots[0]; // Este es el OpenTimeStamp (OTS) original creado en el método stamp() con el helper getOts(); Es un ID único para cada request.
const tx_hash = array_ots[1]; // Hash de la TX obtenida de la blockchain
// Antes de verificar el contenido del OTS y el HASH
// Verifico el estado de la transacción
var tx = await web3.eth.getTransaction(tx_hash, async (err, _tx) => {
if(err){
return res.json(err.toString());
}
// Significa que la TX aún no se incluye en un bloque.
if(!_tx.blockNumber){
return res.json({
status : 'pending',
tx_hash : tx_hash,
file_hash : file_hash,
ots : ots,
msg : 'La Transacción aún no es incluida en un Bloque. Intente nuevamente en unos minutos.'
});
}
// Verifico si el OTS + File_Hash enviado son válidos
const result_verify = await sails.helpers.verifyHash(ots, file_hash, url, accountAddress, contractABI, contractAddress, privateKey);
if(result_verify){
const block_number = await sails.helpers.getBlockNumber(ots, url, contractABI, contractAddress);
// Tengo que obtener el bloque entero, para sacar su timestamp
const block = await sails.helpers.getBlock(block_number, url);
return res.json({
status : 'success',
tx_hash : tx_hash,
block_number : block_number,
file_hash : file_hash,
ots : ots,
contract_address: contractAddress,
timestamp : block.timestamp,
block_hash : block.hash
});
} else {
var file_hash_by_ots = await sails.helpers.getHash(ots, accountAddress, contractAddress);
return res.json({
status : 'fail',
file_hash_by_ots : file_hash_by_ots,
file_hash_send : file_hash,
tx_hash : tx_hash,
ots : ots,
msg : 'El HASH del archivo enviado no se corresponde con el OTS.'
});
}
});
},
stamp : async function (req, res){
sails.log("Stamp("+req.body.file_hash+")");
const file_hash = req.body.file_hash;
// A partir del Hash recibido, genero el OpenTimeStamp (OTS)
const ots = await sails.helpers.getOts(file_hash, accountAddress, contractAddress);
var comprobante_ots;
web3.eth.getTransactionCount(accountAddress, (err, txCount) => {
const data = contract.methods.stamp(ots, file_hash).encodeABI();
// Construir la transaccion
const txObject = {
nonce: web3.utils.toHex(txCount),
to: contractAddress,
gasLimit: web3.utils.toHex(800000),
// TODO: revisar que el precio sea automático
gasPrice: web3.utils.toHex(web3.utils.toWei('1000', 'gwei')),
data: data
}
// Firmar la transaccion
const tx = new Tx(txObject);
tx.sign(privateKey);
const serializeTransaction = tx.serialize();
const raw = '0x' + serializeTransaction.toString('hex');
// Transmitir la transacción
web3.eth.sendSignedTransaction(raw, (err, tx_hash) => {
if(err){
return res.json(err.toString());
}
comprobante_ots = ots + '-' + tx_hash;
// Si está todo bien, retorno el OpenTimeStamp definitivo para luego comprobar si el hash del archivo junto con este comprobante son válidos
comprobante_ots = base64.encode(comprobante_ots.toString(), 'base64');
return res.json({
comprobante_ots : comprobante_ots,
tx_hash : tx_hash
});
});
});
},
};
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
const Web3 = require('web3'); const Web3 = require('web3');
const Tx = require('ethereumjs-tx'); const Tx = require('ethereumjs-tx');
const base64 = require('nodejs-base64-encode'); const base64 = require('nodejs-base64-encode');
const url = sails.config.custom.urlRpc; const url = sails.config.custom.urlRpcRopsten;
const web3 = new Web3(url); const web3 = new Web3(url);
const accountAddress = sails.config.custom.accountAddress; const accountAddress = sails.config.custom.accountAddressRopsten;
const contractABI = sails.config.custom.contractABI; const contractABI = sails.config.custom.contractABIRopsten;
const contractAddress = sails.config.custom.contractAddress; const contractAddress = sails.config.custom.contractAddressRopsten;
const privateKey = Buffer.from( const privateKey = Buffer.from(
sails.config.custom.privateKey, sails.config.custom.privateKeyRopsten,
'hex', 'hex',
); );
const contract = new web3.eth.Contract(contractABI, contractAddress); const contract = new web3.eth.Contract(contractABI, contractAddress);
...@@ -23,7 +23,7 @@ module.exports = { ...@@ -23,7 +23,7 @@ module.exports = {
verify : async function (req, res){ verify : async function (req, res){
sails.log("Verify("+req.params.ots+", "+req.params.file_hash+")"); sails.log("Verify("+req.params.ots+", "+req.params.file_hash+")");
const file_hash = req.params.file_hash; const file_hash = req.params.file_hash;
const base64_ots = req.params.ots; const base64_ots = req.params.ots;
// Transformo datos // Transformo datos
const aux_ots = base64.decode(base64_ots.toString(), 'base64'); const aux_ots = base64.decode(base64_ots.toString(), 'base64');
...@@ -58,18 +58,15 @@ module.exports = { ...@@ -58,18 +58,15 @@ module.exports = {
} }
// Verifico si el OTS + File_Hash enviado son válidos // Verifico si el OTS + File_Hash enviado son válidos
const result_verify = await sails.helpers.verifyHash.with({ const result_verify = await sails.helpers.verifyHash(ots, file_hash, url, accountAddress, contractABI, contractAddress, privateKey);
ots: ots,
file_hash: file_hash,
});
if(result_verify){ if(result_verify){
const block_number = await sails.helpers.getBlockNumber(ots); const block_number = await sails.helpers.getBlockNumber(ots, url, contractABI, contractAddress);
// Tengo que obtener el bloque entero, para sacar su timestamp // Tengo que obtener el bloque entero, para sacar su timestamp
const block = await sails.helpers.getBlock(block_number); const block = await sails.helpers.getBlock(block_number, url);
return res.json({ return res.json({
status : 'success', status : 'success',
...@@ -83,7 +80,7 @@ module.exports = { ...@@ -83,7 +80,7 @@ module.exports = {
}); });
} else { } else {
var file_hash_by_ots = await sails.helpers.getHash(ots); var file_hash_by_ots = await sails.helpers.getHash(ots, accountAddress, contractAddress);
return res.json({ return res.json({
status : 'fail', status : 'fail',
...@@ -105,7 +102,7 @@ module.exports = { ...@@ -105,7 +102,7 @@ module.exports = {
sails.log("Stamp("+req.body.file_hash+")"); sails.log("Stamp("+req.body.file_hash+")");
const file_hash = req.body.file_hash; const file_hash = req.body.file_hash;
// A partir del Hash recibido, genero el OpenTimeStamp (OTS) // A partir del Hash recibido, genero el OpenTimeStamp (OTS)
const ots = await sails.helpers.getOts(file_hash); const ots = await sails.helpers.getOts(file_hash, accountAddress, contractAddress);
var comprobante_ots; var comprobante_ots;
web3.eth.getTransactionCount(accountAddress, (err, txCount) => { web3.eth.getTransactionCount(accountAddress, (err, txCount) => {
......
/**
* Rinkebyontroller
*
* @description :: Server-side actions for handling incoming requests.
* @help :: See https://sailsjs.com/docs/concepts/actions
*/
const Web3 = require('web3');
const Tx = require('ethereumjs-tx');
const base64 = require('nodejs-base64-encode');
const url = sails.config.custom.urlRpcRinkeby;
const web3 = new Web3(url);
const accountAddress = sails.config.custom.accountAddressRinkeby;
const contractABI = sails.config.custom.contractABIRinkeby;
const contractAddress = sails.config.custom.contractAddressRinkeby;
const privateKey = Buffer.from(
sails.config.custom.privateKeyRinkeby,
'hex',
);
const contract = new web3.eth.Contract(contractABI, contractAddress);
module.exports = {
verify : async function (req, res){
sails.log("Verify("+req.params.ots+", "+req.params.file_hash+")");
const file_hash = req.params.file_hash;
const base64_ots = req.params.ots;
// Transformo datos
const aux_ots = base64.decode(base64_ots.toString(), 'base64');
var array_ots = aux_ots.split('-');
// OTS definitivo
var permanent_ots;
if(array_ots.length != 2){
return res.json('El OTS enviado es inválido');
}
const ots = array_ots[0]; // Este es el OpenTimeStamp (OTS) original creado en el método stamp() con el helper getOts(); Es un ID único para cada request.
const tx_hash = array_ots[1]; // Hash de la TX obtenida de la blockchain
// Antes de verificar el contenido del OTS y el HASH
// Verifico el estado de la transacción
var tx = await web3.eth.getTransaction(tx_hash, async (err, _tx) => {
if(err){
return res.json(err.toString());
}
// Significa que la TX aún no se incluye en un bloque.
if(!_tx.blockNumber){
return res.json({
status : 'pending',
tx_hash : tx_hash,
file_hash : file_hash,
ots : ots,
msg : 'La Transacción aún no es incluida en un Bloque. Intente nuevamente en unos minutos.'
});
}
// Verifico si el OTS + File_Hash enviado son válidos
const result_verify = await sails.helpers.verifyHash(ots, file_hash, url, accountAddress, contractABI, contractAddress, privateKey);
if(result_verify){
const block_number = await sails.helpers.getBlockNumber(ots, url, contractABI, contractAddress);
// Tengo que obtener el bloque entero, para sacar su timestamp
const block = await sails.helpers.getBlock(block_number, url);
return res.json({
status : 'success',
tx_hash : tx_hash,
block_number : block_number,
file_hash : file_hash,
ots : ots,
contract_address: contractAddress,
timestamp : block.timestamp,
block_hash : block.hash
});
} else {
var file_hash_by_ots = await sails.helpers.getHash(ots, accountAddress, contractAddress);
return res.json({
status : 'fail',
file_hash_by_ots : file_hash_by_ots,
file_hash_send : file_hash,
tx_hash : tx_hash,
ots : ots,
msg : 'El HASH del archivo enviado no se corresponde con el OTS.'
});
}
});
},
stamp : async function (req, res){
sails.log("Stamp("+req.body.file_hash+")");
const file_hash = req.body.file_hash;
// A partir del Hash recibido, genero el OpenTimeStamp (OTS)
const ots = await sails.helpers.getOts(file_hash, accountAddress, contractAddress);
var comprobante_ots;
web3.eth.getTransactionCount(accountAddress, (err, txCount) => {
const data = contract.methods.stamp(ots, file_hash).encodeABI();
// Construir la transaccion
const txObject = {
nonce: web3.utils.toHex(txCount),
to: contractAddress,
gasLimit: web3.utils.toHex(800000),
// TODO: revisar que el precio sea automático
gasPrice: web3.utils.toHex(web3.utils.toWei('1000', 'gwei')),
data: data
}
// Firmar la transaccion
const tx = new Tx(txObject);
tx.sign(privateKey);
const serializeTransaction = tx.serialize();
const raw = '0x' + serializeTransaction.toString('hex');
// Transmitir la transacción
web3.eth.sendSignedTransaction(raw, (err, tx_hash) => {
if(err){
return res.json(err.toString());
}
comprobante_ots = ots + '-' + tx_hash;
// Si está todo bien, retorno el OpenTimeStamp definitivo para luego comprobar si el hash del archivo junto con este comprobante son válidos
comprobante_ots = base64.encode(comprobante_ots.toString(), 'base64');
return res.json({
comprobante_ots : comprobante_ots,
tx_hash : tx_hash
});
});
});
},
createAccount : async function (req, res){
sails.log("createAccount()");
var account_data = web3.eth.accounts.create();
return res.json(account_data);
},
getBalance : async function (req, res){
var account = req.params.account;
web3.eth.getBalance(account, (err, bal) => {
if(err){
return res.json(err.toString());
}
var balanceToEther = web3.utils.fromWei(bal, 'ether')
return res.json(balanceToEther);
});
}
};
...@@ -7,16 +7,16 @@ ...@@ -7,16 +7,16 @@
const Web3 = require('web3'); const Web3 = require('web3');
const Tx = require('ethereumjs-tx'); const Tx = require('ethereumjs-tx');
const url = sails.config.custom.urlRpc; const url = sails.config.custom.urlRpcRopsten;
const web3 = new Web3(url); const web3 = new Web3(url);
const accountAddress = sails.config.custom.accountAddress; const accountAddressRopsten = sails.config.custom.accountAddressRopsten;
const contractABI = sails.config.custom.contractABI; const contractABIRopsten = sails.config.custom.contractABIRopsten;
const contractAddress = sails.config.custom.contractAddress; const contractAddressRopsten = sails.config.custom.contractAddressRopsten;
const privateKey = Buffer.from( const privateKeyRopsten = Buffer.from(
sails.config.custom.privateKey, sails.config.custom.privateKeyRopsten,
'hex', 'hex',
); );
const contract = new web3.eth.Contract(contractABI, contractAddress); const contract = new web3.eth.Contract(contractABIRopsten, contractAddressRopsten);
module.exports = { module.exports = {
......
const Web3 = require('web3'); const Web3 = require('web3');
const url = sails.config.custom.urlRpc;
const web3 = new Web3(url);
const contractABI = sails.config.custom.contractABI;
const contractAddress = sails.config.custom.contractAddress;
const contract = new web3.eth.Contract(contractABI, contractAddress);
module.exports = { module.exports = {
...@@ -19,6 +14,18 @@ module.exports = { ...@@ -19,6 +14,18 @@ module.exports = {
type: 'string', type: 'string',
require: true, require: true,
}, },
url : {
type : 'string',
require : true,
},
contractABI : {
type : 'ref',
require : true,
},
contractAddress : {
type : 'string',
require : true,
},
}, },
...@@ -32,6 +39,11 @@ module.exports = { ...@@ -32,6 +39,11 @@ module.exports = {
fn: async function (inputs) { fn: async function (inputs) {
const url = inputs.url;
const web3 = new Web3(url);
const contractABI = inputs.contractABI;
const contractAddress = inputs.contractAddress;
const contract = new web3.eth.Contract(contractABI, contractAddress);
var result = await contract.methods.getBlockNumber(inputs.ots).call((err, result) => { var result = await contract.methods.getBlockNumber(inputs.ots).call((err, result) => {
if(err){ if(err){
......
const Web3 = require('web3'); const Web3 = require('web3');
const url = sails.config.custom.urlRpc;
const web3 = new Web3(url);
module.exports = { module.exports = {
...@@ -16,6 +14,10 @@ module.exports = { ...@@ -16,6 +14,10 @@ module.exports = {
type: 'number', type: 'number',
require: true, require: true,
}, },
url : {
type : 'string',
require : true,
},
}, },
...@@ -30,6 +32,9 @@ module.exports = { ...@@ -30,6 +32,9 @@ module.exports = {
fn: async function (inputs) { fn: async function (inputs) {
const url = inputs.url;
const web3 = new Web3(url);
var result = await web3.eth.getBlock(inputs.block_number, (err, result) => { var result = await web3.eth.getBlock(inputs.block_number, (err, result) => {
if(err){ if(err){
return err.toString(); return err.toString();
......
const Web3 = require('web3'); const Web3 = require('web3');
const url = sails.config.custom.urlRpc;
const web3 = new Web3(url);
const contractABI = sails.config.custom.contractABI;
const contractAddress = sails.config.custom.contractAddress;
const contract = new web3.eth.Contract(contractABI, contractAddress);
module.exports = { module.exports = {
...@@ -19,6 +14,18 @@ module.exports = { ...@@ -19,6 +14,18 @@ module.exports = {
type: 'string', type: 'string',
require: true, require: true,
}, },
url : {
type : 'string',
require : true,
},
contractABI : {
type : 'ref',
require : true,
},
contractAddress : {
type : 'string',
require : true,
},
}, },
...@@ -32,6 +39,11 @@ module.exports = { ...@@ -32,6 +39,11 @@ module.exports = {
fn: async function (inputs) { fn: async function (inputs) {
const url = inputs.url;
const web3 = new Web3(url);
const contractABI = inputs.contractABI;
const contractAddress = inputs.contractAddress;
const contract = new web3.eth.Contract(contractABI, contractAddress);
var result = await contract.methods.getHash(inputs.ots).call((err, result) => { var result = await contract.methods.getHash(inputs.ots).call((err, result) => {
if(err){ if(err){
......
...@@ -13,7 +13,15 @@ module.exports = { ...@@ -13,7 +13,15 @@ module.exports = {
file_hash : { file_hash : {
type : 'string', type : 'string',
required : true required : true
} },
accountAddress : {
type : 'string',
require : true,
},
contractAddress : {
type : 'string',
require : true,
},
}, },
...@@ -30,8 +38,8 @@ module.exports = { ...@@ -30,8 +38,8 @@ module.exports = {
var ots; var ots;
const file_hash = inputs.file_hash; const file_hash = inputs.file_hash;
const accountAddress = sails.config.custom.accountAddress; const accountAddress = inputs.accountAddress;
const contractAddress = sails.config.custom.contractAddress; const contractAddress = inputs.contractAddress;
const now = new Date(); const now = new Date();
const timeStamp = now.getTime(); const timeStamp = now.getTime();
......
const Web3 = require('web3'); const Web3 = require('web3');
const Tx = require('ethereumjs-tx');
const url = sails.config.custom.urlRpc;
const web3 = new Web3(url);
const accountAddress = sails.config.custom.accountAddress;
const contractABI = sails.config.custom.contractABI;
const contractAddress = sails.config.custom.contractAddress;
const privateKey = Buffer.from(
sails.config.custom.privateKey,
'hex',
);
const contract = new web3.eth.Contract(contractABI, contractAddress);
module.exports = { module.exports = {
...@@ -29,7 +18,27 @@ module.exports = { ...@@ -29,7 +18,27 @@ module.exports = {
file_hash : { file_hash : {
type : 'string', type : 'string',
require : true require : true
} },
url : {
type : 'string',
require : true,
},
accountAddress : {
type : 'string',
require : true,
},
contractABI : {
type : 'ref',
require : true,
},
contractAddress : {
type : 'string',
require : true,
},
privateKey : {
type : 'ref',
require : true,
},
}, },
...@@ -43,6 +52,16 @@ module.exports = { ...@@ -43,6 +52,16 @@ module.exports = {
fn: async function (inputs) { fn: async function (inputs) {
const url = inputs.url;
const web3 = new Web3(url);
const accountAddress = inputs.accountAddress;
const contractABI = inputs.contractABI;
const contractAddress = inputs.contractAddress;
const privateKey = Buffer.from(
inputs.privateKey,
'hex',
);
const contract = new web3.eth.Contract(contractABI, contractAddress);
var result = await contract.methods.verify(inputs.ots,inputs.file_hash).call({from: accountAddress}, (err, result) => { var result = await contract.methods.verify(inputs.ots,inputs.file_hash).call({from: accountAddress}, (err, result) => {
if(err){ if(err){
......
/**
* Bfa.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
module.exports = {
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
},
};
/**
* Rinkeby.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
module.exports = {
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
},
};
...@@ -21,19 +21,26 @@ module.exports.custom = { ...@@ -21,19 +21,26 @@ module.exports.custom = {
// … // …
//Datos para Ropsten //Datos para Ropsten
urlRpc: 'https://ropsten.infura.io/v3/a59f70f1e62e4db4babb69284e37672f', urlRpcRopsten: 'https://ropsten.infura.io/v3/a59f70f1e62e4db4babb69284e37672f',
accountAddress : '0x59060CF376DeB6729da45C729EbecC171C2c16b9', accountAddressRopsten : '0x59060CF376DeB6729da45C729EbecC171C2c16b9',
contractABI : [{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getBlockNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"verify","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"stamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"hash","type":"string"},{"indexed":true,"name":"ots","type":"string"}],"name":"Stamped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"Deploy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"SelfDestroy","type":"event"}], contractABIRopsten : [{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getBlockNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"verify","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"stamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"hash","type":"string"},{"indexed":true,"name":"ots","type":"string"}],"name":"Stamped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"Deploy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"SelfDestroy","type":"event"}],
contractAddress: '0x96a716f91da961639f685100b12d13ef30ba89dc', contractAddressRopsten: '0x96a716f91da961639f685100b12d13ef30ba89dc',
privateKey: 'D51E9F04E45381E1CC3C450CB296E73BBD0BDFCA7EE22FF2533D71631B9F536C', privateKeyRopsten: 'D51E9F04E45381E1CC3C450CB296E73BBD0BDFCA7EE22FF2533D71631B9F536C',
//Datos para Rinkeby
urlRpcRinkeby: 'https://rinkeby.infura.io/v3/8ac5540878e1481b81c84362c03b8d49',
accountAddressRinkeby : '0xFA2BE13EcF2774e574Dfb640b3510ffe2Fe0C131',
contractABIRinkeby : [{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getBlockNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"verify","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"stamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"hash","type":"string"},{"indexed":true,"name":"ots","type":"string"}],"name":"Stamped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"Deploy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"}],"name":"SelfDestroy","type":"event"}],
contractAddressRinkeby: '0xffD8331172E17227B553F91eA98142d9a5739bb8',
privateKeyRinkeby: 'cea30502b47213f5076ea716c9dc3df078056439b9498b9904f2183cabedf3fd',
/* Datos para localhost /* Datos para localhost
urlRpc: 'http://localhost:8545', urlRpc_: 'http://localhost:8545',
accountAddress : '0xDBF0C927F9E92dFE7C31e045e0Ba1067Ee205f73', accountAddress_ : '0xDBF0C927F9E92dFE7C31e045e0Ba1067Ee205f73',
contractABI : [{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getBlockNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"verify","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"stamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"accountAddress"},{"indexed":true,"name":"hash","type":"string"},{"indexed":true,"name":"ots","type":"string"}],"name":"Stamped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"accountAddress"}],"name":"Deploy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"accountAddress"}],"name":"SelfDestroy","type":"event"}], contractABI_ : [{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getHash","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"}],"name":"getBlockNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"verify","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ots","type":"string"},{"name":"file_hash","type":"string"}],"name":"stamp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"accountAddress"},{"indexed":true,"name":"hash","type":"string"},{"indexed":true,"name":"ots","type":"string"}],"name":"Stamped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"accountAddress"}],"name":"Deploy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"accountAddress"}],"name":"SelfDestroy","type":"event"}],
contractAddress: '0xBD89a34041190439d43ec391486819eF5CBfBDBe', contractAddress_ : '0xBD89a34041190439d43ec391486819eF5CBfBDBe',
privateKey: '6671485e4250881473c639465464148b5a0285461f136b585623333f22f7ca3f', privateKey_ : '6671485e4250881473c639465464148b5a0285461f136b585623333f22f7ca3f',
*/ */
}; };
...@@ -24,9 +24,14 @@ module.exports.routes = { ...@@ -24,9 +24,14 @@ module.exports.routes = {
'GET /account/create' : 'AccountController.create', 'GET /account/create' : 'AccountController.create',
'GET /account/get_balance/:account' : 'AccountController.getBalance', 'GET /account/get_balance/:account' : 'AccountController.getBalance',
'GET /rinkeby/verify/:ots/:file_hash' : 'RinkebyController.verify',
'GET /rinkeby/createAccount' : 'RinkebyController.createAccount',
'GET /rinkeby/get_balance/:account' : 'RinkebyController.getBalance',
'POST /transaction/send' : 'TransactionController.send', 'POST /transaction/send' : 'TransactionController.send',
'POST /blockchain/stamp' : 'BlockchainController.stamp', 'POST /blockchain/stamp' : 'BlockchainController.stamp',
'POST /rinkeby/stamp' : 'RinkebyController.stamp',
/*************************************************************************** /***************************************************************************
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment