1

I am currently working on a snap to integrate with XRPL. However, I have a problem when I want to get data from rippled server.

This is the URL that I am calling: POST https://s.altnet.rippletest.net:51234

This is my payload

{
    "method": "account_info",
    "params": [
        {
            "account": "rDtBYnfg4ehGdYKg98GbxPK63w2rWzYUpT",
            "ledger_index": "current",
        }
    ]
}

I always get error saying Failed to fetch I am doing a call like this:

const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    redirect: 'follow',
    body: JSON.stringify(payload),
});

And there are my initial permissions from snap manifest:

"initialPermissions": {
    "snap_confirm": {},
    "snap_manageState": {},
    "endowment:network-access": {}
},

I am always getting following error:

{
    "code": -32603,
    "message": "Failed to fetch",
    "data": {
        "originalError": {}
    }
}
golobitch
  • 1,466
  • 3
  • 19
  • 38

1 Answers1

0

Your JSON data is invalid.

{
    "method": "account_info",
    "params": [
        {
            "account": "rDtBYnfg4ehGdYKg98GbxPK63w2rWzYUpT",
            "ledger_index": "current",
        }
    ]
}

should be changed to

{
    "method": "account_info",
    "params": [
        {
            "account": "rDtBYnfg4ehGdYKg98GbxPK63w2rWzYUpT",
            "ledger_index": "current"
        }
    ]
}

(mind the missing "," (comma) after "ledger_index": "current"

This should work then :)

nixer
  • 46
  • 3
  • Actually, the problem here was in CORS. Rippled does not have CORS support. https://github.com/XRPLF/rippled/issues/3513 – golobitch Nov 11 '22 at 20:07