JS Tools for javascript-opentimestamps.
Test live tools here
- download from website opentimestamps.org
<script src="https://opentimestamps.org/assets/javascripts/vendor/opentimestamps.js"></script>
- build sources from javascript-opentimestamps
git clone https://github.com/opentimestamps/javascript-opentimestamps.git
npm install --dev
npm run dist
const hashData = "16193782f1d839a08f9fc9a94cec1675f1729db1abc15cf9b57f31aa1724a0ae"
const op = new OpenTimestamps.Ops.OpSHA256()
const detached = OpenTimestamps.DetachedTimestampFile.fromHash(op, hashData)
OpenTimestamps.stamp(detached).then( ()=>{
const ots = detached.serializeToBytes()
const hex = bytesToHex(ots)
console.log(hex)
})
const detached = OpenTimestamps.DetachedTimestampFile.deserialize(ots)
const output = OpenTimestamps.info(detached)
console.log(output)
const detachedOts = OpenTimestamps.DetachedTimestampFile.deserialize(ots)
OpenTimestamps.upgrade(detachedOts).then( (changed) =>{
if(changed){
console.log("Timestamp upgraded")
const upgradedOts = detachedOts.serializeToBytes()
const upgradedHex = bytesToHex(upgradedOts)
console.log(upgradedHex)
} else {
console.log("Timestamp not changed")
}
})
const hashData = "16193782f1d839a08f9fc9a94cec1675f1729db1abc15cf9b57f31aa1724a0ae"
const op = new OpenTimestamps.Ops.OpSHA256()
const detached = OpenTimestamps.DetachedTimestampFile.fromHash(op, hashData)
const detachedOts = OpenTimestamps.DetachedTimestampFile.deserialize(ots)
OpenTimestamps.verify(detachedOts, detached).then( (results)=>{
if(Object.keys(results).length === 0){
console.log("Pending attestation");
}else{
Object.keys(results).map(chain => {
var date = moment(results[chain].timestamp * 1000).tz(moment.tz.guess()).format('YYYY-MM-DD z');
console.log( upperFirstLetter(chain) + ' block ' + results[chain].height + ' attests existence as of ' + date + "\n");
})
}
}).catch( err => {
console.log("Bad attestation" + err);
});