Thorest API
v2.4.1https://vet.nownodes.ioAuthentication
api-keyAuthapiKeyAPI Key: api-key in header
General
Accounts
Retrieve account details
Retrieve information about an account or a contract identified by its address.
To access historical details, you can specify a revision as a query parameter.
Parameters
addressstring<hex>requiredpathThe address of the account/ contract
revisionstringquerySpecify either best, a block number or block ID. If omitted, the best block is assumed.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerInspect clauses
This endpoint can be used for various purposes:
- Read contract state.
- Simulate the execution of a transaction. This can be useful to determine if your transaction may revert before submitting it.
- Inspect the outputs of a transaction before executing it.
- Estimate the gas consumption of a transaction. Note: The
callerfield should be provided for higher accuracy.
The fields gasPrice, gasPayer, provedWork, blockRef and expiration are for exposing themselves in EVM. Transaction meta features won't be reflected in the result, for example, no error is returned if the transaction is technically expired. For more information, please refer to the vechain documentation.
To access historical details, you can specify a revision as a query parameter.
Body
provedWorkstring | nullThe transaction's proved work (for extension contract).
gasPayerstring | nullThe address of the gas payer (for extension contract).
expirationinteger<uint32> | nullThe transaction expiration (for extension contract).
blockRefstring | nullThe block reference (for extension contract).
clausesArray<Clause> | nullAn array of clauses to be executed.
gasinteger<uint64> | nullThe maximum allowed gas for the execution of the batch call.
gasPricestring | nullThe absolute gas price for the batch call.
callerstring | nullThe caller's address (msg.sender) for the batch call.
Parameters
revisionstringquerySpecify either best, a block number or block ID. If omitted, the best block is assumed.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerRetrieve a contract's bytecode
If the provided address is not a contract, empty bytecode is returned.
Parameters
addressstring<hex>requiredpathThe address of the account/ contract
revisionstringquerySpecify either best, a block number or block ID. If omitted, the best block is assumed.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerThis endpoint allows you to retrieve the value stored at a specific storage position ({key}) of a Vechain smart contract associated with the provided address ({address}). The response will contain information about the stored value for the given key.
To access historical details, you can specify a revision as a query parameter.
Parameters
addressstring<hex>requiredpathThe address of the account/ contract
keystringrequiredpathThe unique identifier (key) representing the specific position in the account storage. This key is used to access and retrieve data stored at a particular storage position.
revisionstringquerySpecify either best, a block number or block ID. If omitted, the best block is assumed.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerThis endpoint retrieves the storage for the given storage position in RAW RLP encoded format. This API is not served as the general purpose API, the storage value needs to be decoded by the caller to serve any further purpose..
Parameters
addressstring<hex>requiredpathThe address of the account/ contract
keystringrequiredpathThe unique identifier (key) representing the specific position in the account storage. This key is used to access and retrieve data stored at a particular storage position.
revisionstringquerySpecify either best, a block number or block ID. If omitted, the best block is assumed.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerTransactions
Retrieve a transaction by ID
This endpoint allows you to retrieve a transaction identified by its ID. If the pending parameter is set to true, the response may include a pending transaction with a null meta field. Use this option when you want to retrieve pending transactions, providing flexibility in accessing real-time transaction data.
If no transaction is found, the response will be be a 200 with a null body.
Parameters
idstringrequiredpathThe transaction ID
rawbooleanqueryWhether the response should include a raw transaction represented in hexadecimal format.
headstringqueryExplicitly define the ID of the head block. Best block is assumed if omitted.
pendingbooleanqueryAllows you to indicate whether the response should include transactions that are still pending
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerRetrieve transaction receipt
This endpoint allows you to retrieve the receipt of a transaction identified by its ID. If the transaction is not found, the response will be null.
Parameters
idstringrequiredpathThe transaction ID
headstringqueryExplicitly define the ID of the head block. Best block is assumed if omitted.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerSend a transaction
This endpoint allows you to send a transaction to the blockchain. The transaction must be signed and RLP encoded.
The below is a TypeScript example of how to sign and RLP encode a transaction using the thor-devkit library:
import { Transaction, secp256k1 } from 'thor-devkit'
const clauses = [{
to: '0x7567d83b7b8d80addcb281a71d54fc7b3364ffed',
value: 10000,
data: '0x'
}]
let body: Transaction.Body = {
chainTag: '0x4a',
blockRef: '0x0000000000000000',
expiration: 32,
clauses: clauses,
gasPriceCoef: 128,
gas: Transaction.intrinsicGas(clauses),
dependsOn: null,
nonce: 12345678
}
const tx = new Transaction(body)
const signingHash = tx.signingHash()
tx.signature = secp256k1.sign(signingHash, Buffer.from("99f0500549792796c14fed62011a51081dc5b5e68fe8bd8a13b86be829c4fd36", "hex"))
const raw = tx.encode()
const decoded = Transaction.decode(raw)
axios.post('http://localhost:8669/transactions', {
raw: '0x' + raw.toString('hex')
})Body
rawstring<hex>The raw RLP encoded transaction.
Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in headerBlocks
Retrieve a block
Retrieve information about a block identified by its revision.
If the provided revision is not found, the response will be null
Parameters
revisionstringrequiredpathRevision can be one of:
- a block ID (hex string)
- a block number (integer)
beststands for latest blockfinalizedstands for the finalized block
expandedbooleanqueryWhether the returned block is expanded.
truereturnstransactionsas an array of objects with the transaction details and outputsfalsereturnstransactionsas an array of transaction IDs (hex strings)
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerLogs
Query smart contract events
Query event logs generated by vechain smart contracts. Events are created using the LOG opcode in the Ethereum Virtual Machine (EVM).
Event logs provide a way to track specific occurrences and state changes within a smart contract. By querying these logs, you can gain insights into the history of events emitted by a particular contract.
Body
rangeFilterRange | nullDefines the range for filtering. Setting values to null indicates the entire range.
Note: If omitted or set to null, a timeout may occur if there is a large amount of data to query.
Example:
{
"range": {
"unit": "block",
"from": 10,
"to": 1000
}
}This refers to the range from block 10 to block 1000.
optionsFilterOptions | nullInclude these parameters to receive filtered results in a paged format.
Note: If omitted, a timeout may occur if there is a large amount of data to query. If there is a small amount of data you can omit to receive all results in a single response.
Example:
{
"options": {
"offset": 0,
"limit": 10
}
}In this example, the page offset is 0, and the page size is 10.
criteriaSetArray<EventCriteria> | nullorderstring | nullascdescSpecifies the order of the results. Use asc for ascending order, and desc for descending order.
Default value: asc
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerQuery VET transfer events
Query VET transfers with a given criteria.
Body
rangeFilterRange | nullDefines the range for filtering. Setting values to null indicates the entire range.
Note: If omitted or set to null, a timeout may occur if there is a large amount of data to query.
Example:
{
"range": {
"unit": "block",
"from": 10,
"to": 1000
}
}This refers to the range from block 10 to block 1000.
optionsFilterOptions | nullInclude these parameters to receive filtered results in a paged format.
Note: If omitted, a timeout may occur if there is a large amount of data to query. If there is a small amount of data you can omit to receive all results in a single response.
Example:
{
"options": {
"offset": 0,
"limit": 10
}
}In this example, the page offset is 0, and the page size is 10.
criteriaSetArray<TransferCriteria> | nullorderstring | nullascdescSpecifies the order of the results. Use asc for ascending order, and desc for descending order.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerNode
Retrieve connected peers
Retrieve information about the peers connected to the node.
Response
OK
Authorization
api-keyAuthapiKey in headerSubscriptions
(Websocket) Blocks
Establish a websocket connection to the node to receive real-time updates on new blocks.
This endpoint can also be used to resume a subscription from a specific point in time.
Example:
const ws = new WebSocket('ws://localhost:8669/subscriptions/block')
ws.onmessage = (event) => {
console.log(event.data)
}Parameters
posstringqueryA saved block ID for resuming the subscription. If omitted, the best block ID is assumed.
Note: If the provided position is too far behind the best block, a 403 error will be thrown. The allowable difference depends on the configuration of each node.
See the argument api-backtrace-limit when starting a node.
Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in header(Websocket) Events
Subscribe to events generated by vechain smart contracts. Events are created using the LOG opcode in the Ethereum Virtual Machine (EVM).
Example:
// Filter the events by 'Transfer(address,address,uint256)'
const ws = new WebSocket('ws://localhost:8669/subscriptions/event?t0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef')
ws.onmessage = (event) => {
console.log(event.data)
}Parameters
posstringqueryA saved block ID for resuming the subscription. If omitted, the best block ID is assumed.
Note: If the provided position is too far behind the best block, a 403 error will be thrown. The allowable difference depends on the configuration of each node.
See the argument api-backtrace-limit when starting a node.
addrstringqueryThe address of the contract that emits the event.
t0stringqueryThe keccak256 hash representing the event signature.
For example, the signature for the Transfer event is keccak256("Transfer(address,address,uint256)").
t1stringqueryFilters events based on the 1st parameter in the event.
Note: The parameter must be padded to 32 bytes.
For example, for the event MySolidityEvent(address,uint256), use t1 to match the address parameter.
t2stringqueryFilters events based on the 2nd parameter in the event.
Note: The parameter must be padded to 32 bytes.
For example, for the event MySolidityEvent(address,uint256), use t2 to match the uint256 parameter.
t3stringqueryFilters events based on the 3rd parameter in the event.
Note: The parameter must be padded to 32 bytes.
For example, for the event MySolidityEvent(address,address,uint256), use t3 to match the uint256 parameter.
Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in header(Websocket) Transfers
Subscribe to VET transfers with a given criteria.
Example:
const ws = new WebSocket('ws://localhost:8669/subscriptions/transfer?sender=0x6d95e6dca01d109882fe1726a2fb9865fa41e7aa')
ws.onmessage = (event) => {
console.log(event.data)
}Parameters
posstringqueryA saved block ID for resuming the subscription. If omitted, the best block ID is assumed.
Note: If the provided position is too far behind the best block, a 403 error will be thrown. The allowable difference depends on the configuration of each node.
See the argument api-backtrace-limit when starting a node.
txOriginstringqueryThe address from which the transaction was sent.
recipientstringqueryThe address that received the VET.
senderstringqueryThe address that sent the VET. In most cases this is the same as txOrigin, but it may be different if the VET was sent by a contract.
Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in header(Websocket) Beats
Establish a websocket connection to receive blockchain beats, which contain a summary of new blocks and bloom filters composited with affected addresses.
Example:
const ws = new WebSocket('ws://localhost:8669/subscriptions/beat2')
ws.onmessage = (event) => {
console.log(event.data)
}Parameters
posstringqueryA saved block ID for resuming the subscription. If omitted, the best block ID is assumed.
Note: If the provided position is too far behind the best block, a 403 error will be thrown. The allowable difference depends on the configuration of each node.
See the argument api-backtrace-limit when starting a node.
Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in header(Websocket) Subscribe to new transactions
Establish a websocket connection to receive real-time updates on transactions that are pending inclusion in a future block.
Example:
const ws = new WebSocket('ws://localhost:8669/subscriptions/txpool')
ws.onmessage = (event) => {
console.log(event.data)
}Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in header(Websocket) Subscribe to Blockchain Beats
deprecatedEstablish a websocket connection to receive blockchain beats, which contain a summary of new blocks and bloom filters composited with affected addresses.
Example:
const ws = new WebSocket('ws://localhost:8669/subscriptions/beat')
ws.onmessage = (event) => {
console.log(event.data)
}Parameters
posstringqueryA saved block ID for resuming the subscription. If omitted, the best block ID is assumed.
Note: If the provided position is too far behind the best block, a 403 error will be thrown. The allowable difference depends on the configuration of each node.
See the argument api-backtrace-limit when starting a node.
Response
OK
Bad Request
Forbidden
Authorization
api-keyAuthapiKey in headerDebug
Trace a transaction clause
This endpoint allows you to create a tracer for a specific clause. Tracers are instrumental in monitoring and analyzing the execution flow within the EVM. You can customize the tracer using various options to tailor it to your specific debugging needs.
Body
namestring | null4bytecallnoopprestateunigrambigramtrigramevmdisopcountThe name of the tracer. An empty name stands for the default struct logger tracer.
configobject | nullThe configuration of the tracer. It is specific to the name
targetstringThe unified path of the target to be traced. Currently, only the clause is supported.
Format:
blockID/(txIndex|txId)/clauseIndex
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerTrace a contract call
This endpoint enables clients to create a tracer for a specific vechain function call.
You can customize the tracer using various options to suit your debugging requirements.
Body
namestring | null4bytecallnoopprestateunigrambigramtrigramevmdisopcountThe name of the tracer. An empty name stands for the default struct logger tracer.
configobject | nullThe configuration of the tracer. It is specific to the name
valuestringThe amount of token to be transferred.
datastringThe input data for the contract call.
tostring | nullThe recipient of the call. Null indicates contract deployment.
gasinteger<uint64> | nullThe maximum allowed gas for execution.
gasPricestring | nullThe absolute gas price.
callerstring | nullThe caller's address (msg.sender).
provedWorkstring | nullThe transaction's proved work (for extension contract).
gasPayerstring | nullThe address of the gas payer (for extension contract).
expirationinteger<uint32> | nullThe transaction expiration (for extension contract).
blockRefstring | nullThe block reference (for extension contract).
Parameters
headstringqueryExplicitly define the ID of the head block. Best block is assumed if omitted.
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in headerRetrieve storage range
The endpoint retrieves storage entries related to a particular clause execution and contract address. This could be useful for inspecting or analyzing storage changes.
Body
addressstringThe address of the contract/ account to be traced.
keyStartstring | nullThe start key of the storage range. Default is 0x0000000000000000000000000000000000000000000000000000000000000000
maxResultnumber | nullThe maximum number of results to be returned. Default is 1000.
targetstringThe unified path of the transaction clause.
Format:
blockID/(txIndex|txId)/clauseIndex
Response
OK
Bad Request
Authorization
api-keyAuthapiKey in header