I am trying to interact with ckSepoliaUSDC from my rust canister but getting a few errors while performing a withdrawal of ckSepoliaUSDC to USDC
The first step is approving ckETH minter to burn some of the user’s ckETH tokens as payment, this function is failing with the error I have insufficient balance. And yet I have minted roughly 0.1 ckETH tokens to my principal ID
This is what my function looks like:
const CKETH_MINTER: &str = "jzenf-aiaaa-aaaar-qaa7q-cai";
#[ic_cdk::update]
async fn approve_cketh_burning(user_principal: Principal, amount: Nat) -> ICRC2ApproveResult {
let from_subaccount = Subaccount::from(user_principal);
// Use the ckETH minter as the spender
let minter_principal = Principal::from_text(CKETH_MINTER).expect("Invalid minter principal");
let spender = ICRCAccount::new(minter_principal, None);
let approve_args = ICRC2ApproveArgs {
from_subaccount: Some(from_subaccount),
spender,
amount,
expected_allowance: None,
expires_at: None,
fee: None,
created_at_time: None,
memo: None
};
InterCall::from(CKETH_LEDGER).call(
"icrc2_approve",
approve_args,
CallCycles::NoPay
)
.await
.unwrap()
}
This is the error I am getting when I try to approve burning of ckETH tokens from this particular canister ID: 4p7ji-qaaaa-aaaal-qjabq-cai
The second error I am getting is when I try to call icrc2_approve
function on the USDC_LEDGER
to approve the minter
to burn
some of the user's ckUSDC
tokens.
(I am not sure whether I am doing this the right way)
This is what my function looks like:
const CKETH_MINTER: &str = "jzenf-aiaaa-aaaar-qaa7q-cai";
const USDC_LEDGER: &str = "2s5qh-7aaaa-aaaar-qadya-cai";
#[ic_cdk::update]
async fn approve_usdc_burning(user_principal: Principal, amount: Nat) -> ICRC2ApproveResult {
let from_subaccount = Subaccount::from(user_principal);
// Convert minter Principal to ICRCAccount
let minter_principal = Principal::from_text(CKETH_MINTER).expect("Invalid minter principal");
let spender = ICRCAccount::new(minter_principal, None);
let approve_args = ICRC2ApproveArgs {
from_subaccount: Some(from_subaccount),
spender,
amount,
expected_allowance: None,
expires_at: None,
fee: None,
created_at_time: None,
memo: None
};
InterCall::from(USDC_LEDGER).call(
"icrc2_approve",
approve_args,
CallCycles::NoPay
)
.await
.unwrap()
}
But when calling the function I am getting the error:
Err` value: CallError("icrc2_approve", "IC0536: Error from Canister 2s5qh-7aaaa-aaaar-qadya-cai: Canister has no update method 'icrc2_approve'
The final error I am getting is when I try to get the balance
of ckSepoliaUSDC on my principal ID
This is how I’ve implemented the functionality
const USDC_LEDGER: &str = "2s5qh-7aaaa-aaaar-qadya-cai";
#[ic_cdk::update]
async fn balance(principal_id: Principal) -> Nat {
let account = ICRCAccount::new(principal_id, None);
ICRC1::from(USDC_LEDGER).balance_of(account).await.unwrap()
}
But I am getting the error:
`Err` value: CallError("icrc1_balance_of", "IC0536: Error from Canister 2s5qh-7aaaa-aaaar-qadya-cai: Canister has no update method 'icrc1_balance_of'
I would really appreciate if I got some assistance on this