@sensority-labs/sensor
v0.1.4
Published
SDK for Sensority bots development
Downloads
772
Readme
@sensority-labs/sensor
Sensority bot development kit.
Installation
npm install @sensority-labs/sensor
Preparation
Your bot should export functions processBlock or processTx, or both. These functions will be called by the sensor when a new block or transaction is received.
export const processBlock = async (blockEvent: BlockEvent) => {
console.log('New block:', blockEvent);
}
export const processTx = async (txEvent: TransactionEvent) => {
console.log('New transaction:', txEvent);
}
Usage
You can run it from the command line:
npx sensor
Options:
- no options - real-time blocks and transactions
--block <number>
- retrieve a specific block--tx <hash>
- retrieve a specific transaction--range <from> <to>
- examine the blocks range--help
- display help
Or add npm script ro run the sensor like this:
Real-time blocks and transactions
{
"scripts": {
"run": "sensor"
}
}
Retrieving a specific block
{
"scripts": {
"run-block": "sensor --block 123456"
}
}
Retrieving a specific transaction
{
"scripts": {
"run-tx": "sensor --tx 0x1234567890abcdef"
}
}
Examining the blocks range
{
"scripts": {
"run-range": "sensor --range 123456 123459"
}
}
Deployment
When you are ready to deploy your bot, you can use the following command:
git remote add deploy <your-sensority-bot-git-repo>
git push deploy <your-branch>:main