# What's the equivalent of ic\_cdk::api::call\_with\_payment in agent-js

**URL:** <https://forum.dfinity.org/t/whats-the-equivalent-of-ic-cdk-call-with-payment-in-agent-js/10759>\
**Category:** JavaScript\
**Created:** [February 8, 2022, 7:46am UTC](https://forum.dfinity.org/t/whats-the-equivalent-of-ic-cdk-call-with-payment-in-agent-js/10759 "2022-02-08T07:46:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![coin\_master](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/coin_master/32/15963_2.png) [@coin\_master](https://forum.dfinity.org/u/coin_master)\
**Post date:** [February 8, 2022, 7:46am UTC](https://forum.dfinity.org/t/whats-the-equivalent-of-ic-cdk-call-with-payment-in-agent-js/10759/1 "2022-02-08T07:46:35Z")

</div>

I am trying to use [XTC](https://github.com/Psychedelic/dank/tree/main/xtc) from agent-js and I wanted to use the `mint` function.

From the [documentation](https://github.com/Psychedelic/dank/tree/main/xtc#deposit-cycles-to-mint-an-xtc-balance---mint) the [candid interface](https://github.com/Psychedelic/dank/blob/a7f82de47014d5bca1be0319a45366b145543cac/candid/xtc.did#L190) for mint is `(principal, nat) -> (MintResult);`

And this is how you should call the `mint` function from `dfx`:

` $ dfx canister --network=ic --wallet=$(dfx identity --network=ic get-wallet) call --with-cycles AMOUNT aanaa-xaaaa-aaaah-aaeiq-cai mint "(principal \"$(dfx identity get-principal)\",0:nat)"`

The interesting part here is the `--with-cycles AMOUNT`

As per documentation the `AMOUNT` is the cycles amount that you need to mint and the second arg to `mint` `0:nat` is just a fake argument that gets ignored by `mint` logic.

This is also mentioned in [this post](https://hackernoon.com/tutorial-extending-sonic-with-limit-orders-using-ic-cron-library)

> One can spot an interesting expression inside the `mint()` method - `(to, Nat::from(0))` . Unfortunately, this is how XTC’s API works - you have to pass zero as a second argument (which in classic `ERC-20` `mint()` is the amount of tokens to mint). This value does no affect the algorithm - you will get the same amount of XTC as the amount of cycles you send to this method. So, basically, this second argument is a fake.

The problem here is in the generated javascript binding to this function is looking like this  
`mint: (arg_0: Principal, arg_1: bigint) => Promise<MintResult>;`

and there’s no api for passing cycles equivalent to `--with-cycles`.

The question is how one could pass cycles to this function or how one could use the mint function from agent-js.

---

<div class="post-metadata">

**Author:** ![coin\_master](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/coin_master/32/15963_2.png) [@coin\_master](https://forum.dfinity.org/u/coin_master)\
**Post date:** [March 1, 2022, 7:42am UTC](https://forum.dfinity.org/t/whats-the-equivalent-of-ic-cdk-call-with-payment-in-agent-js/10759/2 "2022-03-01T07:42:19Z")

</div>

Well for people coming later I figured it out.  
You can call the cycles wallet itself to get the same effect.

```auto
  let args = IDL.encode(
    [IDL.Text, IDL.Opt(IDL.Nat), IDL.Opt(IDL.Vec(IDL.Nat8))],
    [to_principal, [], []],
  );
  let swapCyclesToICP = await walletActor.wallet_call({
    canister: Principal.fromText(canister_id_you_want_to_call),
    method_name: "mint",
    args: [...Buffer.from(args)],
    cycles: BigInt(100_000),
  });

```
