-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode2.js
18 lines (16 loc) · 5.12 KB
/
node2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var input_publisher_name = "Widgets Corporation"
var mp_sol_merkleproofsContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"publisher","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"merkle_proofs","outputs":[{"name":"root_hash","type":"bytes32"},{"name":"timestamp","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getLatestProofRootHash","outputs":[{"name":"root_hash","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"input_root_hash","type":"bytes32"}],"name":"publishProof","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getLatestProofTimestamp","outputs":[{"name":"timestamp","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"publisher_name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"inputs":[{"name":"input_publisher_name","type":"string"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"root_hash","type":"bytes32"},{"indexed":false,"name":"timestamp","type":"uint256"}],"name":"ProofPublished","type":"event"}]);
var mp_sol_merkleproofs = mp_sol_merkleproofsContract.new(
input_publisher_name,
{
from: web3.eth.accounts[0],
data: '0x6060604052341561000c57fe5b60405161068b38038061068b833981016040528080518201919050505b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060019080519060200190610080929190610088565b505b5061012d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100c957805160ff19168380011785556100f7565b828001600101855582156100f7579182015b828111156100f65782518255916020019190600101906100db565b5b5090506101049190610108565b5090565b61012a91905b8082111561012657600081600090555060010161010e565b5090565b90565b61054f8061013c6000396000f30060606040523615610076576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638c72c54e14610078578063aa45a36f146100ca578063becceac91461010d578063d32933de1461013b578063e5660c471461015f578063f4890bfd14610185575bfe5b341561008057fe5b61008861021e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100d257fe5b6100e86004808035906020019091905050610244565b6040518083600019166000191681526020018281526020019250505060405180910390f35b341561011557fe5b61011d610278565b60405180826000191660001916815260200191505060405180910390f35b341561014357fe5b61015d6004808035600019169060200190919050506102c2565b005b341561016757fe5b61016f6103d9565b6040518082815260200191505060405180910390f35b341561018d57fe5b610195610423565b60405180806020018281038252838181518152602001915080519060200190808383600083146101e4575b8051825260208311156101e4576020820191506020810190506020830392506101c0565b505050905090810190601f1680156102105780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028181548110151561025357fe5b906000526020600020906002020160005b915090508060000154908060010154905082565b6000600060028054905011151561028f5760006000fd5b60026001600280549050038154811015156102a657fe5b906000526020600020906002020160005b506000015490505b90565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561031f5760006000fd5b6002805480600101828161033391906104c1565b916000526020600020906002020160005b6040604051908101604052808560001916815260200142815250909190915060008201518160000190600019169055602082015181600101555050507fefe2b279a82d87ce91dfb1a32840f3e856af29c46cb0cce3a93238e9f4e011246103a9610278565b6103b16103d9565b6040518083600019166000191681526020018281526020019250505060405180910390a15b50565b600060006002805490501115156103f05760006000fd5b600260016002805490500381548110151561040757fe5b906000526020600020906002020160005b506001015490505b90565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b95780601f1061048e576101008083540402835291602001916104b9565b820191906000526020600020905b81548152906001019060200180831161049c57829003601f168201915b505050505081565b8154818355818115116104ee576002028160020283600052602060002091820191016104ed91906104f3565b5b505050565b61052091905b8082111561051c57600060008201600090556001820160009055506002016104f9565b5090565b905600a165627a7a72305820ca59050af82d77eb81a4d30c75832dbf0cc4431b34d8b1ee4ac73191602e49f40029',
gas: '4700000'
}, function (e, contract){
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})
setTimeout(function(){ console.log('"' + mp_sol_merkleproofs.address + '"'); }, 12000);
setTimeout(function(){ mp_sol_merkleproofs.publishProof('0xdeadbeef'); }, 13000);
setTimeout(function(){ console.log(mp_sol_merkleproofs.getLatestProofRootHash()); }, 25000);