SDK Overview
Learn about the zksync-easy-onramp SDK package
The ZKsync Easy On-Ramp SDK package provides a seamless way to integrate fiat purchases and token swaps, ensuring a smooth user experience. It connects with a growing list of services like Kado.money and LI.FI to combine a list of quotes that provide the best returns for your user.
Installation
Install the ZKsync Easy On-Ramp SDK into your app.
npm install zksync-easy-onramp
You can view a demo example implementing the SDK into a Vue app.
Quick start
Configure the SDK
import { createOnRampConfig } from 'zksync-easy-onramp';
createOnRampConfig({
integrator: "ZKsync Easy OnRamp Demo",
},);
Request quotes
import { fetchQuotes } from 'zksync-easy-onramp';
const quotes = await fetchQuotes({
toAddress: "0xE6a8bEEFC1Bca3046235e0d1f8db805734949024",
fiatAmount: 25,
fiatCurrency: "USD",
chainId: 324,
toToken: "0x000000000000000000000000000000000000800A",
});
Execute a quote
import { executeRoute } from 'zksync-easy-onramp';
const quotes = await fetchQuotes({...});
const quote = executeRoute(quotes[0], {
onUpdateHook: (executingRoute) => {
// receive the latest state change
// of the quote that is executing
console.log(executingRoute);
}
})