Search code examples
node.jssmartcontractsnearprotocolnear-api-js

Near Protocol Unknown arguments


It might be a stupid question, but I am trying to learn how to work with Near Protocol in Near academy.

In chapter 6, you have a task to login to NEAR using CLI, register yourself as a meme museum contributor and register your meme.

Link to the Chapter 6: https://near.academy/near101/chapter-6

I have an issue when I try to register the meme. I am getting an error:

Unknown argument: {meme : bingoo, title : telephonememe, data : https://9gag.com/gag/a718nWb, category : 4}

I am not sure why those arguments are percevied as unknown.

Here's the code:

near call museum.testnet add_meme \ '{"meme" : "bingoo", "title" : "telephonememe", "data" : "https://9gag.com/gag/a718nWb", "category" : 4}' --accountId bingoo.testnet --amount 4


Solution

  • I'm using a windows machine, and I was getting the same error.

    I tried a bunch of things and I saw this AWS post on host to use quotes in the aws cli: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-quoting-strings.html

    I think for windows you can't use the single quotes around the json object, and you can't do the \ for the newline. I would just one long string and \ the " inside the json. like this:

    near call museum.testnet add_meme "{\"meme\" : \"bingoo\", \"title\" : \"telephonememe\", \"data\" : \"https://9gag.com/gag/a718nWb\", \"category\" : 4}" --accountId bingoo.testnet --amount 4
    

    I think this is why they recommend using wsl for windows in their github repo: Windows For Windows users, we recommend using Windows Subsystem for Linux (WSL).

    Install WSL 
    Install npm 
    Install Node.js 
    Change npm default directory 
    This is to avoid any permission issues with WSL
    Open WSL and install near-cli globally by running:
    npm install -g near-cli