How to send ICP from Account Identifier to ledger Canister

I’m newbie on Motoko. I read docs about the Ledger Canister, dfx ledger transfer --to [account-identifier]. This transfers ICP from ledger canister account to destination(account identifier). How to transfer ICP from account identifier to Ledger Canister on Motoko?


I am not an expert in motoko but you will need the nns ledger interface
and call the transfer method
transfer : ( TransferArgs, ) -> (TransferResult);

You can find an example how to call other canisters from your actor here

You can use the playground to experiment.


Many thanks,
let me ask commands:


dfx identity new minter

dfx identity use minter

export MINT_ACC=$(dfx ledger account-id)

# ledger

dfx identity use default
export LEDGER_ACC=$(dfx ledger account-id)

can Account Identifier(use NNS) to be the Ledger Canister account? Or The Ledger Canister account is only our developer to hold ICP to payment, convert to cycles…?

I’m not clear, hold u can explain it.

maybe this code can help

1 Like