DispatchError: ContractTrapped

DispatchError docs: Contract trapped during execution.

Debug message:

panicked at 'encountered error while calling <AccountId as PSP22>::transfer_from: CalleeTrapped',...

This gets invoked when calling:


I do have checks prior to make sure the sender has greater or equal than amount of token in balance and allowance to the contract. The PSP22 token is initialized on my local chain. Not really sure why it tells me it's trapped.

1 Answer 1


CalleeTrapped means that the contract you are calling (the PSP22 contract in this case) trapped. Trapped just means its aborted its execution and rolled back all changes. A panic/assert in Rust will cause a trap. This doesn't need to be an exceptional error but could just be how the callee decided to do error handling.

If the callee was compiled in debug mode (i.e not passing --release to cargo contract) the reason should be found in the debug buffer. You seem to have posted a truncated version of the debug buffer. Wasn't there any more useful information in there?

We can't really tell from the information posted why the callee trapped as this is a generic error. I suggest to build the callee in debug mode and then examine the debug buffer on error. This should help you to find out where the callee is failing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.