Hi everyone,
I am relatively new to building apps on ICP and currently I am working on an app that will allow users to swap ICP with another supported token, same as on ICP Swap.
I am using the @dfinity npm packages to create identity, actors and http agents with nodejs and Javascript, but I get stuck when trying to deposit funds to the pool.
The error message I am getting is: InternalError = ‘Wrong fee cache, please try later’
Here is the code that fails:
const identity = Secp256k1KeyIdentity.fromSeedPhrase(seed)
const agent = new HttpAgent({
identity,
host: 'https://ic0.app',
const poolCanisterId = 'mohjv-bqaaa-aaaag-qjyia-cai'
const poolActor = Actor.createActor(
poolIdl,
{ agent, canisterId: poolCanisterId },
)
const token1Actor = Actor.createActor(
tokenIdl,
{ agent, canisterId: 'ryjl3-tyaaa-aaaaa-aaaba-cai' },
)
const approve = await token1Actor.icrc2_approve({
fee: [],
memo: [],
from_subaccount: [],
created_at_time: [],
amount: amount * 10,
expected_allowance: [],
expires_at: [],
spender: {
owner: Principal.fromText(poolCanisterId),
subaccount: [],
},
})
const depositResult = await poolActor.depositFrom({
token: 'ryjl3-tyaaa-aaaaa-aaaba-cai',
amount: 1000000,
fee: 30000,
});
No matter what I try the last line fails with the error. I tried increasing the fee, decreasing it, calculating to be exactly 0.3%, but no luck.
I also tried the deposit method on the poolActor class. Same error.
Can anyone point me to what steps I need to take in order to make a successful swap?
Thanks