Debug Thor debug functionalities.
The DebugModule class encapsulates functionality to debug the VeChainThor blockchain.
The module provides methods to interact with the debug end points provided by
Trace Contract Call - https://testnet.vechain.org/doc/swagger-ui/#/Debug/post_debug_tracers_call
Retrieve Storage Range
The retrieveStorageRange
method provides information about the storage range of an account, including the nextKey which is a string that can be null, and storage which is an object.
In this example the thorClient
connects to the testnet to retrieve the storage range for the coordinates passed as input
parameter.
Copy // 1 - Create thor client for testnet
const thorClient = ThorClient .at ( TESTNET_URL );
// 2 - Retrieve the storage range.
const result = await thorClient . debug .retrieveStorageRange ({
target : {
blockId : BlockId .of (
'0x010e80e3278e234b8a5d1195c376909456b94d1f7cf3cb7bfab1e8998dbcfa8f'
) ,
transaction : 0 ,
clauseIndex : 0
} ,
options : {
address : Address .of ( '0x0000000000000000000000000000456E65726779' ) ,
keyStart : BlockId .of (
'0x0000000000000000000000000000000000000000000000000000000000000000'
) ,
maxResult : 10
}
});
// 3 - Print the result.
console .log (result);
The result will show the storage.
Copy {
storage : {
'0x004f6609cc5d569ecfdbd606d943edc5d83a893186f2942aef5e133e356ed17c' : {
key : ' 0 x 9 a 92 ca 715 ec 8529 b 3 ee 4 dbefd 75e142176 b 92 c 3 d 93701808 be 4e36296718 a 5 f 3 ' ,
value : ' 0 x 000000000000000000000000000000000000046 ff 5 af 2138 c 51 ba 45 a 80000000 '
} ,
'0x0065bf3c383c7f05733ee6567e3a1201970bb5f4288d1bdb6d894167f8fc68dd' : {
key : ' 0 xf 3 dfa 1 b 3 c 541595 cd 415 aef 361e508553 fc 80 af 15 b 3e2 e 0 d 9 a 4e2408 f 2111 ed 8 ' ,
value : ' 0 xfffffffffffffffffffffffffffffffffffffffffffffe 280 bc 404 dc 5470 db 3 e'
} ,
'0x01783f86c9e29f37f3277ed5abb62353ef8baf304337e511f1b5edefc9756b23' : {
key : ' 0 x 01 cfb 1 f 8 b 52 bdbeb 1178 ba 8 fc 499479815330143 d 1 acddb 9 c 9 d 5686 cd 596 ec 24 ' ,
value : ' 0 x 0000000000000000000000000000000000000010000000000000000000000000 '
} ,
'0x0195180093382541d5396e797bd49250b1664fe8db68ff5c1d53ca95046f4549' : {
key : ' 0 x 3 f 4626 c 77582 db 20 d 0 d 690 ce 3 ad 9 bfde 8 f 9 dd 508 c 0212 a 187684678 bd 9 dc 397 a' ,
value : ' 0 x 000000000000000000000000000000000000000082 eed 4 d 8 eb 7286 de 6e540000 '
} ,
'0x02631b1c9d1e3f1360c4c6ee00ea48161dc85a0e153a0a484429bbcef16e581e' : {
key : ' 0 xc 5e3 f 1 ff 368 ddfee 94124549 ec 19 d 8 a 50547 b 5 cb 0 cc 55 ba 72188 b 7159 fb 3 ab 3 f' ,
value : ' 0 x 00000000000000000000000000000000000000000052 b 7 d 2 dcc 80 cd 2e4000000 '
} ,
'0x038658243306b2d07b512b04e6ddd4d70c49fd93969d71d51b0af7cf779d1c8f' : {
key : ' 0 x 87 b 232 cdb 2002 f 97 b 61 df 380 acf 088 f 13e5006543 d 63780567 aa 2 b 886 c 6 a 1 a 90 ' ,
value : ' 0 x 00000000000000000000000000000000000000000052 b 7 cd 7100 aea 580 f 00000 '
} ,
'0x03969104d4e5233e212c939a85ef26b8156e2fbb0485d6d751c677e854e9ba55' : {
key : ' 0 xa 887493 a 2 b 531915738 a 065 a 24263 abae 3722 b 9 a 8928 a 96 c 14 c 1 f 52 a 05964 f 23 ' ,
value : ' 0 x 00000000000000000000000000000000000000000000003635 c 9 adc 5 dea 00000 '
} ,
'0x04379cd040e82a999f53dba26500b68e4dd783b2039d723fe9e06edecfc8c9f1' : {
key : ' 0 x 831 ade 39167 b 84e87 f 89 fd 4 cd 0 bcec 5783 d 2281 fe 44 d 2 bc 6 cb 93 daaff 46 d 569 e' ,
value : ' 0 x 000000000000000000000000000000000000000000002 a 1 b 4 ae 1206 dd 9 bd 0000 '
} ,
'0x0465f4b6f9fccdb2ad6f4eac8aa7731bfe4c78f6cf22f397b5ef10398d4d5771' : {
key : ' 0 x 5 d 56 afd 38 de 44 f 293 bdce 388 b 7 d 98120 f 55971 a 0 f 3 a 608797 f 1 ddaced 0 f 2 b 047 ' ,
value : ' 0 x 00000000000000000000000000000000000000000052 b 7 c 8053950781 de 00000 '
} ,
'0x04af8500fb85efaaa5f171ef60708fc306c474011fabb6fbafcb626f09661a01' : {
key : ' 0 x 136 aee 904 ebcade 77 dc 8 d 3 c 6e48 a 2365 b 1 d 9 dff 83 f 78 eb 90 d 2 f 6e5 ef 4 a 6466 c 6 ' ,
value : ' 0 x 000000000000000000000000008 ca 1 a 3 b 5 cbedeb 0 f 1 a 0900000080845 b 322 ac 0 '
}
} ,
nextKey : ' 0 x 04e9569439 bd 218 fce 594 dbd 705 b 41 f 2 afe 6 b 6 d 8 abcb 9 c 5 aaa 5 b 1 a 52 b 7 ab 7 cea'
}
Trace Contract Call
The traceContractCall
traces the contract call execution.
In this example the thorClient
connects to the testnet to trace the contract at the coordinates specified in the input
parameter.
Copy // 1 - Create thor client for testnet
const thorClient = ThorClient .at ( TESTNET_URL );
// 2 - Trace the contract call.
const result = await thorClient . debug .traceContractCall (
{
target : {
to : Address .of ( '0x0000000000000000000000000000456E65726779' ) ,
data : HexUInt .of (
'0xa9059cbb0000000000000000000000000000000000000000000000000000456e65726779000000000000000000000000000000000000000000000004563918244f400000'
) ,
value : VET .of ( 0 )
} ,
options : {
caller : '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF' ,
gasPayer : '0x625fCe8dd8E2C05e82e77847F3da06AF6e55A7AF' ,
expiration : 18 ,
blockRef : '0x0101d05409d55cce'
} ,
config : {}
} ,
// Note that in the testnet only the 'call' option is available.
'call'
);
// 3 - Print the result.
console .log (result);
The result shows the trace, here only the first element is shown.
Copy {
gas : 0 ,
failed : false ,
returnValue : ' 0000000000000000000000000000000000000000000000000000000000000001 ' ,
structLogs : [
{
pc : 0 ,
op : 'PUSH 1 ' ,
gas : 50000000 ,
gasCost : 3 ,
depth : 1 ,
stack : []
}
]
}
Trace Transaction Clause
The traceTransactionClause
method trace the transactions specified in the clause at the coordinates expressed in the input
parameter.
In this example the thorClient
connects to the testnet to trace the clause at the coordinates specified in the input
parameter.
Copy // 1 - Create thor client for testnet
const thorClient = ThorClient .at ( TESTNET_URL );
// 2 - Trace the clause.
const result = await thorClient . debug .traceTransactionClause (
{
target : {
blockId : BlockId .of (
'0x010e80e3278e234b8a5d1195c376909456b94d1f7cf3cb7bfab1e8998dbcfa8f'
) ,
transaction : BlockId .of (
'0x05b31824569f2f2ec64c62c4e6396199f56ae872ff219288eb3293b4a36e7b0f'
) ,
clauseIndex : 0
} ,
config : {}
} ,
'call' as TracerName
);
// 3 - Print the result.
console .log (result);
The result shows the following.
Copy {
from : ' 0 x 105199 a 26 b 10e55300 cb 71 b 46 c 5 b 5e867 b 7 df 427 ' ,
gas : ' 0 x 8 b 92 ' ,
gasUsed : ' 0 x 50 fa' ,
to : ' 0 xaa 854565401724 f 7061e0 c 366 ca 132 c 87 c 1e5 f 60 ' ,
input : ' 0 xf 14 fcbc 800 d 770 b 9 faa 11 ba 944366 f 3e7 a 14 c 166 f 780 ece 542e557 e 0 b 7 fe 4870 fcbe 8 dbe' ,
value : ' 0 x 0 ' ,
type : 'CALL'
}