0

I was actually developing a token in SOLANA Blockchain and stuck in a place. The problem is.

I need to transfer a custom token ( Eg: MyCustomToken ) I created ( Not SOL ) from one wallet to another and charge the gas fee from another wallet. So the process is,

Wallet A: The token Sender Wallet B: The token Reciever Wallet C: The Fee payer.

I saw that it is possible with --fee-payer argument in the case of SOLANA, but I haven't found a way for Tokens I created. Is there a good solution for this? Please help.

Thanks in Advance

insaneray
  • 75
  • 1
  • 11

1 Answers1

1

The spl-token CLI has the same --fee-payer argument that you can use to set the fee payer, AKA "Wallet C" in your example.

If you're using JS, you'd set it when sending your transaction, ie:

await transfer(connection, walletC, walletATokenAccount, walletB, walletA, amount, []);

Note the payer argument specified as walletC: https://github.com/solana-labs/solana-program-library/blob/2ad468f8b751e819dd68007064495ce2e69ff863/token/js/src/actions/transfer.ts#L18

Jon C
  • 7,019
  • 10
  • 17
  • Thanks a lot for the reply @jon .I was not able to find the code for doing the same from CLI. If you have a link or the code, please share. I will surely check the javascript code and update it. – insaneray May 25 '22 at 05:41
  • 1
    Here is the code for the fee payer argument in the CLI: https://github.com/solana-labs/solana-program-library/blob/424c90034569942375ff9ec39ad82d83f1d46d5e/token/cli/src/main.rs#L1787 and here's the code that sets the fee payer during any transaction sending: https://github.com/solana-labs/solana-program-library/blob/424c90034569942375ff9ec39ad82d83f1d46d5e/token/cli/src/main.rs#L3094 – Jon C May 25 '22 at 15:45
  • Hi jon , i found the way to execute via SOLANA CLI via the door you opened , Thank you , But regarding typescript , Is it possible to find an example link for a transfer / minting with a custom fee payer , Because when i tried to add a custom fee payer , it said signature doesn't match. Thanks in advance. – insaneray May 26 '22 at 08:55
  • 1
    Here's a typescript example from our tests that specified a separate `payer`: https://github.com/solana-labs/solana-program-library/blob/424c90034569942375ff9ec39ad82d83f1d46d5e/token/js/test/e2e/transfer.test.ts#L73 – Jon C May 26 '22 at 18:19
  • Piece of cake now. Thanks a lot, Jon. It helped me to save a lot of time :). – insaneray May 27 '22 at 08:37