Skip to content

Instantly share code, notes, and snippets.

View vasa-develop's full-sized avatar
💭

vasa vasa-develop

💭
View GitHub Profile
@vasa-develop
vasa-develop / earth01.js
Created December 28, 2019 12:34
SimpleAsWater: Building a Chat Application using Libp2p
'use strict'
/* eslint-disable no-console */
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const Node = require('./libp2p_bundle')
const async = require('async')
const chalk = require('chalk');
const emoji = require('node-emoji')
let moonPeerId
async.parallel([
@vasa-develop
vasa-develop / default_opts.js
Created December 28, 2019 12:33
SimpleAsWater: Building a Chat Application using Libp2p
const DEFAULT_OPTS = {
modules: {
transport: [
TCP
],
connEncryption: [
SECIO
],
streamMuxer: [
Multiplex
@vasa-develop
vasa-develop / seccom-snippet.js
Created December 28, 2019 12:32
SimpleAsWater: Building a Chat Application using Libp2p
const Multiplex = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
@vasa-develop
vasa-develop / moon_02.js
Created December 28, 2019 12:24
SimpleAsWater: Building a Chat Application using Libp2p
'use strict'
/* eslint-disable no-console */
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const Node = require('./libp2p_bundle')
const chalk = require('chalk');
const emoji = require('node-emoji')
PeerId.createFromJSON(require('./ids/moonId'), (err, peerId) => {
if (err) {
throw err
@vasa-develop
vasa-develop / moonId.json
Created December 28, 2019 12:22
SimpleAsWater: Building a Chat Application using Libp2p
{
"id": "QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm",
"privKey": "CAASqAkwggSkAgEAAoIBAQDLZZcGcbe4urMBVlcHgN0fpBymY+xcr14ewvamG70QZODJ1h9sljlExZ7byLiqRB3SjGbfpZ1FweznwNxWtWpjHkQjTVXeoM4EEgDSNO/Cg7KNlU0EJvgPJXeEPycAZX9qASbVJ6EECQ40VR/7+SuSqsdL1hrmG1phpIju+D64gLyWpw9WEALfzMpH5I/KvdYDW3N4g6zOD2mZNp5y1gHeXINHWzMF596O72/6cxwyiXV1eJ000k1NVnUyrPjXtqWdVLRk5IU1LFpoQoXZU5X1hKj1a2qt/lZfH5eOrF/ramHcwhrYYw1txf8JHXWO/bbNnyemTHAvutZpTNrsWATfAgMBAAECggEAQj0obPnVyjxLFZFnsFLgMHDCv9Fk5V5bOYtmxfvcm50us6ye+T8HEYWGUa9RrGmYiLweuJD34gLgwyzE1RwptHPj3tdNsr4NubefOtXwixlWqdNIjKSgPlaGULQ8YF2tm/kaC2rnfifwz0w1qVqhPReO5fypL+0ShyANVD3WN0Fo2ugzrniCXHUpR2sHXSg6K+2+qWdveyjNWog34b7CgpV73Ln96BWae6ElU8PR5AWdMnRaA9ucA+/HWWJIWB3Fb4+6uwlxhu2L50Ckq1gwYZCtGw63q5L4CglmXMfIKnQAuEzazq9T4YxEkp+XDnVZAOgnQGUBYpetlgMmkkh9qQKBgQDvsEs0ThzFLgnhtC2Jy//ZOrOvIAKAZZf/mS08AqWH3L0/Rjm8ZYbLsRcoWU78sl8UFFwAQhMRDBP9G+RPojWVahBL/B7emdKKnFR1NfwKjFdDVaoX5uNvZEKSl9UubbC4WZJ65u/cd5jEnj+w3ir9G8n+P1gp/0yBz02nZXFgSwKBgQDZPQr4HBxZL7Kx7D49ormIlB7CCn2i7mT11Cppn5ifUTrp7D
@vasa-develop
vasa-develop / moon_01.js
Created December 28, 2019 12:20
SimpleAsWater: Building a Chat Application using Libp2p
'use strict'
/* eslint-disable no-console */
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const Node = require('./libp2p_bundle')
PeerId.createFromJSON(require('./ids/moonId'), (err, peerId) => {
if (err) {
throw err
}
const peerInfo = new PeerInfo(peerId)
@vasa-develop
vasa-develop / libp2p_bundle_01.js
Created December 28, 2019 12:20
SimpleAsWater: Building a Chat Application using Libp2p
const Libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const defaultsDeep = require('@nodeutils/defaults-deep')
const DEFAULT_OPTS = {
modules: {
transport: [
TCP
]
}
}
@vasa-develop
vasa-develop / chat.sh
Last active December 28, 2019 12:10
SimpleAsWater: Building a Chat Application using Libp2p
# create a directory for the project and `cd` into it
$ mkdir -p hello-libp2p/src
$ cd hello-libp2p
# make it a git repository
$ git init .
Initialized empty Git repository in /home/vasa/Desktop/simpleaswater/libp2p/.git/
# make it an npm project
$ npm init -y
pragma solidity ^0.5.11;
contract Storage {
uint256 public number;
address public account;
uint256[] private array;
mapping(uint256 => uint256) private map;
constructor() public {
number = 2;
pragma solidity ^0.5.11;
contract Calldata {
function add(uint256 _a, uint256 _b) public view returns (uint256 result) {
assembly{
_a := mload(0x40)
_b := add(_a, 32)
calldatacopy(_a, 4, 32)
calldatacopy(_b, add(4, 32), 32)
result := add(mload(_a), mload(_b))