pha-decode
CLI tool for decoding Phantasma transactions (Carbon + VM) and legacy event hex.
What it can decode
Carbon transactions (Call, Call_Multi, mint, burn, transfer).
VM transactions (script disassembly and method calls).
Legacy event hex payloads (classic events).
JSON or pretty text output.
Optional ABI resolution from local files or RPC.
Requirements
Node.js with ESM support (Node 18+ recommended).
Installation
# install globally
npm i -g pha-decode
# or run once via npx
npx pha-decode --help
# local dev install
npm install
npm run buildQuick start
Decode a local transaction hex (shorthand):
Decode a transaction hash from RPC:
Decode legacy event hex:
Commands and inputs
pha-decode supports two commands:
tx(default): decode a transaction from hex (--hex) or from hash (--hash+--rpc).event: decode legacy event data from hex (--hex) with an optional event kind (--kind).
Input rules:
Hex strings may include
0xprefix and must have even length.--hashrequires--rpc.eventmode requires--hex.
Output formats
--format controls output:
pretty(default): human readable sections.json: machine friendly output.
JSON output structure (example):
Option reference
General:
--format <json|pretty>Output format (default:pretty).--rpc <url>RPC endpoint for--hash.--resolveFetch contract ABIs from RPC and merge into the method table.--abi <path>ABI JSON file or directory (merged with built-ins).--protocol <number>Protocol version used for ABI selection (default: latest known).--protocol-version <number>Alias for--protocol.--verboseEnable SDK logging.--helpShow help.
VM output detail:
--vm-detail <all|calls|ops|none>Control VM output (default:all).Accepted aliases:
both->all,methods->calls,opcodes->ops,off->none.
Carbon output detail:
--carbon-detail <all|call|msg|none>Control Carbon output (default:call).
Event decoding:
--kind <eventKind>Event kind hint for legacy event hex. Accepts numeric id or name.
Event mode rules
When event is selected:
--abi,--resolve,--vm-detail, and--carbon-detailare ignored.If
--kindis omitted or unknown, the tool returns raw hex with a warning.
ABI resolution
The decoder starts with built-in ABI definitions. You can add more:
--abi <path>loads a JSON file or a directory of JSON files and merges into the method table.--resolveuses the RPCgetContractsoutput and merges contract methods.
If the RPC returns no contracts or a method is unknown, the decoder keeps raw hex values and adds warnings instead of guessing.
Event kinds (legacy)
--kind accepts either the numeric id or the name (case-insensitive, whitespace ignored).
0
Unknown
1
ChainCreate
2
TokenCreate
3
TokenSend
4
TokenReceive
5
TokenMint
6
TokenBurn
7
TokenStake
8
TokenClaim
9
AddressRegister
10
AddressLink
11
AddressUnlink
12
OrganizationCreate
13
OrganizationAdd
14
OrganizationRemove
15
GasEscrow
16
GasPayment
17
AddressUnregister
18
OrderCreated
19
OrderCancelled
20
OrderFilled
21
OrderClosed
22
FeedCreate
23
FeedUpdate
24
FileCreate
25
FileDelete
26
ValidatorPropose
27
ValidatorElect
28
ValidatorRemove
29
ValidatorSwitch
30
PackedNFT
31
ValueCreate
32
ValueUpdate
33
PollCreated
34
PollClosed
35
PollVote
36
ChannelCreate
37
ChannelRefill
38
ChannelSettle
39
LeaderboardCreate
40
LeaderboardInsert
41
LeaderboardReset
42
PlatformCreate
43
ChainSwap
44
ContractRegister
45
ContractDeploy
46
AddressMigration
47
ContractUpgrade
48
Log
49
Inflation
50
OwnerAdded
51
OwnerRemoved
52
DomainCreate
53
DomainDelete
54
TaskStart
55
TaskStop
56
CrownRewards
57
Infusion
58
Crowdsale
59
OrderBid
60
ContractKill
61
OrganizationKill
62
MasterClaim
63
ExecutionFailure
64
Custom
65
Custom_V2
Last updated