Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- web3 = require('web3');
- web3.setProvider(new web3.providers.HttpProvider('http://localhost:8546'));
- var eventtestContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"signedInput","type":"int256"},{"name":"unsignedInput","type":"uint256"}],"name":"intTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"test","type":"bool"}],"name":"booleanTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes32"}],"name":"Bytes32Test","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes2[]"}],"name":"Bytes2ArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"str","type":"string"}],"name":"StringTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int256[]"},{"name":"unsignedInput","type":"uint256[]"}],"name":"IntArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes2"}],"name":"Bytes2Test","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int8[]"},{"name":"unsignedInput","type":"uint8[]"}],"name":"Int8ArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int32"},{"name":"unsignedInput","type":"uint32"}],"name":"Int32Test","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int40"},{"name":"unsignedInput","type":"uint40"}],"name":"Int40Test","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int32[]"},{"name":"unsignedInput","type":"uint32[]"}],"name":"Int32ArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes1"}],"name":"Bytes1Test","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes32[]"}],"name":"Bytes32ArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int8"},{"name":"unsignedInput","type":"uint8"}],"name":"Int8Test","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"arr","type":"uint8[]"}],"name":"EnumArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"input","type":"bool[]"}],"name":"BooleanArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"signedInput","type":"int40[]"},{"name":"unsignedInput","type":"uint40[]"}],"name":"Int40ArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"enu","type":"uint8"}],"name":"EnumTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"AddressTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes1[]"}],"name":"Bytes1ArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address[]"}],"name":"AddressArrayTest","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"byt","type":"bytes"}],"name":"BytesTest","outputs":[],"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bool"}],"name":"BooleanTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int256"},{"indexed":false,"name":"unsignedInput","type":"uint256"}],"name":"IntTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int8"},{"indexed":false,"name":"unsignedInput","type":"uint8"}],"name":"Int8TestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int32"},{"indexed":false,"name":"unsignedInput","type":"uint32"}],"name":"Int32TestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int40"},{"indexed":false,"name":"unsignedInput","type":"uint40"}],"name":"Int40TestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"address"}],"name":"AddressTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes1"}],"name":"Bytes1TestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes2"}],"name":"Bytes2TestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes32"}],"name":"Bytes32TestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes"}],"name":"BytesTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"string"}],"name":"StringTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"enum TestEnum"}],"name":"EnumTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bool[]"}],"name":"BooleanArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int256[]"},{"indexed":false,"name":"unsignedInput","type":"uint256[]"}],"name":"IntArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int8[]"},{"indexed":false,"name":"unsignedInput","type":"uint8[]"}],"name":"Int8ArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int32[]"},{"indexed":false,"name":"unsignedInput","type":"uint32[]"}],"name":"Int32ArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"signedInput","type":"int40[]"},{"indexed":false,"name":"unsignedInput","type":"uint40[]"}],"name":"Int40ArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"address[]"}],"name":"AddressArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes1[]"}],"name":"Bytes1ArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes2[]"}],"name":"Bytes2ArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"bytes32[]"}],"name":"Bytes32ArrayTestEvent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"enum TestEnum[]"}],"name":"EnumArrayTestEvent","type":"event"}]);
- // Contract mined! address: 0xa5fa4c56bec5dc4e3ff3e26edabf638e23348410 transactionHash: 0xac1486b1b494e73ba5da867091ae1750a6db3b71b6fd5ec465137eba8a62ba20
- eventtestAddress = "0xa5fa4c56bec5dc4e3ff3e26edabf638e23348410"; // on my testnet.
- eventtestInstance = eventtestContract.at(eventtestAddress);
- oneInputPrint = function oneInputPrint (error, result) {
- if(!error) {
- var input = result.args["input"];
- var type = Object.prototype.toString.call(input).slice(8, -1);
- var constrName = input.constructor.name;
- console.log(new Date());
- console.log(JSON.stringify(result, null, 4));
- console.log(input + " (" + type + "/" + constrName + ")\n");
- } else {
- console.error(new Date() + " " + error);
- }
- }
- twoInputPrint = function twoInputPrint (error, result) {
- if(!error) {
- var unsigned = result.args["unsignedInput"];
- var unsignedType = Object.prototype.toString.call(unsigned).slice(8, -1);
- var unsignedConstrName = unsigned.constructor.name;
- var signed = result.args["signedInput"];
- var signedType = Object.prototype.toString.call(signed).slice(8, -1);
- var signedConstrName = signed.constructor.name;
- console.log(new Date());
- console.log(JSON.stringify(result, null, 4));
- console.log("unsigned: " + unsigned + " (" + unsignedType + "/" + unsignedConstrName + ") signed: " + signed + " (" + unsignedType + "/" + unsignedConstrName + ")\n");
- } else {
- console.error(new Date() + " " + error);
- }
- }
- boolEvent = eventtestInstance.BooleanTestEvent( {}, oneInputPrint);
- intEvent = eventtestInstance.IntTestEvent({}, twoInputPrint);
- int8Event = eventtestInstance.Int8TestEvent({}, twoInputPrint);
- int32Event = eventtestInstance.Int32TestEvent({}, twoInputPrint);
- int40Event = eventtestInstance.Int40TestEvent({}, twoInputPrint);
- addressEvent = eventtestInstance.AddressTestEvent({}, oneInputPrint);
- bytesEvent = eventtestInstance.BytesTestEvent({}, oneInputPrint);
- bytes1Event = eventtestInstance.Bytes1TestEvent({}, oneInputPrint);
- bytes2Event = eventtestInstance.Bytes2TestEvent({}, oneInputPrint);
- bytes32Event = eventtestInstance.Bytes32TestEvent({}, oneInputPrint);
- stringEvent = eventtestInstance.StringTestEvent({}, oneInputPrint);
- enumEvent = eventtestInstance.EnumTestEvent({}, oneInputPrint);
- boolArrayEvent = eventtestInstance.BooleanArrayTestEvent( {}, oneInputPrint);
- intArrayEvent = eventtestInstance.IntArrayTestEvent({}, twoInputPrint);
- int8ArrayEvent = eventtestInstance.Int8ArrayTestEvent({}, twoInputPrint);
- int32ArrayEvent = eventtestInstance.Int32ArrayTestEvent({}, twoInputPrint);
- int40ArrayEvent = eventtestInstance.Int40ArrayTestEvent({}, twoInputPrint);
- addressArrayEvent = eventtestInstance.AddressArrayTestEvent({}, oneInputPrint);
- bytes1ArrayEvent = eventtestInstance.Bytes1ArrayTestEvent({}, oneInputPrint);
- bytes2ArrayEvent = eventtestInstance.Bytes2ArrayTestEvent({}, oneInputPrint);
- bytes32ArrayEvent = eventtestInstance.Bytes32ArrayTestEvent({}, oneInputPrint);
- enumArrayEvent = eventtestInstance.EnumArrayTestEvent({}, oneInputPrint);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement