Hi,
I’m trying to make this code work, to fetch the ICP balance from a principal:
import { createAgent } from "@dfinity/utils";
import { LedgerCanister, AccountIdentifier } from "@dfinity/ledger-icp";
import { Principal } from '@dfinity/principal';
...
const agent = await createAgent({
identity,
//host: HOST,
});
const { accountBalance } = LedgerCanister.create({
agent,
canisterId: process.env.CANISTER_ID_ICP_LEDGER_CANISTER,
});
const accountIdentifier = AccountIdentifier.fromPrincipal({
principal: Principal.fromText(principal),
//subAccount: principalSubaccount
});
let balance = await accountBalance(accountIdentifier);
console.log(balance);
as mentioned here.
I’ve debugged everything until the accountIdentifier (I know that it is correct); However, now I get the following error from the accountBalance method:
Buffer is not defined
That appears to come from the @dfinity/ledger-icp library (this line), so I have no idea how do debug further.
Any idea?
Thanks!