This is gmaxwell's 2-of-2 escrow example, adapted to Electrum and to a lesser extent, GFM.
Archey wants to pay Bertha 0.001 BTC for a Twitter Platinum invite, but prevent Bertha from cheating him. Archey selects Iceland to act as
| const Web3 = require('web3') | |
| const Tx = require('ethereumjs-tx').Transaction | |
| // connect to Infura node | |
| const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_KEY')) | |
| // the address that will send the test transaction | |
| const addressFrom = '0x1889EF49cDBaad420EB4D6f04066CA4093088Bbd' | |
| const privateKey = new Buffer('PRIVATE_KEY', 'hex') |
| admin.addPeer("enode://03f178d5d4511937933b50b7af683b467abaef8cfc5f7c2c9b271f61e228578ae192aaafc7f0d8035dfa994e734c2c2f72c229e383706be2f4fa43efbe9f94f4@163.172.149.200:30303"); | |
| admin.addPeer("enode://0a3c4c4f5b2f46c5b343fd9c4ad28e6413d475d2c4d41b454e50c51ecdb1c2f3e6002fdac5e9639eaf0cb9425efff95cd89c1bdd2d167217e0becf28f3b8660f@88.95.162.200:30303"); | |
| admin.addPeer("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"); | |
| admin.addPeer("enode://138ec659b5ec02029c0c08d4a8f377174622c4d4f8684cf22bd6393a1e46e731ed1bf87249f4003f4c47f7a39611c39e0dc7004091604183d6e5781f1eaf81be@79.98.29.93:30303"); | |
| admin.addPeer("enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303"); | |
| admin.addPeer("enode://1a5a1fc361f3f25d3d8e0dfd2f059cd4b6fb7228c7163d232d657377818dc5f7f89426fdcb92d6cc9fd49f2f96fbe4a14c3a8d070e56ed7bee536f1bb014065 |
| 0x00 0 STOP | |
| 0x01 3 ADD | |
| 0x02 5 MUL | |
| 0x03 3 SUB | |
| 0x04 5 DIV | |
| 0x05 5 SDIV | |
| 0x06 5 MOD | |
| 0x07 5 SMOD | |
| 0x08 8 ADDMOD | |
| 0x09 8 MULMOD |
| var libxmljs = require("libxmljs"); | |
| var xml = [ | |
| '<?xml version="1.0" encoding="utf-8"?>', | |
| '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">', | |
| ' <soap:Body>', | |
| ' <Response xmlns="http://tempuri.org/">', | |
| ' <Result>', | |
| ' <client xmlns="">', | |
| ' <msg>SEARCH OK.</msg>', | |
| ' <code>0</code>', |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(query_start, clock_timestamp()), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| contract random { | |
| /* Generates a random number from 0 to 100 based on the last block hash */ | |
| function randomGen(uint seed) constant returns (uint randomNumber) { | |
| return(uint(sha3(block.blockhash(block.number-1), seed ))%100); | |
| } | |
| /* generates a number from 0 to 2^n based on the last n blocks */ | |
| function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) { | |
| uint n = 0; | |
| for (uint i = 0; i < size; i++){ |
| contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); } | |
| contract MyToken { | |
| /* Public variables of the token */ | |
| string public name; | |
| string public symbol; | |
| uint8 public decimals; | |
| /* This creates an array with all balances */ | |
| mapping (address => uint256) public balanceOf; |
| contract owned { | |
| address public owner; | |
| function owned() { | |
| owner = msg.sender; | |
| } | |
| modifier onlyOwner { | |
| if (msg.sender != owner) throw; | |
| _ | |
| } | |
| function transferOwnership(address newOwner) onlyOwner { |
This is gmaxwell's 2-of-2 escrow example, adapted to Electrum and to a lesser extent, GFM.
Archey wants to pay Bertha 0.001 BTC for a Twitter Platinum invite, but prevent Bertha from cheating him. Archey selects Iceland to act as
| var urls = [ | |
| /* Wildcard CORS enabled - Works in PhantomJS 1.9.0 */ | |
| 'http://updates.html5rocks.com', | |
| /* CORS disabled - Fails in PhantomJS 1.9.0 (and every other version) */ | |
| 'http://www.google.com', | |
| /* Hack workaround? */ | |
| /* | |
| function(httpGet, callback) { | |
| phantom.page.settings = (phantom.page.settings || {}); | |
| phantom.page.settings.webSecurityEnabled = false; |