Trying to communicate with sui api to fetch balance of an address

I’m trying to fetch my balance of my wallet address using the sui api and node js.
but am getting this response :

Full Response: {
jsonrpc: ‘2.0’,
error: { code: -32601, message: ‘Method not found’ },
id: 1
}

the code I’m using is :

const axios = require(‘axios’);

const rpc = “I can’t put the link of the api here cause this is my first post’”;
const address = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”;

const data = {
jsonrpc: “2.0”,
method: “sui_getBalance”,
id: 1,
params: [address]
};

axios.post(rpc, data, {
headers: {
‘Content-Type’: ‘application/json’
}
})
.then(response => {
console.log(“Full Response:”, response.data);
})
.catch(error => {
console.error(“Error fetching balance:”, error);
});

anyone had similar issue ?

1 Like