0

enter image description here

    // TOKEN ASSOCIATION WITH ALICE's ACCOUNT
    let associateAliceTx = await new TokenAssociateTransaction()
      .setAccountId(aliceId)
      .setTokenIds([tokenId])
      .freezeWith(global.client)
      .sign(aliceKey);

    //SUBMIT THE TRANSACTION
    let associateAliceTxSubmit = await associateAliceTx.execute(global.client);

    //GET THE RECEIPT OF THE TRANSACTION
    let associateAliceRx = await associateAliceTxSubmit.getReceipt(
      global.client
    );

    //LOG THE TRANSACTION STATUS
    console.log(
      `- Token association with Alice's account: ${associateAliceRx.status} \n`
    );

code is here. I am trying to associate and transfer custom tokens with another user but getting same error for both TokenAssociateTransaction and TransferTransaction. What's the problem here?

2 Answers2

0

Instead of alicKey write PublicKey.fromString(aliceKey)

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

You have to pass the tokenId which you would associate with Alice's id. Otherwise keep an account that would create a token and pass it to tokenid(ideally it is the NFT collection id, inside the collection, you will get a serial number(token inside NFT)) you can only associate that token and transfer the same. check the .env file to identify the id which is referring to making this transaction.