Get SOL Balance
Endpoint:/svm/wallet/balance
- Socket.IO
- HTTP
socket.emit(
"/svm/wallet/balance",
{
chain: "sol",
wallet: "YourSolanaWalletPublicKey",
},
(response) => {
console.log(response);
}
);
await fetch("https://api.chainworks.co/svm/wallet/balance", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CHAINWORKS_API_AUTH_TOKEN,
},
body: JSON.stringify({
chain: "sol",
wallet: "YourSolanaWalletPublicKey",
}),
});
{
"success": true,
"result": {
"balance": "0x59682f00",
"slot": 318472901,
"decimals": 9
}
}
| Field | Type | Description |
|---|---|---|
balance | string | SOL balance in lamports, hex-encoded |
slot | number | Slot the balance was read at |
decimals | number | Always 9 |
Get Token Balance
Endpoint:/svm/wallet/balance/token
- Socket.IO
- HTTP
socket.emit(
"/svm/wallet/balance/token",
{
chain: "sol",
token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
wallet: "YourSolanaWalletPublicKey",
},
(response) => {
console.log(response);
}
);
await fetch("https://api.chainworks.co/svm/wallet/balance/token", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: CHAINWORKS_API_AUTH_TOKEN,
},
body: JSON.stringify({
chain: "sol",
token: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
wallet: "YourSolanaWalletPublicKey",
}),
});
{
"success": true,
"result": {
"balance": "0x5f5e100",
"associatedTokenAccount": "YourAssociatedTokenAccountAddress",
"associatedTokenAccountExists": true,
"decimals": 5,
"uiScalingFactors": {
"decimals": 5,
"multiplier": 1
},
"slot": 318472901
}
}
| Field | Type | Description |
|---|---|---|
balance | string | Token balance in raw units, hex-encoded. 0x0 when the account does not exist |
associatedTokenAccount | string | The wallet’s associated token account for the token |
associatedTokenAccountExists | boolean | Whether that account exists on chain |
decimals | number | Token decimals |
uiScalingFactors.decimals | number | Token decimals |
uiScalingFactors.multiplier | number | UI amount multiplier of the mint. 1 unless the mint uses the Token-2022 scaled UI amount extension |
slot | number | Slot the balance was read at |
balance / 10^decimals * multiplier.
