Skip to content

A command-line applications to decode ethereum abi pack data or event logs

Notifications You must be signed in to change notification settings

kinganeng/ethereum-abi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ethereum-abi

Introduce

  • A command-line applications to decode abi pack data or event logs using go. Just like the data (inputText and logs) in the follow image:

Install

$ go get -u -v github.com/sanguohot/ethereum-abi
$ ethereum-abi
ethereum-abi-1.0.0
command line for ethereum-abi!

Examples

Help command:

$ ethereum-abi h
NAME:
   ethereum-abi - command line for ethereum-abi!

USAGE:
   ethereum-abi [global options] command [command options] [arguments...]

VERSION:
   1.0.0

AUTHOR:
   Sanguohot <[email protected]>

COMMANDS:
     decode, d, de  decode the solidity's method and params from json
     help, h        Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --abi-json value  abi json string
   --abi-file value  abi file path, should be absolute path
   --help, -h        show help
   --version, -v     print the version

Decode input data:

$ export ABI_FILE=/root/.gvm/pkgsets/go1.11/global/src/medichain/contracts/medi/build/Controller.abi
$ ethereum-abi d 0x494641232be1ebf5fa924aed82103d1f1207ac7300000000000000000000000000000000388de3a4c4a0e9aa6ccb9357c031505cbe0b052c94fc1fc4345112c96497f4610f2a694b0375b2ef6faf3317fe4c4ebdbf63ac7c78199a98ebae8f43c6a7beda9fdb6075f0508eb5be54c1aa2b85e2f692cf098ebf6645f2856491ce3bec752de5b9bfe8a5bfe4b8ade58cbbe88dafe5a4a7e5ada6e7acace4b880e99984e5b19ee58cbbe999a20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b90c119
abi decode successfully!
method ===> addOrg(bytes16: [43 225 235 245 250 146 74 237 130 16 61 31 18 7 172 115], bytes32[2]: [[56 141 227 164 196 160 233 170 108 203 147 87 192 49 80 92 190 11 5 44 148 252 31 196 52 81 18 201 100 151 244 97] [15 42 105 75 3 117 178 239 111 175 51 23 254 76 78 189 191 99 172 124 120 25 154 152 235 174 143 67 198 167 190 218]], bytes32: [159 219 96 117 240 80 142 181 190 84 193 170 43 133 226 246 146 207 9 142 191 102 69 242 133 100 145 206 59 236 117 45], bytes32[4]: [[229 185 191 232 165 191 228 184 173 229 140 187 232 141 175 229 164 167 229 173 166 231 172 172 228 184 128 233 153 132 229 177] [158 229 140 187 233 153 162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]], uint256: 1536213273)

Decode event logs:

$ export ABI_FILE=/root/.gvm/pkgsets/go1.11/global/src/medichain/contracts/medi/build/OrgsData.abi
$ ethereum-abi d "[{\"blockHash\":\"0x92fc5a92c73504bcfea3f20f24cf2f73a9868e78fc7b0ef5726acce95553f45f\",\"address\":\"0x5f464b1a5ea3ce0f04f1513a069725a955d4eb20\",\"logIndex\":0,\"data\":\"0x2be1ebf5fa924aed82103d1f1207ac730000000000000000000000000000000000000000000000000000000073390edcf73b94d641de1577be9b471843cb8622388de3a4c4a0e9aa6ccb9357c031505cbe0b052c94fc1fc4345112c96497f4610f2a694b0375b2ef6faf3317fe4c4ebdbf63ac7c78199a98ebae8f43c6a7beda9fdb6075f0508eb5be54c1aa2b85e2f692cf098ebf6645f2856491ce3bec752de5b9bfe8a5bfe4b8ade58cbbe88dafe5a4a7e5ada6e7acace4b880e99984e5b19ee58cbbe999a20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b90c119\",\"topics\":[\"0x72015815f96db3c437b25806f64ca98e0fcf191b8391b37b8f1fa89209897227\"],\"blockNumber\":29,\"transactionIndex\":0,\"type\":\"mined\",\"transactionHash\":\"0xe9f3d58fae9ef6ecf9486562b29d9cafe4195f15cf6790857c8f1c60404d8d78\",\"polarity\":false}]"
abi decode successfully!
event ===> onAddOrg(bytes16: [91 123 34 98 108 111 99 107 72 97 115 104 34 58 34 48], address: 0x6632663733613938363865373866633762306566, bytes32[2]: [[53 55 50 54 97 99 99 101 57 53 53 53 51 102 52 53 102 34 44 34 97 100 100 114 101 115 115 34 58 34 48 120] [53 102 52 54 52 98 49 97 53 101 97 51 99 101 48 102 48 52 102 49 53 49 51 97 48 54 57 55 50 53 97 57]], bytes32: [53 53 100 52 101 98 50 48 34 44 34 108 111 103 73 110 100 101 120 34 58 48 44 34 100 97 116 97 34 58 34 48], bytes32[4]: [[120 50 98 101 49 101 98 102 53 102 97 57 50 52 97 101 100 56 50 49 48 51 100 49 102 49 50 48 55 97 99 55] [51 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48] [48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 55 51 51 57 48 101 100] [99 102 55 51 98 57 52 100 54 52 49 100 101 49 53 55 55 98 101 57 98 52 55 49 56 52 51 99 98 56 54 50]], uint256: 22706139647592311372414623896807951824132518626356885800703841292447754039349)

About

A command-line applications to decode ethereum abi pack data or event logs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%