Skip to content

Instantly share code, notes, and snippets.

@pau1m
pau1m / test.js
Created March 28, 2017 14:47
Test donation contract
const Web3 = require('web3')
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
let Donation = artifacts.require("./Donation")
contract('Donation', function(accounts) {
var donation
it("Should retrive deployed contract.", function(done) {
Donation.deployed().then(function(instance) {
@pau1m
pau1m / exampleDeployment.js
Last active March 30, 2017 11:31
Example of deploying contract code with js in ethereum
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple Contract Deployment</title>
</head>
<script>
window.addEventListener('load', function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
@pau1m
pau1m / solidityMigrate.sol.js
Created March 30, 2017 11:57
Solidity migration
pragma solidity ^0.4.4;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
contract Relay {
address public currentVersion;
address public owner;
function Relay(address initAddr){
currentVersion = initAddr;
owner = msg.sender;
}
function update(address newAddress){
0x44D84089e32802ac13eE8cc74455C51d9AB549aA
0xa4f966F298C182364D9A238aA176667c793AD7D5
0x1313734d2d6625173278978ddaa7b63400462745
0x34e8D99893CcA9a593D905fb9aB07E1E20C0157D
0x5432a7a0d8b228166f41f305942ffbfed97bb2d8
@pau1m
pau1m / createDefaultAccounts.js
Created November 15, 2017 11:15
Handy script for generating Ethereum accounts (json files) from Mnemonic
//const argv = require('minimist')(process.argv.slice(2));
const Web3 = require("web3")
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
console.log(web3)
let bip39 = require("bip39")
let hdkey = require('ethereumjs-wallet/hdkey')
let mnemonic = "weather cancel symptom owner lumber bitter bread butter dice trial shrug glance"
let hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic))
// Set to m/44'/60'/0' for ledger nano s hardware wallet compatibilty