IC0503: Canister <canister_id> trapped explicitly: transaction is a duplicate of another transaction

Hi @icme, This error happens when two transactions are sent to the ledger with the same exact transfer args within 24 hours. It is a feature to help a client if the client lost power or had a system failure before getting a message-response, the client can make sure the transaction goes through without scanning the ledger transaction history by sending the same exact transfer args. See here for the transaction-de-duplication mechanics. When calling the ledger, dfx sets the created_at_time field to the computer’s current time so most of the time the transactions have a different created_at_time field value but in your case since you are doing these commands at the same time, the computer’s time is the same for multiple requests triggering the duplicate transaction error. You can control the transaction de-duplication by setting a different created_at_time value on each ledger request. Here is a dfx PR: feat: ledger transfer optional set created_at_time field by levifeldman · Pull Request #3018 · dfinity/sdk · GitHub.

2 Likes