vechain-sdk-js
vechain-sdk-js copied to clipboard
Contract :: Simulate Clause
Summary
When I create a Contract
instance using thorClient.contracts.load(...)
, I would like to be able to simulate transactions.
Currently I can do read(...)
and transact(...)
but there is no option to simulate
Basic Example
const simulation = myContract.simulate.transfer(......)
console.log(simulation) // { gas: 10000, reverted: false }
Also, I should be able specify all additional options in the endpoint. Example payload:
{
"gas": 50000,
"gasPrice": "1000000000000000",
"caller": "0x6d95e6dca01d109882fe1726a2fb9865fa41e7aa",
"provedWork": "1000",
"gasPayer": "0xd3ae78222beadb038203be21ed5ce7c9b1bff602",
"expiration": 1000,
"blockRef": "0x00000000851caf3c",
"clauses": [
{
"to": "0x0000000000000000000000000000456E65726779",
"value": "0x0",
"data": "0xa9059cbb0000000000000000000000000f872421dc479f3c11edd89512731814d0598db50000000000000000000000000000000000000000000000013f306a2409fc0000"
}
]
}
Done.