WalletValidateAddress returns 400 (bad request) when following FileCoin quickstart tutorial

Context

I made it partway through the Filecoin Quickstart, but am getting errors in the ‘Validate Address’ section.

Steps to Reproduce

Complete the first part of the tutorial

The following code snippet successfully returns the blockchain head. I am accessing my Infura Key and Secret in a .env file using the dotenv npm package.

require('dotenv').config()
let request = require('request')
// Call the Infura API and check that the address is valid.
let options = {
    url: 'https://filecoin.infura.io',
    method: 'post',
    headers: {
      'content-type': 'application/json'
    },
    auth: {
        user: process.env.INFURA_PROJECT_ID,
        pass: process.env.INFURA_SECRET
    },
    body: `{
      "jsonrpc": "2.0",
      "id": 0,
      "method": "Filecoin.ChainHead"
  }`
  }

request(options, (error, response, body) => {
  if (error) {
    console.error('Error: ', error)
  } else {
    console.log('Response: ', body)
  }
})

Everything works so far. I am getting the expected response body.

WalletValidateAddress Error

I modified the body to include the address mentioned in the tutorial, and this results in a 400 (Bad Request).

body: `{
    "jsonrpc": "2.0",
    "id": 0,
    "method": "Filecoin.WalletValidateAddress",
    "params": ["f1ydrwynitbbfs5ckb7c3qna5cu25la2agmapkchi"],
}`

Discussion

Wrong address?

I thought I might be getting a 400 request because that address is no longer valid, so I tried to find another address such as the Huobi Hot Wallet listed on the Protocol Labs Filecoin addresses page. I using address, f1abjxfbp274xpdqcpuaykwkfb43omjotacm2p3za I would expect a response of f033259

According to the Quickstart, if I put in the wrong address, I should get an error in the response body

If we had sent over an invalid address, we’d get something like this:
Response: {“jsonrpc”:“2.0”,“id”:0,“error”:{“code”:1,“message”:“invalid address payload”}}

But I am getting a blank response body.

Environment

Node: v16.15.1
request: 2.88.2

hey, try to remove the last comma here:

"params": ["f1ydrwynitbbfs5ckb7c3qna5cu25la2agmapkchi"],

1 Like

Hey @traian.vila ! That worked! I am going to make a PR in the Filecoin docs repo to address this issue in the Quickstart docs. I see their other examples don’t include the comma and this is the only snippet that includes it.

Thank you so much!

2 Likes