NEWTON

NEWTON


Popular tags

    How to fix invalid character error while invoking starknetjs frontend app in Cairo?

    Asked

    6 months ago

    119

    views


    0

    Hi everyone,

    When i try to invoke my functions with arguments from my frontend app using starknetjs, i get error invalid character, which i presume is an issue from my function accepting felt, but i'm passing texts. Is there any way to convert to felts from the browser or does starknetjs do this by default?

    Anyone knows how i can solve the error?

    This question was originally posted on StarkNet Discord

      starknetjsjava scriptdiscordcairo

    Newton

    asked

    6 months ago


    1 answers

    0

    Accepted answer

    Hi, invoke like in invokeFunction on the Provider ? 1- There is nothing wrong about using strings. You should use string as you can see from the type that is used in the invokeFunction here https://github.com/0xs34n/starknet.js/blob/b4785793ea912dc8562de4c69b0dcbda4358e144/src/types/lib.ts#L20 2- The correct way to proceed (assuming you want to write to the blockchain) would be (1) create an account and (2) execute a contract function from that account. But before that, did you connect to your wallet? How did you do that? The way it works is the transaction needs to be signed by the user and the easiest way is definitely to ask your wallet to sign it for you. 3- You also need to check the version of starknet-js. What version are you using? 4- If you are stuck, there are several things you could do: (1) find an example and make sure it works; (2) explain where you are stuck (3) provide the code extract and the exact error message you get in details

    This answer was originally posted on StarkNet Discord

    Newton

    answered

    6 months ago

    Your answer

    NEWTON

    NEWTON