Simulation
Simulation is an essential part of interacting with the web3 ecosystem — it allows you to simulate the state changes that would occur on the Bitcoin blockchain without executing the transaction permanently. This allows you to gain deep insights in what the transaction would execute before you sign it.
POST/v1/simulate
Run a simulation
This endpoint allows you to run a transaction simulation and returns the resulting state changes for the list of requested addresses.
Request attributes
- Name
psbt
- Type
- string
- Description
A partially-signed bitcoin transaction, encoded in base64.
- Name
addresses
- Type
- array
- Description
An array of addresses to compute the aggregated state changes for.
Response attributes
- Name
state_changes
- Type
- object
- Description
The expected state changes for all addresses.
- Name
aggregated
- Type
- object
- Description
The aggregated and deduplicated state changes for the addresses provided in the request.
Request
POST
/v1/simulatecurl --location 'https://api.virtoshi.com/v1/simulate' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY_HERE' \
--data '{
"psbt": "cHNidP8BAJ4CAAAAAu2BaIBuhpYKY8ax31ZAVZze1iismPwTPStICuMyUJtGAAAAAAD/////IGFcnPZXzaCe4qr069+JnaAVUGID33eQ4aTpIM0eipEAAAAAAP////8C09/1BQAAAAAZdqkU0MWZA8W6woaHYOkP1SGkZlqnZSCIrADh9QUAAAAAF6kUNUXm4zuDLEcFDyTT7rk8nAOUi8eHsy4TAAABAP1zAQEAAAAAAQIWVufpLOUIurGPHgB4a9DffjOONLakDOqxdhe9eVgqKwAAAABqRzBEAiAKWOL5TVIiDAJnNoZAkSxXKiyelDWS4XfK+oewWuhzsgIgY/3O56Tvx94G1pgyu3fvSlUF+GTLUYV4+ViKBiHa7+YBIQKBEgfesvGQntqodhg/eXgul85JpOiZlEtE5WrmGkWatf3///9GyQ8t/FBuZJtE3o7pLRqpV7Mdyd2Eu9TVlSpnpYU9LQEAAAAA/f///wIiAgAAAAAAABYAFL8ZFtwz291l9g2LH2XrNegSCDX8we0AAAAAAAAWABTKhnyqk4kmcURM/mMXCfgO6vLpOQACSDBFAiEA33EggHpC0Y0xm4/16ZqEJYccH/mxnlxoYrNpVlRJZMICIBXSCLOcz2TILiWJdmGQt+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eoh4mSoiUZrSbs1J3jazSdJH9QS"
]
}'
Response
{
"state_changes":{
"bc1qhuv3dhpnm0wktasd3v0kt6e4aqfqsd0uhfdu7d":{
"balance":[
{
"ticker":"ordi",
"value":1000,
"sign":"-"
},
{
"ticker":"BTC",
"value":546,
"sign":"-"
}
],
"nft":[]
},
"bc1p9ctdfwx0m20h7spf088erur5um3ule6tff7uqzfhy0xq7vaqwh6sjfs3a5":{
"balance":[
{
"ticker":"BTC",
"value":10000,
"sign":"-"
}
],
"nft":[
{
"id":"918a1ecd20e9a4e19077df03625015a09d89dfebf4aae29ea0cd57f69c5c6120i0",
"sign":"-"
}
]
},
"36YhUacEtcnkfhSbxwm11wDCexLGBLgJF6":{
"balance":[
{
"ticker":"BTC",
"value":100000000,
"sign":"+"
}
],
"nft":[]
},
"1L2tGENeoh4mSoiUZrSbs1J3jazSdJH9QS":{
"balance":[
{
"ticker":"ordi",
"value":1000,
"sign":"+"
},
{
"ticker":"BTC",
"value":99999699,
"sign":"+"
}
],
"nft":[
{
"id":"918a1ecd20e9a4e19077df03625015a09d89dfebf4aae29ea0cd57f69c5c6120i0",
"sign":"+"
}
]
}
},
"aggregated":{
"state_change":{
"balance":[
{
"ticker":"BTC",
"value":99989699,
"sign":"+"
},
{
"ticker":"ordi",
"value":1000,
"sign":"+"
}
],
"nft":[]
}
},
"inputs":10546,
"outputs":199999699,
"fee":0
}