Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Character error while using Lucid #83

Closed
ssbright opened this issue Sep 26, 2022 · 7 comments
Closed

Invalid Character error while using Lucid #83

ssbright opened this issue Sep 26, 2022 · 7 comments

Comments

@ssbright
Copy link

Hello, was wondering if you have encountered this error before, and why lucid is throwing it at me. I am trying to use the payToAddress function but with a variable for address. Here is relevant code.

lucid.selectWalletFromSeed(process.env.POOLSEED)
    let address = await lucid.wallet.address();
    let token = "<sometokenID>";
    let tx = await lucid.newTx().payToAddress(addressC, { lovelace: BigInt(1000000), [token]: BigInt(5) }).complete();

error I get: error invalid character (code=")

@alessandrokonrad
Copy link
Contributor

I recommend you to log the variables you use there. The token variable could be wrong as well.

@ssbright
Copy link
Author

This is what I get when I log the address and token. Are there supposed to be quotes around the address?

inputAddress "addr1q87t0w6aex59ve5j73pr9cpy94uras8julnwdv6qx9mwanutt68365g6lg6jyc4fvq24jesf3d68wy76hu7fjk2a34ssqcwhnk"
string
token cf85feeae10e8f6d36d265e2310045a4afc38319a779232e5dfff2466e65774c50
string

@rodrigomd94
Copy link

Seems like you have a typo. You wrote addressC instead of address
let tx = await lucid.newTx().payToAddress(addressC, { lovelace: BigInt(1000000), [token]: BigInt(5) }).complete();

@ssbright
Copy link
Author

ssbright commented Oct 3, 2022

Thanks for the advice, but that wasn't a type. That is how I defined the input, it stands for addressC(ustomer).

Here is more of the code

async function sendToken(addressC, sentADA) {
  try{

    lucid.selectWalletFromSeed(process.env.POOLSEED)
    let address = await lucid.wallet.address();
    let token = "cf85feeae10e8f6d36d265e2310045a4afc38319a779232e5dfff2466e65774c50" 
    let tx = await lucid.newTx().payToAddress(addressC, { lovelace: BigInt(1000000), [token]: BigInt(5) }).complete(); //customer addres
    let txSigned = await tx.sign().complete();

    let hash = await txSigned.submit();
  } catch (error) {
    console.log("this is my error", error)
  }


};

I can also confirm that the token variable works. If I replace addressC with an address in quotes, the code works. However, I am still very confused why my addressC variable does not work.

@rodrigomd94
Copy link

Oh sorry I misunderstood not having looked at the full function. Hmm transaction looks good, have you tried logging the process.env.POOLSEED? Or remove the try-catch to see which line is the problem.

@ssbright
Copy link
Author

ssbright commented Oct 3, 2022

The code works when I replace the addressC with a address in quotes. So I am sure the POOLSEED .env is working. Also I have used console.log and am nearly certain the error is the "let tx = " line

I have a theory that the issue is because my addressC variable has quotes around it, where you can see my token variables does not return with quotes around it. Seems a weird issue.

@ssbright
Copy link
Author

ssbright commented Oct 3, 2022

I ended up solving this by removing the double quotes within the variable. Thanks everyone!

@ssbright ssbright closed this as completed Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants