Jump to content

Search the Community

Showing results for tags 'javascript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • BlockForums Announcements
    • Denarius Announcements
    • Kronos Wallet Announcements
    • The Crypto News Feed
  • Cryptocurrency Discussions
    • Cryptocurrencies
    • Altcoin Announcements
    • General Discussion
    • Tutorials & Help
  • Denarius Discussions
    • General Discussion
    • Tutorials & Help
    • Marketing & PR
    • Development
    • Mining & Staking
    • Trading & Exchanges
    • Marketplace
  • Programming & Design
    • Development QA
    • Design QA
  • Gaming
    • Bot Downloads & Discussion
    • Gaming Discussion
  • Classifieds
    • Buy Sell and Trade
  • Other Discussions
    • Element 115
    • The Lounge
    • Hardware & IoT
    • Tutorials & Guides
    • Domains & Hosting

Product Groups

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


BTC Address

Found 6 results

  1. A basic example of a Discord.js bot that can autoupdate every 5 seconds based on an API using fetch. Install nodejs and some packages. Linux x64 or ARM, example below is 64-bit. wget https://nodejs.org/dist/v16.0.0/node-v16.0.0-linux-x64.tar.xz tar xvf node-v16.0.0-linux-x64.tar.xz cd node-v16.0.0-linux-x64/ sudo cp -R bin/* /usr/bin/ sudo cp -R lib/* /usr/lib/ npm install discord.js npm install node-fetch blockheight.js https://gist.github.com/buzzkillb/63a66f27ff65c6dd880a6c3eae740602 //npm install discord.js node-fetch //get blockheight from Chainz CryptoID and update Bots Name as Blockheight const Discord = require('discord.js'); const fetch = require('node-fetch'); const config = require("./config.json"); var chainzApi = "https://chainz.cryptoid.info/d/api.dws?q=getblockcount" const client = new Discord.Client(); client.on('ready', async () => { client.user.setActivity('denarius.io'); const GUILD_ID = client.guilds.cache.map(guild => guild.id); const guild = await client.guilds.fetch(GUILD_ID); console.log('Bot is connected...'); setInterval(async function(){ fetch(chainzApi) .then(function (response) { // Get a JSON object from the response // This is a weird quirk of Fetch return response.json(); }).then(function (data) { // Log the data to the console, block height console.log(data); var blockHeight = "Height: " + data guild.me.setNickname(blockHeight); }) }, 5000); }); client.login(config.BOT_TOKEN); config.json { "BOT_TOKEN": "DISCORDGENERATEDTOKENGOESHERE" } How to add the bot to a server and get your BOT_TOKEN Authorizing Discord User Visit https://discord.com/developers/applications and create 'New Application'. Set a bot name like BlockHead On the page that follows, set the account name and save. Then click Bot Create a Bot account and Save. Click 'Copy' on the Token; this is the API Key you use in the bot script Visit the OAuth2 tab. Under Scopes, select 'bot' The resulting URL is what you (or anyone) use to add your bot instance to a server.
  2. KRONOS Kronos (Originally Denarius Pi - dPi) is a AIO interface/wallet for Denarius. Kronos was originally built with the intention of running it and installing it on Raspberry Pi Ubuntu systems, but now can be used mostly for all Linux distros. It is recommended to have at least 2GB of RAM to install and run Kronos (It also runs a Denarius node). Please go to the last page of this thread for updated information. Kronos has progressed massively overtime and this information can be out-of-date and deprecated. Features: Send and Receive D Denarius Addresses with P2PK and P2PKH scripthashed balances Import and Export Private Keys View Transactions Terminal (Access your terminal for advanced use or restarting your Denarius node manually) Generate Minikeys Convert Minkeys Encrypted Local LevelDB 24 Word Seed Phrases Block Explorer (View Addresses, Transactions, and Blocks) Stake your Denarius Monitor your configured FortunaStakes Verify Denarius Messages Sign Denarius Messages Backup Wallet Send Raw Transactions View Current OS Enviroment Statistics like CPU and Memory Usage Runs on local network by default, so great for running on a local Pi or Linux box and then accessing it from your phone or other computer, can also run it locally if viewing with a monitor on a Pi or Linux box. More Coming Soon How to Install: Run one of these commands depending on your flavor of Linux! wget -qO- https://raw.githubusercontent.com/carsenk/kronos/master/installkronos.sh | bash or curl -o- https://raw.githubusercontent.com/carsenk/kronos/master/installkronos.sh | bash Github: https://github.com/carsenk/kronos Screenshot of Kronos: Screenshots when this all started (dPi): More information and list of features will be coming soon! Stay tuned! It will be a one liner install script to run.
  3. How you can fetch cryptocurrency price data with Javascript/JQuery <div id="dprice"></div> <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> <script> fetch('https://api.coingecko.com/api/v3/coins/denarius?tickers=true&market_data=true&community_data=true&developer_data=true&sparkline=false') .then((response) => { return response.text(); }) .then((myContent) => { var market = JSON.parse(myContent); var info = market["market_data"]["current_price"]["usd"]; document.getElementById('dprice').innerHTML = info; }); </script> Simply put this code into any HTML file, the script goes at the bottom of your HTML. This example fetches the Denarius (D) price from Coingecko's API
  4. Currently looking for a version of NodeJS compiled natively on Apple M1 (Apple Silicon) aka ARMv8 for macOS Seems all current and past NodeJS builds including current nightlies do not contain any Darwin ARM binaries yet. I may attempt to compile v12.18.3 for Darwin ARM if no release soon...Read below for updates....NodeJS v15 compiled successfully on macOS Big Sur 11.0.1 - Kernel 20.1.0 - Darwin ARM64 M1 Chip
  5. How to easily swap or change endianness in Javascript, NodeJS, etc. with one simple function! changeEndianness() const changeEndianness = (string) => { const result = []; let len = string.length - 2; while (len >= 0) { result.push(string.substr(len, 2)); len -= 2; } return result.join(''); } You can then use this function with any string to convert its endianness Example of using function: var yourstringvar = 'Your string goes here to swap endianness'; var newendian = changeEndianness(yourstringvar); console.log('Your newly swapped endian string', newendian);
  6. This is a lot easier than it looks, and a super easy way to watch the status of your Fortunastakes (masternodes) from anything, including a raspberry pi. If you have multiple fortunastakes, somehow you want to get each json of your fortunastake status onto a single nginx server. Depends a lot on how to go about this. I am using blocknotify on the daemon to create 1.json and 2.json files, also grab the current block from blocknotify send that to block.txt, sending these files to /var/www/html and then making sure permissions are what I want. Install nginx on your ubuntu you will be using. sudo apt install nginx Verify that works by going to your ip address. I am doing everything on a local network, this is gonna vary, but if its working you should see the default nginx welcome screen. denarius.conf (change the full path to your server, maybe /home/username/status.sh) blocknotify=/root/status.sh status.sh (creates block.txt and iterates through 2 fortunastakes on same server at directories /root/D01 and /root/D02, i<3 is +1 of the number you are running if on same server) #!/bin/bash denariusd -datadir=/root/D01 getblockcount > /var/www/html/block.txt #stop and start 01-02 for ((i=1; i<3; i++)) do echo "$i" denariusd -datadir=/root/D0$i fortunastake status > /var/www/html/$i.json chmod -R 644 /var/www/html/* done Restart the daemon and on the first new block status.sh will run and send the files into /var/www/html. Double check the directory has some files after running for a bit. Basically you want to get each of your Fortunastakes json files into your /var/www/html, maybe even using scp from multiple vps's. Just make sure to label them 1.json 2.json 3.json and so forth for how we will iterate through these json files. example of using scp command way to do it, you want ssh-key login if using scp scp 2.json [email protected]:/var/www/html/2.json Create 4 files we will use to create the website, stick them in /var/www/html folder style.css body { background: #020000; font-family: 'Raleway', sans-serif; font-size:16px; } .row { display: flex; flex-wrap: wrap; } .col { flex: 1 0 18%; /* The important bit. This percentage decides your columns. The percent can be px. It just represents your minimum starting width. */ margin: 0.5px; background: #333333; height: 30px; color: white; display: flex; align-items: center; justify-content: center; } /* visited link */ a:visited { color: white; } /* unvisited link */ a:link { color: white; } fortunastake.js fetchData = () => { const urls = [ "1.json", "2.json" ]; const allRequests = urls.map(url => fetch(url).then(response => response.json()) ); return Promise.all(allRequests); }; fetchData().then(arrayOfResponses => { for (index = 0; index < arrayOfResponses.length; index++) { window.FS = '<div class="row">' + '<div class="col">FS' + [index+1] + '</div>' + '<div class="col">' + (arrayOfResponses[index].local.service) + '</div>' + '<div class="col">' + '<a href="https://www.coinexplorer.net/D/address/' + (arrayOfResponses[index].local.payment_address) + '">' + (arrayOfResponses[index].local.payment_address) + '</a></div>' + '<div class="col">' + (arrayOfResponses[index].local.network_status) + '</div>' + '<div class="col">' + parseFloat((arrayOfResponses[index].local.earnings) / 100000000).toFixed(8) + '</div>' + '</div>'; console.log(window.FS) $("#fsnumber").append(window.FS).hide().fadeIn("fast"); } } ); block.js fetch('block.txt', {mode: 'no-cors'}) .then(function(response) { return response.json(); }) .then(function(data) { if (data) console.log(data); $('#block').html(""); $("#block").append(data).hide().fadeIn("slow"); }) .catch(function(err) { console.log(err); }); var listen = setInterval(function() { fetch('block.txt', {mode: 'no-cors'}) .then(function(response) { return response.json(); }) .then(function(data) { if (data) console.log(data); $('#block').html(""); $("#block").append(data).hide().fadeIn("slow"); }) .catch(function(err) { console.log(err); }); }, 30000);//30 second index.html <html> <head> <title>FortunaStake List</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css"> <script type="text/javascript" src="block.js?version=0.1337"></script> <script type="text/javascript" src="fortunastake.js?version=0.1337"></script> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="style.css?version=0.1337"> </head> <body> <div class="row"> <div class="col">FortunaStake List</div> </div> <div class="row"> <div class="col">Block #<div id="block"; style="display:inline-block"; class="animated rubberBand"></div></div> </div> <div id="fsnumber"></div> </body> </html> Go back to your nginx IP and force refresh by using shift+ctrl+r and now you can start watching your Fortunastake Status from wherever. This uses a 5 column flex grid and has clickable link to coinexplorer per address and auto refreshes the block count every 30 seconds. This does not autorefresh the FS list though. FS # | IP Address | FS Address | Status | Round Earnings What it shows when one goes down from the list. This particular one lost sync on the daemon, and still shows active as I restarted the QT. Was about to get bumped off to inactive and REKT.
×
×
  • Create New...