
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
blockchain-logger
Advanced tools
This project provides loggers which implement a basic blockchain structure. Data is put into the following block format and stored according to the chosen strategy:
{
"data": "your data here",
"meta": {
"timestamp": "when it was created",
"previousHash": "a sha256 hash of the previous block"
},
"hash": "a sha256 hash of this block’s contents"
}
yarn add blockchain-logger # or npm install blockchain-logger
This will store logs in date-stamped files in the directory of your choice.
import { LocalFileLogger } from 'blockchain-logger'
const logger = new LocalFileLogger({
genesisHash: 'abc123',
logPath: './logs/',
logFilePrefix: 'actions',
})
This will store logs in the alt-text of an image you repeatedly upload to your Twitter account. See @tweetblockchain for an example. (Click on an image for gallery view, and then inspect element to see the alt-text.)
import { TwitterLogger } from 'blockchain-logger'
const logger = new TwitterLogger({
accessTokenKey: 'get-this-from-twitter',
accessTokenSecret: 'get-this-from-twitter',
baseImageLocation: './path/to/some/media/file.jpg',
consumerKey: 'get-this-from-twitter',
consumerSecret: 'get-this-from-twitter',
genesisHash: 'abc123',
screenName: '@handle',
})
}
const data = { whatever: 'you want' }
logger.log(data)
logger.getLoggedData(ensureHashConsistency=true)
There’s also a logger for the Bitcoin blockchain or the Bitcoin Testnet. This stores data in transactions with an OP_RETURN
output. Since the length of data that can be stored in such a transaction is limited to 80 bytes, this logger does not provide the blockchain properties of the other loggers, but can be used to store small amounts of data, or in conjunction with the other loggers to ensure integrity by storing hashes in a decentralised database.
import { BlockchainLogger } from 'blockchain-logger'
const logger = new BlockchainLogger({
maxFee: 5000, // satoshis
prefix: 'BL', // prepended to everything you log (uses up characters!)
privateKey: 'generate-this-using-secure-tools',
testnet: true,
})
Only the private key is required. The private key is needed to sign the transactions created to store logs in OP_RETURN
outputs. The transaction sends 0 satoshis to the OP_RETURN
script, and the rest back to the input address, minus a mining fee.
The logger uses 21.co’s recommended fees to calculate what fee to pay for the logging transaction, but you can set a limit with maxFee
.
logger.store('some text')
logger.store(Buffer.from('some arbitrary data'))
The limit is 80 bytes minus the length of your prefix (if you provided one).
logger.getLogs()
This returns an array of strings of text that has been stored using OP_RETURN
transactions for the specified address, which include the prefix (if you provided one). The prefix is stripped off.
The local file and Twitter loggers can use the Blockchain logger to validate hash integrity. Just provide either one with an additional config option blockchainOptions
, which should be a nested object containing the Blockchain logger options. E.g.:
import { LocalFileLogger } from 'blockchain-logger'
const logger = new LocalFileLogger({
genesisHash: 'abc123',
logPath: './logs/',
logFilePrefix: 'actions',
blockchainOptions: {
maxFee: 5000,
prefix: 'BL',
privateKey: 'generate-this-using-secure-tools',
testnet: true,
},
})
Now if you call logger.getLoggedData(ensureHashConsistency=true)
, it will loop through the hashes stored on the Bitcoin/Testnet blockchain, and make sure that the hashes for your logs appear in that order on the relevant blockchain.
FAQs
Store logs in a blockchain structure
We found that blockchain-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.