Skip to content

Instantly share code, notes, and snippets.

0xa4f966F298C182364D9A238aA176667c793AD7D5
0x44D84089e32802ac13eE8cc74455C51d9AB549aA
contract Relay {
address public currentVersion;
address public owner;
function Relay(address initAddr){
currentVersion = initAddr;
owner = msg.sender;
}
function update(address newAddress){
@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) _;
}
@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 / 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 / donation.sol.js
Last active May 22, 2022 02:01
Donation smart contract
pragma solidity ^0.4.4;
// TestRPC HD wallet
// warrior minimum breeze raven garden express solar flavor obvious twenty alpha actress
contract Donation {
// Instantiate a variable to hold the account address of the contract administrator
address public owner;
@pau1m
pau1m / AuthorDonationsTest.js
Last active August 21, 2019 13:55
AuthorDonationsTest.js
// Include web3 library so we can query accounts.
const Web3 = require('web3')
// Instantiate new web3 object pointing toward an Ethereum node.
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
// Include AuthorDonation contract
let AuthorDonation = artifacts.require("./AuthorDonation")
// Test with Mocha
contract('AuthorDonation', function(accounts) {
// Setup a variable to hold the contract object.
@pau1m
pau1m / AuthorDonationExample.js
Last active March 15, 2017 16:17
AuthorDonationExample.js
// Tell the compiler what version of Solidity we're using.
pragma solidity ^0.4.4;
// TestRPC HD wallet
// warrior minimum breeze raven garden express solar flavor obvious twenty alpha actress
contract AuthorDonation {
// Accounts for each of the two participants in the contract with the 'address' type.
address author = 0x34f06373e492e6ba87cbcb655ccc1d0951f734d3;
address editor = 0x7a8f86c5c3ca815e182188567cc44ca9738549af;
@pau1m
pau1m / watchingConfirmation.js
Last active March 9, 2017 12:22
Alice in chains
const Web3 = require('web3')
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
let account = '0xE767aEB31dAAF66366999F72FB5De2CEEA76c277'.toLowerCase()
let filter = web3.eth.filter('latest')
filter.watch(function(error, result) {
if (!error) {
let confirmedBlock12 = web3.eth.getBlock(web3.eth.blockNumber - 11)
confirmedBlock12.transactions.forEach(function(txId) {