Get quote for ETH to USDT
The following examples get quote for 1 ETH -> USDT on Ethereum.
Typescript
import axios from 'axios';
const apiKey = '' // Contact Native to get your API key;
const baseUrl = 'https://newapi.native.org/v1/';
const walletAddress = '' // Your wallet address;
// Swap input
const chain = 'ethereum'; // 1, 56
const tokenIn = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; // ETH
const tokenOut = '0xdAC17F958D2ee523a2206206994597C13D831ec7'; // USDT
const amount = 1; // in ether, not in wei
async function callIndicativeQuote() {
const endpoint = 'indicative-quote?';
const headers: any = {
apiKey: apiKey,
};
const response = await axios
.get(
`${baseUrl}${endpoint}chain=${chain}&token_in=${tokenIn}&token_out=${tokenOut}&amount=${amount}&address=${walletAddress}`,
{
headers,
}
)
console.log('Quote result', response.data)
}Python
Last updated