Transfer sns1 tokens from plug to canister with javascript

Discussion | Support | Bug Report
Hello, how can I transfer SNS1 tokens from Plug to Canister using JavaScript? I have searched the official documentation, but haven’t found any relevant information."

didn’t try it, I believe by

  1. login with Plug GitHub - Psychedelic/plug-connect: The Plug Connect button, is a basic React Component button you can use to integrate Plug's Agent features for authenticating a user's identity and requesting access to the Plug Agent to sign request to your canisters on behalf of that identity.

  2. create actor of SNS1 (zfcdd-tqaaa-aaaaq-aaaga-cai)

  3. call api “icrc1_transfer” (Canister: SNS-1 Ledger - IC Dashboard) to the canister id you want to send

thank you,
I created the sns1 agent in the plugin, but when I try to use its methods, I get an error: TypeError: sns1.icrc1_transfer is not a function. I thought that maybe when I authenticate to the canister, I’m not passing the .did file as an interfaceFactory.

i have solve this problem with import sns1 idl, but i have now new log
Invalid record {to:record {owner:principal; subaccount:opt vec nat8}; fee:opt nat; memo:opt vec nat8; from_subaccount:opt vec nat8; created_at_time:opt nat64; amount:nat} argument: {“from_subaccount”:,“to”:“oxwqk-pqaaa-aaaaa-aaaaq-caiaa-h7q”,“amount”:1,“fee”:,“memo”:,“created_at_time”:[“BigInt(1680476938174000000)”]}
at :8:40927
at :8:24242

“to” is not correct:

idl : to:record {owner:principal; subaccount:opt vec nat8}

but your data is “to”:“oxwqk-pqaaa-aaaaa-aaaaq-caiaa-h7q”

In the first case, I tried to send it to the encrypted address of sns1, and now I tried to simply send it to the account returned by the createUser method and got this log.

Invalid record {to:record {owner:principal; subaccount:opt vec nat8}; fee:opt nat; memo:opt vec nat8; from_subaccount:opt vec nat8; created_at_time:opt nat64; amount:nat} argument: {“from_subaccount”:,“to”:{“owner”:{“_arr”:{“0”:0,“1”:0,“2”:0,“3”:0,“4”:0,“5”:0,“6”:0,“7”:1,“8”:1,“9”:1},“_isPrincipal”:true},“subaccount”:[{“0”:4,“1”:0,“2”:0,“3”:0,“4”:0,“5”:0,“6”:0,“7”:0,“8”:0,“9”:0,“10”:0,“11”:0,“12”:0,“13”:0,“14”:0,“15”:0,“16”:0,“17”:0,“18”:0,“19”:0,“20”:0,“21”:0,“22”:0,“23”:0,“24”:0,“25”:0,“26”:0,“27”:0,“28”:0,“29”:0,“30”:0,“31”:0}]},“amount”:1,“fee”:10000,“memo”:}

my transfer method which i am calling in agent : await sns1.icrc1_transfer({
from_subaccount: ,
to:account,
amount: 1,
fee:10000,
memo: ,

  })      }

and my account looks like owner it is principal and subacc it is a uintArray

fee is opt nat, so should be “fee:[BigInt(1000)]”, not sure if your subaccount is correct , I would suggest to try first.

So my subaccount is already an empty array, I can’t figure out what’s going on here.

I mean to’s subaccount
“subaccount”:[{“0”:4,“1”:0,“2”:0,“3”:0,“4”:0,“5”:0,“6”:0,“7”:0,“8”:0,“9”:0,“10”:0,“11”:0,“12”:0,“13”:0,“14”:0,“15”:0,“16”:0,“17”:0,“18”:0,“19”:0,“20”:0,“21”:0,“22”:0,“23”:0,“24”:0,“25”:0,“26”:0,“27”:0,“28”:0,“29”:0,“30”:0,“31”:0}]

When I changed the “to” property in the object for sending, it now looks like this: to: { owner: account.owner, subaccount: }, and I’m getting a new error “all was rejected: Request ID: 4818f0167ebce66a86a88244fd31cf3a44f9df7b0fa5232e830439d3dd9afc7f Reject code: Reject text: Canister r7inp-6aaaa-aaaaa-aaabq-cai has no update method ‘icrc1_transfer’”.

such as idl i am importing sns1.did.js file

what is this canister? r7inp-6aaaa-aaaaa-aaabq-cai

I think SNS1 is zfcdd-tqaaa-aaaaq-aaaga-cai

I checked my canisterIds.json in the .dfx directory, and the canister ID is as follows.

anyway, this error - “has no update method ‘icrc1_transfer’” notice you called the wrong canister

I think plug doesn’t support icrc1-ledger yet. It can only deal with the old transfer method. I am looking forward to the upgrade.