Hi,
I’m just wondering which npm package implements icrc_2_transfer_from. I was thinking it would be @dfinity/ledger but I get dependency errors so thinking i might be looking in the wrong place:
Hi,
I’m just wondering which npm package implements icrc_2_transfer_from. I was thinking it would be @dfinity/ledger but I get dependency errors so thinking i might be looking in the wrong place:
This one should do the trick, should also work on the ICP ledger as it supports icrc:
@dfxjesse you ever seen this before when making a transfer:
Here is the function that calls it:
async function saveEuro2024Predictions(
dto: Euro2024PredictionDTO,
): Promise {
try {
const identityActor = await ActorFactory.createIdentityActor(
authStore,
process.env.FOOTBALL_GOD_BACKEND_CANISTER_ID ?? “”,
);
if (dto.alreadyEntered) {
const result = await identityActor.submitEuro2024Prediction(dto);
console.log(result);
if (isError(result)) {
console.error("Error saving Euro2024 prediction.");
return;
}
return result;
}
const ledger = IcrcLedgerCanister.create({
agent: ActorFactory.getAgent(),
canisterId: Principal.fromText("avqkn-guaaa-aaaaa-qaaea-cai"),
});
authStore.subscribe(async (auth) => {
let transfer_result = await ledger.transfer({
to: {
owner: Principal.fromText(
process.env.FOOTBALL_GOD_BACKEND_CANISTER_ID ?? "",
),
subaccount: [auth.identity?.getPrincipal().toUint8Array() ?? []],
},
fee: 100_000n,
memo: undefined,
from_subaccount: undefined,
created_at_time: BigInt(Date.now()),
amount: 100_000_000_000n,
});
console.log(transfer_result);
});
} catch (error) {
console.error("Error saving Euro2024 prediction.", error);
throw error;
}
}