The latest documentation for endpoints is always on the DevPortal:
ALTERNATIVE: Retrieve User Token Balance
import { createPublicClient, http } from 'viem';
import { abi as erc20ABI } from './ERC20ABI.json';
const client = createPublicClient({
transport: http('https://rpc.ankr.com/chiliz'),
});
const tokenAddress = '0xYourTokenAddress'; // Replace with the actual ERC-20 contract address
const userAddress = '0xUserWalletAddress'; // Replace with the user's wallet address
async function getTokenBalance() {
const balance = await client.readContract({
address: tokenAddress, // Contract address of the token
abi: erc20ABI, // ERC-20 ABI
functionName: 'balanceOf', // Standard ERC-20 function to get balance
args: [userAddress], // User's address whose balance you want to check
});
return balance.toString();
}
// Example usage
getTokenBalance().then(console.log);
REMOVED WITH NO ALTERNATIVE AVAILABLE
async function getTransaction(txHash) {
const transaction = await client.getTransaction({
hash: txHash, // Replace with the actual transaction hash
});
return transaction;
}
// Example usage
getTransaction('0xTransactionHash').then(console.log);
import { createWalletClient, privateKeyToAccount } from 'viem';
const privateKey = '0xSenderPrivateKey'; // Replace with the sender's private key
const account = privateKeyToAccount(privateKey);
const walletClient = createWalletClient({
account,
transport: http('https://rpc.ankr.com/chiliz'),
});
async function sendTokens(to, amount) {
const txHash = await walletClient.writeContract({
address: '0xYourTokenAddress', // Replace with the ERC-20 token contract address
abi: erc20ABI, // ERC-20 ABI
functionName: 'transfer', // Standard ERC-20 function to transfer tokens
args: [to, BigInt(amount * 1e18)], // Replace 'to' with recipient address and 'amount' with the amount to send
});
return txHash;
}
// Example usage
sendTokens('0xRecipientAddress', 10).then(console.log);
DEPRECATED - Endpoint to sign a transaction via ETH Sign method
post
Authorizations
Body
messagestringRequiredExample: The message to be signed.
Responses
application/json
all ofOptional
application/json
post
POST /wallet/1.0.0/user/wallet/sign-message HTTP/1.1
Host: api-public.socios.com
Content-Type: application/json
Accept: */*
Content-Length: 39
{
"message": "The message to be signed."
}