Emulate transaction execution locally to understand why it fails
If you want to test your contract locally and find out will your operation work on the real network or not, you can emulate it locally.
To emulate deploy you need to create a deploy message and execute it locally.
If you plan to emulate local execution afterwards, then retrieve account state (BOC) from deploy emulation result and pass it into the next local execution.
To emulate local execution you need to take the current contract state (boc), create a run message and execute it locally on the current account state.
If you emulated deploy before run, then you need to get the account state from the result of the deploy emulation.
For the subsequent call emulations, use account state retrieved from the previous local execution emulation.