prettymuchbryce / abidecoder Goto Github PK
View Code? Open in Web Editor NEWKotlin and Java library for decoding data params and events from ethereum transactions
License: MIT License
Kotlin and Java library for decoding data params and events from ethereum transactions
License: MIT License
I am trying to decrypt a logs from a transaction
val d = Decoder() d.addAbi("[ { \"constant\": false, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" }, { \"name\": \"timesPerDay\", \"type\": \"uint256\" }, { \"name\": \"reward\", \"type\": \"uint256\" }, { \"name\": \"timeInSeconds\", \"type\": \"uint256\" } ], \"name\": \"saveOrUpdateDataType\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getHour\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [], \"name\": \"kill\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getWeekday\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [], \"name\": \"refill\", \"outputs\": [], \"payable\": true, \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" }, { \"name\": \"hour\", \"type\": \"uint8\" }, { \"name\": \"minute\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getDay\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" } ], \"name\": \"setState\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [], \"name\": \"getContractBalance\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"view\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" }, { \"name\": \"hour\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getSecond\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" }, { \"name\": \"hour\", \"type\": \"uint8\" }, { \"name\": \"minute\", \"type\": \"uint8\" }, { \"name\": \"second\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getYear\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint16\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" }, { \"name\": \"hash1\", \"type\": \"bytes32\" }, { \"name\": \"hash2\", \"type\": \"bytes14\" } ], \"name\": \"saveHash\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getMonth\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" } ], \"name\": \"isLeapYear\", \"outputs\": [ { \"name\": \"\", \"type\": \"bool\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint256\" } ], \"name\": \"leapYearsBefore\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"year\", \"type\": \"uint16\" } ], \"name\": \"getDaysInMonth\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" } ], \"name\": \"getDataType\", \"outputs\": [ { \"name\": \"name\", \"type\": \"string\" }, { \"name\": \"reward\", \"type\": \"uint256\" }, { \"name\": \"times\", \"type\": \"uint256\" }, { \"name\": \"timeInSecond\", \"type\": \"uint256\" }, { \"name\": \"state\", \"type\": \"bool\" } ], \"payable\": false, \"stateMutability\": \"view\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" } ], \"name\": \"getInformationData\", \"outputs\": [ { \"name\": \"name\", \"type\": \"string\" }, { \"name\": \"hash1\", \"type\": \"bytes32\" }, { \"name\": \"hash2\", \"type\": \"bytes14\" }, { \"name\": \"times\", \"type\": \"uint256\" }, { \"name\": \"time\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"view\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getMinute\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"inputs\": [], \"payable\": true, \"stateMutability\": \"payable\", \"type\": \"constructor\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"name\": \"_from\", \"type\": \"address\" }, { \"indexed\": false, \"name\": \"reward\", \"type\": \"uint256\" }, { \"indexed\": false, \"name\": \"dataType\", \"type\": \"string\" }, { \"indexed\": false, \"name\": \"hash1\", \"type\": \"bytes32\" }, { \"indexed\": false, \"name\": \"hash2\", \"type\": \"bytes14\" } ], \"name\": \"Data\", \"type\": \"event\" } ]") val result = d.decodeLogs("0x000000000000000000000000008d4eafd3c7590f253096179253c1723c0a0a6f000000000000000000000000000000000000000000000000000000003b9aca0000000000000000000000000000000000000000000000000000000000000000a066697273742068617368000000000000000000000000000000000000000000007365636f6e64206861736800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055761746572000000000000000000000000000000000000000000000000000000")
but i have this mistake:
FATAL EXCEPTION: main
Process: health.bowhead.com.bowheadhealth, PID: 30509
java.lang.ExceptionInInitializerError
at org.ethereum.crypto.HashUtil.sha3(HashUtil.java:83)
at org.ethereum.solidity.Abi$Entry.fingerprintSignature(Abi.java:164)
at org.ethereum.solidity.Abi$Entry.encodeSignature(Abi.java:168)
at org.ethereum.solidity.Abi$Function.encodeSignature(Abi.java:265)
at health.bowhead.com.bowheadhealth.utils.Decoder.addAbi(Decoder.kt:45)
at health.bowhead.com.bowheadhealth.ContractsTest.onCreate(ContractsTest.kt:52)
at android.app.Activity.performCreate(Activity.java:6955)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.Reader.read(char[])' on a null object reference
at org.ethereum.config.SystemProperties.(SystemProperties.java:227)
at org.ethereum.config.SystemProperties.(SystemProperties.java:172)
at org.ethereum.config.SystemProperties.(SystemProperties.java:160)
at org.ethereum.config.SystemProperties.getSpringDefault(SystemProperties.java:104)
at org.ethereum.config.SystemProperties.getDefault(SystemProperties.java:99)
at org.ethereum.crypto.HashUtil.(HashUtil.java:55)
at org.ethereum.crypto.HashUtil.sha3(HashUtil.java:83)
at org.ethereum.solidity.Abi$Entry.fingerprintSignature(Abi.java:164)
at org.ethereum.solidity.Abi$Entry.encodeSignature(Abi.java:168)
at org.ethereum.solidity.Abi$Function.encodeSignature(Abi.java:265)
at health.bowhead.com.bowheadhealth.utils.Decoder.addAbi(Decoder.kt:45)
at health.bowhead.com.bowheadhealth.ContractsTest.onCreate(ContractsTest.kt:52)
at android.app.Activity.performCreate(Activity.java:6955)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.Reader.read(char[])' on a null object reference
at java.util.Properties$LineReader.readLine(Properties.java:435)
at java.util.Properties.load0(Properties.java:354)
at java.util.Properties.load(Properties.java:342)
at org.ethereum.config.SystemProperties.(SystemProperties.java:216)
at org.ethereum.config.SystemProperties.(SystemProperties.java:172)
at org.ethereum.config.SystemProperties.(SystemProperties.java:160)
at org.ethereum.config.SystemProperties.getSpringDefault(SystemProperties.java:104)
at org.ethereum.config.SystemProperties.getDefault(SystemProperties.java:99)
at org.ethereum.crypto.HashUtil.(HashUtil.java:55)
at org.ethereum.crypto.HashUtil.sha3(HashUtil.java:83)
at org.ethereum.solidity.Abi$Entry.fingerprintSignature(Abi.java:164)
at org.ethereum.solidity.Abi$Entry.encodeSignature(Abi.java:168)
at org.ethereum.solidity.Abi$Function.encodeSignature(Abi.java:265)
at health.bowhead.com.bowheadhealth.utils.Decoder.addAbi(Decoder.kt:45)
at health.bowhead.com.bowheadhealth.ContractsTest.onCreate(ContractsTest.kt:52)
at android.app.Activity.performCreate(Activity.java:6955)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Settings used as stated in readme:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading from jitpack.io: https://jitpack.io/org/github/prettymuchbryce/abidecoder/master-SNAPSHOT/maven-metadata.xml
Downloading from jitpack.io: https://jitpack.io/org/github/prettymuchbryce/abidecoder/master-SNAPSHOT/abidecoder-master-SNAPSHOT.pom
[WARNING] The POM for org.github.prettymuchbryce:abidecoder:jar:master-SNAPSHOT is missing, no dependency information available
Downloading from jitpack.io: https://jitpack.io/org/github/prettymuchbryce/abidecoder/master-SNAPSHOT/abidecoder-master-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.039 s
[INFO] Finished at: 2018-09-19T08:32:09+02:00
[INFO] Final Memory: 12M/44M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test: Could not resolve dependencies for project eth.events:storm-topology:jar:0.0.1-SNAPSHOT: Could not find artifact org.github.prettymuchbryce:abidecoder:jar:master-SNAPSHOT in jitpack.io (https://jitpack.io) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Any clues?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.