Skip to content
Snippets Groups Projects
Commit 7e42c24f authored by Andrés Blanco's avatar Andrés Blanco
Browse files

se borra viejo simplestamper

parent 7d444401
No related branches found
No related tags found
No related merge requests found
const simpleStamperInterface = require('../../contract/build/contracts/SimpleStamper.json')
class SimpleStamper {
constructor(web3, netId) {
this.web3 = web3
let address = simpleStamperInterface.networks[netId].address
this.contract = new web3.eth.Contract(simpleStamperInterface.abi, address)
}
setSender(fromAddress) {
this.from = fromAddress
}
async stamp(hash) {
console.log(`${hash}: stamping`)
let txPromise = this.contract.methods.stamp(hash).send({
from: this.from
})
txPromise.then((receipt) => {
console.log(`${hash}: stamped (bloque: ${receipt.blockNumber})`)
}).catch((error) => {
console.error(error)
})
return new Promise((resolve, reject) => {
txPromise.on('transactionHash', (txHash) => {
resolve(txHash)
})
txPromise.catch((error) => {
reject(error)
})
})
}
async verify(hash) {
try {
let blockNumber = await this.contract.methods.getBlockNumber(hash).call()
console.log(`${hash}: blockNmb (${blockNumber})`)
return {
verified: blockNumber > 0,
blockNumber: blockNumber
}
} catch (e) {
console.error(e)
throw e
}
}
}
export default SimpleStamper
\ No newline at end of file
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