Sequence that keeps printing current crypto prices for a provided pair of currencies every 3 seconds.
The video that illustrates the execution of the sample is on our YouTube channel How to check cryptocurrency prices using Scramjet?
💡 Please note that the sample below requires some previous installations before you start running it, you will find them here.
Open two terminals and run the following commands:
The first terminal:
# start sth
scramjet-transform-hub
The second terminal
# go to 'crypto-prices' directory
cd samples/crypto-prices
# install dependencies
npm install
# transpile TS->JS and copy node_modules and package.json to dist/
npm run build
# deploy the Sequence from the dist/ directory, which contains transpiled code, package.json and node_modules
si seq deploy dist
# see the Instance output
si inst output -
💡NOTE: Command
deploy
performs three actions at once:pack
,send
andstart
the Sequence. It is the same as if you would run those three commands separately:
si seq pack dist/ -o crypto-prices.tar.gz # compress 'dist/' directory into file named 'crypto-prices.tar.gz'
si seq send crypto-prices.tar.gz # send packed Sequence to STH, this will output Sequence ID
si seq start - # start the Sequence, this will output Instance ID
Once you run si inst output -
command you should get an output similar to this one:
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"
"{\"data\":{\"base\":\"BTC\",\"currency\":\"USD\",\"amount\":\"40989.61\"}}\r\n"