# How to transfer funds/tokens from a master identity to another identity / wallet

**URL:** <https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758>\
**Category:** Developers\
**Tags:** nns\
**Created:** [December 20, 2023, 10:12am UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758 "2023-12-20T10:12:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 10:12am UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/1 "2023-12-20T10:12:04Z")

</div>

I am able to transfer funds from one **connected account** to another _not connected account_ simply by using the icp ledger in js. but now i want to transfer funds the other way arround.  
If what i was doing before was send tokens now i want to recieve them is there a possible way for it in a reactjs app which is 100% on chain.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 10:25am UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/2 "2023-12-20T10:25:58Z")

</div>

Are you looking for `icrc2_transfer_from`? [ICRC-1/standards/ICRC-2/README.md at main · dfinity/ICRC-1 · GitHub](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-2/README.md)

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 1:58pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/3 "2023-12-20T13:58:13Z")

</div>

What i want is to transfer icp tokens from my motoko canister using my master wallet. without me having to approve the transaction.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 2:01pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/4 "2023-12-20T14:01:10Z")

</div>

You can have your canister blanket-approve a large amount (say `u64::MAX`) and then you can `icrc2_transfer_from` whenever you want, but the canister will have to call `icrc2_approve` once to set this up

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 2:02pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/5 "2023-12-20T14:02:36Z")

</div>

i can approve a canister to do transfers on my behalf?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 2:04pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/6 "2023-12-20T14:04:09Z")

</div>

Yes, you can approve any valid principal to spend on your behalf

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 2:06pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/7 "2023-12-20T14:06:41Z")

</div>

so i could do something like:

```auto
public shared ({caller}) func gimme_money() : Bool {
  <If the caller deserves money> 
   ledger.transfer(to:<callers'accountid>,amount: <what he deserves>);
   return true;
  <else>
   return false;
}

```

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 2:09pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/8 "2023-12-20T14:09:13Z")

</div>

You can do that. If you use `ledger.transfer` you will always spend your own tokens (so since this is in a canister you would spend the canister’s tokens). If you want to spend tokens of some other account you have to use `ledger.icrc2_transfer_from`

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 2:10pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/9 "2023-12-20T14:10:43Z")

</div>

Yes i get that, Thank you very much!!!  
But how can i call ledger’s methods from a motoko canister is it just like how we do normal inter-canister calls or is it different?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 2:12pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/10 "2023-12-20T14:12:00Z")

</div>

The ledger is a canister like any other canister. You can use the normal inter-canister calls. It’s just a bit ‘more important’, otherwise there’s nothing special about it

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 2:15pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/11 "2023-12-20T14:15:40Z")

</div>

yes and in normal cansiter call we declare the methods we want to use by creating the actor like:

```auto
let ledgerCanister = actor ('ryjl3-tyaaa-aaaaa-aaaba-cai') : actor {
      transfer : (to : Principal, amount : Int) -> async Bool;
  };

```

its not complete ik but do we have to declare all the methods we want to use or is ther a predefined way to achieve this

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 2:20pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/12 "2023-12-20T14:20:49Z")

</div>

The recommended setup is [here](https://internetcomputer.org/docs/current/developer-docs/integrations/ledger/ledger-local-setup), then you can use the ledger in Motoko with `import LEDGER "canister:ledger";`

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 20, 2023, 3:06pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/13 "2023-12-20T15:06:49Z")

</div>

I am got this error when tried to call the approve method on my local ledger.  
ICRC-2 features are not enabled on the ledger., error code None

from what i found on the docs. i have to deploy an icrc1 ledger with ` feature_flags = opt record{icrc2 = true};` but i dont really want to create my own tokens and interact with them i want to interact with the icp ledger and its (icp)tokens.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 20, 2023, 4:39pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/14 "2023-12-20T16:39:22Z")

</div>

You only deploy the ledger yourself if you’re developing locally on your machine. For mainnet you won’t deploy your own.

To turn on ICRC-2, you need to add the `feature_flag` field to the init args like this:

```auto
dfx deploy --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister --argument "
  (variant {
    Init = record {
      minting_account = \"$MINTER_ACCOUNT_ID\";
      initial_values = vec {
        record {
          \"$DEFAULT_ACCOUNT_ID\";
          record {
            e8s = 10_000_000_000 : nat64;
          };
        };
      };
      send_whitelist = vec {};
      transfer_fee = opt record {
        e8s = 10_000 : nat64;
      };
      token_symbol = opt \"LICP\";
      token_name = opt \"Local ICP\";
      feature_flags = opt record {
        icrc2 = true;
      };
    }
  })
"

```

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 21, 2023, 1:29pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/15 "2023-12-21T13:29:35Z")

</div>

Sorry to bother again but it is releated to the issue so:

I was able to do it locally as you’ve mentioned but when i deploy my canisters on main-net and i want to allow my canister to use my masterWallets token i got stuck.  
what i tried was to use the icrc2\_approve method on the dfx ledger but it doesn’t have a method like that so the question is :  
How am i supposed to allow a canister on mainnet to use my icp tokens from icp ledger “ryjl3-tyaaa-aaaaa-aaaba-cai” using the icrc2\_approve method

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 21, 2023, 1:47pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/16 "2023-12-21T13:47:58Z")

</div>

You have to call the function manually using `dfx canister call`.

```auto
dfx canister --network ic call ryjl3-tyaaa-aaaaa-aaaba-cai icrc2_approve '( record {
  amount = <amount in e8s>;
  spender = record {
     owner = principal "<canister id>";
  };
})'

```

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 21, 2023, 1:59pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/17 "2023-12-21T13:59:51Z")

</div>

This is the command iam running  
`dfx canister call ryjl3-tyaaa-aaaaa-aaaba-cai icrc2_approve "(record { amount = 10_000_000_000_000_000; spender = record{owner = principal \"my-canister-id\";} })" --network ic`

````auto
And i get this error 
Error: Failed update call.
Caused by: Failed update call.
  The replica returned a replica error: Replica Error: reject code CanisterReject, reject message Fail to decode argument 0, error code None```
````

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 21, 2023, 2:01pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/18 "2023-12-21T14:01:52Z")

</div>

Maybe try `amount = 10_000 : nat`?

---

<div class="post-metadata">

**Author:** ![Mysticx](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Mysticx](https://forum.dfinity.org/u/Mysticx)\
**Post date:** [December 21, 2023, 2:02pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/19 "2023-12-21T14:02:24Z")

</div>

I did but didn’t work i even removed the whole amount field yet it still gave the same error

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 21, 2023, 2:08pm UTC](https://forum.dfinity.org/t/how-to-transfer-funds-tokens-from-a-master-identity-to-another-identity-wallet/25758/20 "2023-12-21T14:08:40Z")

</div>

If I add `: nat` to the amount it works for me:

```auto
❯ dfx canister call ryjl3-tyaaa-aaaaa-aaaba-cai icrc2_approve "(record { amount = 10_000_000_000_000_000: nat; spender = record{owner = principal \"aaaaa-aa\";} })" --network ic
(variant { 17_724 = 9_232_450 : nat })

```
