After approval from the ckBTC ledger, we are transferring it to another wallet (principal ID).
dfx canister call bza44-ciaaa-aaaan-qlvna-cai transfer '(30, principal "3zm3c-qhy2j-5vvce-il3fu-il4ai-wf5fs-bwwjp-dbary-numis-kgxui-rae")' --network ic
However, we are getting the following error:
(variant { err = “Unknown transfer error” })
We want to send ICRC1, ICRC2, and ICP through our Canister freely.
Can you please guide us on how we can solve this issue?
Can you show what canister/principal makes what calls to the ckBTC canister? What you show here is how you call your own canister which doesn’t really help to debug
When you make the icrc2_transfer_from call the ckBTC canister sees bza44-ciaaa-aaaan-qlvna-cai as the caller. This is different from e.g. ETH where the TX creator gets forwarded between contract calls. If you want to do that transfer you can use a standard icrc1_transfer, no need to go through the approval process
The approve function seems to work. If I check the approved amount using the principals you posted above I get (record { allowance = 100 : nat; expires_at = null })
I’ve tried that approach initially, but it didn’t work as expected. Instead of deducting ckBTC from the user’s wallet, it was taking the amount from the canister.
I’m looking for a way to directly deduct from the user’s wallet and transfer it to another account, but it needs to go through our canister because we have additional data that needs to be passed along with the transaction.
I have also tried using the icrc2_approve function on the frontend side with the ckBTC ledger. However, I encountered an error while transferring the tokens. Here are the links to the repository and the live demo:
Approve: declaration says it takes an ApproveArgs, you create an ApproveArgs object here
Transfer: declaration says it takes a Nat and a Principal, but you construct an object with a amount and from. In Candid notation: expected: (nat, principal), you supply (record{amount: nat; to: principal}). The tuple is supposed to be 2 elements, but you give only 1, therefore Wrong number of arguments
We would appreciate it if you could provide us with any updates regarding the issue we mentioned earlier. Our infrastructure and backend processes are in place; we just need a solution for the requested error. This will enable us to implement the proposed payment solution on ICP as soon as possible.
Initially, I used the ckBTC approve function on the frontend to authorized my canister to access a specific amount of funds. Subsequently, I integrated the ckBTC canister into my contract for fund transfer purposes. I encountered an error from my canister during this process, and the relevant code is available in my GitHub repository here.
To summarize, our objective is to enable our canister to transfer ckBTC and, simultaneously, send additional values as needed.