Skip to content

Instantly share code, notes, and snippets.

View epexa's full-sized avatar

Erlan Sobakin epexa

  • Planet Earth
View GitHub Profile
@epexa
epexa / cleaner.js
Last active June 29, 2016 13:15
cleaner.js
/**
* Cleaner - remove useless elements
* based on Additional Enhancements by XjSv
*
* @author Epexa
* @version 1.0.0
* @url https://gist.githubusercontent.com/Epexa/e4c7c7870d2b3d4f4314404497c16bdf/raw
* @last-edit 06.29.2016 15:40
*/
@epexa
epexa / golos_replace_img_to_own_domain.js
Last active November 12, 2017 09:04
Replace images links to own domain on Golos Blockchain for Node.js
// output post
res.json({
created: result.created,
title: result.title,
body: imgUrlReplace(result.body)
});
// replace all img links to own domain
function imgUrlReplace(url) {
/*return url.replace(/https:\/\/images.golos.io\/([a-zA-Z0-9]+)\/([0-9+]).jpg/g, function(match) {
@epexa
epexa / golos_first.html
Created January 12, 2018 22:55
golos-js first example
<script src="https://cdn.jsdelivr.net/npm/golos-js/dist/golos.min.js"></script>
<script>
// поиск аккаунта по юзернейму
var usernames = ['epexa', 'epexa2'];
golos.api.lookupAccountNames(usernames, function(err, result) {
//console.log(err, result);
if ( ! err) {
result.forEach(function(item) {
if (item) console.log('lookupAccountNames', 'username: [', item.name, '] id: [', item.id, ']');
else console.log('lookupAccountNames', 'аккаунт не найден!');
@epexa
epexa / steem_first.html
Created January 17, 2018 22:52
steem-js first example
<script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/steem.min.js"></script>
<script>
steem.api.setOptions({ url: 'https://api.steemit.com' });
// поиск аккаунта по юзернейму
var usernames = ['epexa', 'epexa2'];
steem.api.lookupAccountNames(usernames, function(err, result) {
//console.log(err, result);
if ( ! err) {
result.forEach(function(item) {
@epexa
epexa / golos_second.html
Created January 24, 2018 11:41
golos-js second example
<!--
0.5.21 - для текущей версии чейна
0.5.29 - для тестнета
-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/golos.min.js"></script>
<script>
/**
* getFollowers() возвращает подписчиков (кто подписан)
* @param {String} following - юзернейм на которого подписаны
* @param {String} startFollower - позиция с какого элемента возвращать результат
@epexa
epexa / golos_third.html
Last active March 23, 2018 15:21
golos-js third example
<!--
0.5.29 - для тестнета
0.5.30 - для текущей версии чейна
-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/golos.min.js"></script>
<script>
// переключение на тестнет
/*golos.api.setOptions({
'websocket': 'wss://ws.testnet.golos.io',
'address_prefix': 'GLS',
@epexa
epexa / golos_check_of_private_key_is_correct.js
Last active February 18, 2018 09:27
golos_check_of_private_key_is_correct
var usernamesArr = ['epexa'];
golos.api.getAccounts(usernamesArr, function(err, response) {
if ( ! err) {
var privWif = '5J...'; // private key
var resultWifToPublic = golos.auth.wifToPublic(privWif);
// example check of private posting key
if (response[0].posting.key_auths[0][0] == resultWifToPublic) console.log('yes, is it private posting key!');
else console.log('no, is it not private posting key!');
}
});
@epexa
epexa / golos_check_username_and_master_password.js
Last active February 27, 2018 09:55
golos check username and master password
var username = 'epexa';
var password = 'P5H...'; // мастер-пароль
golos.api.getAccounts([username], function(err, response) {
if ( ! err) {
// получение публичного ключа
var roles = ['posting']; // параметр необязательный, если не указаывать, то вернутся все ключи
var keys = golos.auth.getPrivateKeys(username, password, roles);
// проверка публичного ключа аккаунта и с полученым публичным ключом
if (response[0].posting.key_auths[0][0] == keys.postingPubkey) console.log('правильный логин и мастер-пароль!');
else console.log('не правильный логин и\или мастер-пароль!');
@epexa
epexa / get_transaction.js
Last active March 7, 2018 20:26
get_transaction from blockchain Golos on NodeJS
const golos = require('golos-js');
// switch to testnet
golos.config.set('websocket', 'wss://ws.testnet3.golos.io');
golos.config.set('chain_id', '5876894a41e6361bde2e73278f07340f2eb8b41c2facd29099de9deef6cdb679');
let trx = {
ref_block_num: 49191,
ref_block_prefix: 2024493436
};
@epexa
epexa / sign_and_send_transaction.js
Created March 7, 2018 20:31
signTransaction and getTransaction on blockchain Golos on NodeJS
const golos = require('golos-js');
const moment = require('moment');
// switch to testnet
golos.config.set('websocket', 'wss://ws.testnet3.golos.io');
golos.config.set('chain_id', '5876894a41e6361bde2e73278f07340f2eb8b41c2facd29099de9deef6cdb679');
// private posting key
let wif = '5J...';