Virtual Machine
This component of the REST API allows one to call view functions (pure functions) of Smart Contracts, or, to put it in other words, to query values stored within contracts.
POST Compute Output of Pure Function
https://gateway.multiversx.com/vm-values/query
This endpoint allows one to execute - with no side-effects - a pure function of a Smart Contract and retrieve the execution results (the Virtual Machine Output).
- Request
- Response
Body Parameters
Param | Required | Type | Description |
---|---|---|---|
scAddress | REQUIRED | string | The Address (bech32) of the Smart Contract. |
funcName | REQUIRED | string | The name of the Pure Function to execute. |
args | REQUIRED | array | The arguments of the Pure Function, as hex-encoded strings. The array can be empty. |
caller | OPTIONAL | string | The Address (bech32) of the caller. |
value | OPTIONAL | string | The Value to transfer (can be zero). |
🟢 200: OK
The VM Output is retrieved successfully.
{
"data": {
"data": {
"ReturnData": ["eyJSZ... (base64)"],
"ReturnCode": 0,
"ReturnMessage": "",
"GasRemaining": 1500000000,
"GasRefund": 0,
"OutputAccounts": {
"...": {
"Address": "... (base64)",
"Nonce": 0,
"Balance": null,
"BalanceDelta": 0,
"StorageUpdates": null,
"Code": null,
"CodeMetadata": null,
"Data": null,
"GasLimit": 0,
"CallType": 0
}
},
"DeletedAccounts": null,
"TouchedAccounts": null,
"Logs": null
}
},
"error": "",
"code": "successful"
}
Here's an example of a request:
POST https://gateway.multiversx.com/vm-values/query HTTP/1.1
Content-Type: application/json
{
"scAddress": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqllls0lczs7",
"funcName": "get",
"caller": "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
"value": "0",
"args": ["d98d..."]
}
POST Compute Hex Output of Pure Function
https://gateway.multiversx.com/vm-values/hex
This endpoint allows one to execute - with no side-effects - a pure function of a Smart Contract and retrieve the first output value as a hex-encoded string.
- Request
- Response
Body Parameters
Param | Required | Type | Description |
---|---|---|---|
scAddress | REQUIRED | string | The Address (bech32) of the Smart Contract. |
funcName | REQUIRED | string | The name of the Pure Function to execute. |
args | REQUIRED | array | The arguments of the Pure Function, as hex-encoded strings. The array can be empty. |
caller | OPTIONAL | string | The Address (bech32) of the caller. |
value | OPTIONAL | string | The Value to transfer (can be zero). |
🟢 200: OK
The output value is retrieved successfully.
{
"data": "7b22..."
}
POST Compute String Output of Pure Function
https://gateway.multiversx.com/vm-values/string
This endpoint allows one to execute - with no side effects - a pure function of a Smart Contract and retrieve the first output value as a string.
- Request
- Response
Body Parameters
Param | Required | Type | Description |
---|---|---|---|
scAddress | REQUIRED | string | The Address (bech32) of the Smart Contract. |
funcName | REQUIRED | string | The name of the Pure Function to execute. |
args | REQUIRED | array | The arguments of the Pure Function, as hex-encoded strings. The array can be empty. |
caller | OPTIONAL | string | The Address (bech32) of the caller. |
value | OPTIONAL | string | The Value to transfer (can be zero). |
🟢 200: OK
The output value is retrieved successfully.
{
"data": "foobar"
}
POST Get Integer Output of Pure Function
https://gateway.multiversx.com/vm-values/int
This endpoint allows one to execute - with no side-effects - a pure function of a Smart Contract and retrieve the first output value as an integer.
- Request
- Response
Body Parameters
Param | Required | Type | Description |
---|---|---|---|
scAddress | REQUIRED | string | The Address (bech32) of the Smart Contract. |
funcName | REQUIRED | string | The name of the Pure Function to execute. |
args | REQUIRED | array | The arguments of the Pure Function, as hex-encoded strings. The array can be empty. |
caller | OPTIONAL | string | The Address (bech32) of the caller. |
value | OPTIONAL | string | The Value to transfer (can be zero). |
🟢 200: OK
The output value is retrieved successfully.
{
"data": "2020"
}