Skip to content

Instantly share code, notes, and snippets.

View Siimone's full-sized avatar
🎯
Focusing

Simone Da Re Siimone

🎯
Focusing
View GitHub Profile
@Siimone
Siimone / IOTA-getNodeInfo.js
Created September 24, 2018 22:49
Getting Node info with iota.lib.js
iota.api.getNodeInfo((err, res) => {
if (error) {
document.getElementById('node-result').innerText = JSON.stringify(err)
} else {
document.getElementById('node-app-name').innerText = "Nome Applicazione: " + res.appName;
document.getElementById('node-app-version').innerText = "Versione: " + res.appVersion;
document.getElementById('node-neighbors').innerText = "Numero di nodi vicini: " + res.neighbors;
document.getElementById('node-time').innerText = "Orario: " + new Date(res.time);
}
})
@Siimone
Siimone / seed-generation.js
Created September 24, 2018 22:42
Generation of a IOTA seed with sjcl.js
function genSeed() {
varseed="";
for (; seed.length<81; seed+=sjcl.codec.base64.fromBits(sjcl.random.randomWords(33, 10)).replace(/[^A-Z9]+/g, '')) { };
return seed.substring(0, 81);
}
@Siimone
Siimone / IOTA-getBalance.js
Created September 24, 2018 22:30
Calling getBalances function from Iota.lib.js
document.getElementById('get-balance-btn').addEventListener('click', function () {
let address = document.getElementById('iota-address-js').value
if (iota.valid.isAddress(address))
iota.api.getBalances(
[address],
100,
(err, response) => {
if (err)
console.log(err)
else {
pragma solidity ^0.4.0;
contract GetKeccakHash {
function getHash() public pure returns(bytes32){
return keccak256("coiners.it");
}
}
@Siimone
Siimone / Coiners_Bitcoin_RSK.sol
Last active August 3, 2018 14:13
Coiners Smart Contract deployed to RSK Testnet.
pragma solidity ^0.4.0;
contract CoinersBitcoinRSK {
function getMessage() public pure returns(string){
return "3d August 2018, Coiners joined Bitcoin RSK Blockchain";
}
}
[
{
"constant": true,
"inputs": [],
"name": "totalShares",
"outputs": [
{
"name": "",
"type": "uint256"
}
@Siimone
Siimone / Share.sol
Last active May 15, 2018 20:05
Smart Contract example
pragma solidity ^0.4.17;
contract Share {
address A = 0xf17f52151EbEF6C7334FAD080c5704D77216b732;
address B = 0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2;
function() public payable {
if(!A.send(msg.value/2) || !B.send(msg.value/2)) {
revert();
}
@Siimone
Siimone / gettingBalances.js
Created April 23, 2018 00:21
Get balances of Ethereum addresses
// We need Web3.js library
var Web3 = require("web3");
// Let's create the Object
let web3 = new Web3();
// Setting the provider
web3.setProvider(new Web3.providers.HttpProvider("http://localhost:9545"));
// Coinbase account
var coinbase = web3.eth.coinbase;
// Wei balance
var weiBalance = web3.eth.getBalance(coinbase);
@Siimone
Siimone / SmartContractTutorial.sol
Created April 16, 2018 22:00
Simple example of a Smart Contract, Solidity
pragma solidity ^0.4.17;
contract Example {
uint256 balance;
function getBalance() public view returns(uint256) {
return balance;
}
function () public payable {
@Siimone
Siimone / WastingMoney.sol
Created March 30, 2018 10:35
Example of wasting money with a Smart Contract
pragma solidity ^0.4.17;
contract Hello {
function hello() public pure returns(string) {
return "Hello World!";
}
function pay() public payable returns(bool) {
if(!msg.sender.send(msg.value)) {
return false;
} else {