vechain-sdk-js icon indicating copy to clipboard operation
vechain-sdk-js copied to clipboard

Contract :: Simulate Clause

Open darrenvechain opened this issue 11 months ago • 1 comments

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 }

darrenvechain avatar Mar 19 '24 16:03 darrenvechain

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"
    }
  ]
}

darrenvechain avatar Jun 12 '24 09:06 darrenvechain

Done.

victhorbi avatar Sep 16 '24 15:09 victhorbi